I recently started up with a new NXT 2.0 kit, using a MacBook Pro and NXC. I'm compiling and downloading the code to the NXT from the Terminal. For some reason, for a very simple program (just turning Motor A on for some seconds and then stopping), the program runs and then displays "File error!" on the NXT LCD screen. Has anyone else had this before? I think I've downloaded all the necessary firmware and driver updates.
My first suggestion is that you stop #including NXCDefs.h. The compiler does this automatically for you so there is no reason to put this line in your own code anymore. It was needed a long time ago so old sample code may still do this.
My second suggestion is that you are perhaps not actually running the latest enhanced NBC/NXC firmware on your NXT if all you see is the File Error! message without a number also shown on the screen. Recent releases of the enhanced firmware have added an error code output to this message so that you can tell what kind of problem has occurred. You can get version 1.31 of the enhanced NBC/NXC firmware via links on the BricxCC page or in the latest test release zip at http://bricxcc.sourceforge.net/test_releases/. Check the NXT Versions screen under Settings on your NXT to see what version you are actually running. If it doesn't say NBC/NXC on that page then you are running the standard firmware.
My third suggestion is that in a trivial program like this the most likely cause for a File Error message is trying to run 2.0 code on a 1.0 firmware or code that requires the enhanced firmware on the standard firmware or code compiled with a version of NBC that doesn't know anything about the 2.0 firmware on a 2.0 firmware. So it would be good to verify that you are running the latest NBC for your platform and that you are passing -EF if you have the enhanced firmware on your brick but not using that switch on the command line if you have the standard firmware on your brick. And if you happen to have the 1.0x firmware on your brick and are using a recent release of NBC that you are passing -v=107 on the command line so that the compiler correctly targets the 1.0x firmware. Older versions of NBC defaulted to a 1.0x target version but the recent releases now default to using a version of 1.28 (-v=128).
If your program used arrays then another common cause for File Error messages is reading or writing past the end of an array, i.e., trying to access element n when there are only n elements in the array, since in C arrays are indexed from 0 to n-1 for an array with n elements.
nxtboyiii wrote:Do you have the latest enhanced firmware?
afanofosc wrote:My first suggestion is that you stop #including NXCDefs.h. The compiler does this automatically for you so there is no reason to put this line in your own code anymore. It was needed a long time ago so old sample code may still do this.
My second suggestion is that you are perhaps not actually running the latest enhanced NBC/NXC firmware on your NXT if all you see is the File Error! message without a number also shown on the screen. Recent releases of the enhanced firmware have added an error code output to this message so that you can tell what kind of problem has occurred. You can get version 1.31 of the enhanced NBC/NXC firmware via links on the BricxCC page or in the latest test release zip at http://bricxcc.sourceforge.net/test_releases/. Check the NXT Versions screen under Settings on your NXT to see what version you are actually running. If it doesn't say NBC/NXC on that page then you are running the standard firmware.
My third suggestion is that in a trivial program like this the most likely cause for a File Error message is trying to run 2.0 code on a 1.0 firmware or code that requires the enhanced firmware on the standard firmware or code compiled with a version of NBC that doesn't know anything about the 2.0 firmware on a 2.0 firmware. So it would be good to verify that you are running the latest NBC for your platform and that you are passing -EF if you have the enhanced firmware on your brick but not using that switch on the command line if you have the standard firmware on your brick. And if you happen to have the 1.0x firmware on your brick and are using a recent release of NBC that you are passing -v=107 on the command line so that the compiler correctly targets the 1.0x firmware. Older versions of NBC defaulted to a 1.0x target version but the recent releases now default to using a version of 1.28 (-v=128).
If your program used arrays then another common cause for File Error messages is reading or writing past the end of an array, i.e., trying to access element n when there are only n elements in the array, since in C arrays are indexed from 0 to n-1 for an array with n elements.
John Hansen
I re-downloaded 1.29 and it stopped displaying that error, perhaps something somehow got overwritten when I was getting all the updates? Thanks!
lizard381 wrote:I re-downloaded 1.29 and it stopped displaying that error, perhaps something somehow got overwritten when I was getting all the updates? Thanks!
Kami
If you have 1.29, then I don't think it is enhanced. I don't think John ever released a 1.29 enhanced. The latest he did was 1.31 (but he skipped 1.29, I think).