I'm trying to make a Hex viewer which only reads the portion of the file which is shown on the screen (in order to read files which are much larger than 32kB).
However after a certain point in the file it starts reading incorrectly and after a while it crashes the brick and I have to remove the batteries. SysFileSeek does not at any point return any errors.
Here is a stripped down version of my code (with TextOut() instead of FontTextOut()):
This was indeed what I was doing but the crash also happens when viewing the other programs. (It was just because it was the only .rxe file on my NXT at the moment, not that I need to be able to do it.)
There was only a single .sys file which size was 6 bytes and the program reads 64 bytes at once, thus there would be no seeking when using that file. I could have uploaded some random file, I had just forgotten that you can't read the currently running program.
timpattinson wrote:I think they are actuallly RXEs
Clarification: I meant the .rxe cannot read itself (because it already has an open handle?). It can read other.rxe files, though.
It runs OK on my NXT until it reaches the end of the file.
Try opening a large 1KB file. Scroll down for a while (to the bottom?). It freezes.
EDIT: In addition, when viewing a small >16 bytes file, it shows a bunch of "ADDBEDAB..." over and over, filling the screen. When you press the left button, it freezes. The right button doesn't seem to do anything other than refresh the drawing.
Commit to LEGO Mindstorms Robotics Stack Exchange: bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Yes, it crashes and shows random values when it is at the end of the file. However when opening a large file (KB size) it freezes long before it is near the end. (Until I'm sure I can fix this issue I'm not going to fix the other easier one.)
With the latest enhanced NBC/NXC firmware on my brick and the latest version of the compiler I do not experience any crashes/freezes with your program even when it reaches the end of a nearly 6kb file.
FYI, seeking only works with files opened for reading at this point. It may be that you have a slightly older and buggy version of the firmware on your NXT?
I did try to update the firmware to the latest version. However while I thought I already had downloaded the latest BCC release, I had not...
It indeed works fine now. Updating your software (correctly) really does magic : )