Closed ahogen closed 5 years ago
len(binflie)
is the sum of all segments' lengths.
len(binfile.as_binary()
is the binary minimum address subtracted from the maximum address. So this includes padding between segments.
So if you have a file with two segments, say addresses 0-10 and 90-100, len(binfile)
returns 20, while len(binfile.as_binary()
returns 100.
I have absolutely no idea if this behavior is good, but that's how it works.
Ah! Okay, that is good to know. I can certainly understand the reasoning there.
I guess maybe the padding=None
default argument of as_binary()
might have been throwing me off. In terms of the English language, that obviously looks like "no padding will be added between segments". Which obviously does not make sense when generating a binary blob... you need padding. So the behavior makes sense, but the "api" wording was throwing me off.
Anyhow, thanks for the clarification.
And thanks for the library! Been getting a some good use out of it! Saved me a lot of headache as I have a need to read, modify, and write compiled ihex/binaries.
Cheers!
I clarified that giving padding as None
means pad with 0xff.
I haven't looked into this too deeply, but just thought I'd ask. How come the length of the
binfile
object is not equal to the length of the bytes returned bybinfile.as_binary()
?For example, if you added this statement to the regression test code, the test will fail.
Could you explain the difference between the two?
Thanks!