Skip to content

Conversation

smlkdev
Copy link

@smlkdev smlkdev commented Mar 12, 2019

Hello!

I would love to add this small functionality into your project!

Cheers,
smlkdev

Copy link

@nazriel nazriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noice.

lpc17prl.lua Outdated
if opts.mode == 'calculate' then
if not opts.fname then D.abort(2, "Binary file not provided") end

local f, err = io.open(opts.fname, "r+b")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually you see such order for open-mode.

Suggested change
local f, err = io.open(opts.fname, "r+b")
local f, err = io.open(opts.fname, "rb")

but what you wrote seems to be good as well :)

lpc17prl.lua Outdated
local bytes = f:read(4)
local int32 = B.dec32LE(bytes)
sum = sum + int32
D.yellow''(byteno,int32,B.hex(int32))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's convenient for development purposes - I think user is not interested in those values

lpc17prl.lua Outdated

local sum = 0

for byteno=1,7,1 do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: you can omit tailing 1:
for byteno=1,7 do

lpc17prl.lua Outdated
f:write(B.enc32LE(sum))
f:close()

D.green'File saved! Checksum:'(sum,B.hex(sum))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again - not sure if it's really needed.

lpc17prl.lua Outdated

D.green'File saved! Checksum:'(sum,B.hex(sum))

os.exit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I'd like patch the file and write it to flash in one go?
Maybe we can think of supporting syntax like ./lpc17prl.lua -XW FILE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants