-
Notifications
You must be signed in to change notification settings - Fork 1
Added checksum calculator option for microcontroller. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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") |
There was a problem hiding this comment.
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.
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
Hello!
I would love to add this small functionality into your project!
Cheers,
smlkdev