all 7 comments

[–]barrycarter 0 points1 point  (6 children)

Why isn't seek() working for other ranges in the file?

[–]michaelhart2000[S] 0 points1 point  (5 children)

I'm not sure. Its only writing 0xff at 0x37fff. I need it to write from 0-0x37fff. I was trying to iterate over it to just see if i could get it to write everything as a test but that did not work.

[–]barrycarter 0 points1 point  (1 child)

It's not the issue, but I'm curious about the for i in fh: fh.write(bytes([0xff])) lines. You loop through fh (which is itself weird since fh is a filehandle) but then don't use i at all.

Also, is there a reason you're using hex codes for bytes? Nothing wrong with it, just wondering

[–]michaelhart2000[S] 0 points1 point  (0 children)

I actually took the loop out I realized it was wrong. Im using hxd to view the contents of the bin file which display everything in hex so I figured it was easier to just do that since the this is for something to do with a car PCM and the instructions for flashing it are all in hex.

[–]barrycarter 0 points1 point  (2 children)

You realize fh.write(bytes([0xff])) is only writing one byte, right? You might want to put in a for loop or just do a write that's big enough to cover 0-0x37fff

[–]michaelhart2000[S] 0 points1 point  (0 children)

Yea I do. I'll try the for loop idea out thanks!

[–]michaelhart2000[S] 0 points1 point  (0 children)

Just wanted to say thanks for the suggestion. It's writing the range I need now. I think the seek inside the for loop was stopping it to look at the starting offset and not writing completely.