To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxtOpen lugnet.robotics.nxt in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / 851
     
   
Subject: 
File Error - what does it exactly mean?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Sun, 5 Aug 2007 00:12:51 GMT
Viewed: 
23162 times
  

Hello,

I have an NBC program which compiles fine and the previous versions of it were
working as expected.  After some minor modifications, the program is interrupted
in the middle with a message "File Error!" shown on the LCD for a short momemnt
and terminated.

Is this meaning that my NBC program is wrong, or that NBC (1.0.1.b31) produces
some faulty byte-code, or that there is a bug in the NXT standard firmware
(1.04), or something else, please?

Thank you,
Pavel.

   
         
   
Subject: 
Re: File Error - what does it exactly mean?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Sun, 5 Aug 2007 01:12:44 GMT
Viewed: 
22939 times
  

a message "File Error!" shown on the LCD for a short moment
and terminated.

I have to answer myself after analyzing the reason.
The error occured when trying to access elements of array
outside of the initialized range. Glad to have resolved it.

   
         
   
Subject: 
Re: File Error - what does it exactly mean?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Sun, 5 Aug 2007 06:12:37 GMT
Viewed: 
23663 times
  

In lugnet.robotics.nxt, Pavel Petrovic wrote:
a message "File Error!" shown on the LCD for a short moment
and terminated.

I have to answer myself after analyzing the reason.
The error occured when trying to access elements of array
outside of the initialized range. Glad to have resolved it.

I would guess that 99% of the time that you get a File Error abend in an NXT
program it is because of trying to access an element beyond the end of the
array.  I'm glad you were able to figure the problem out quickly.  It would be
nice if the firmware was a little more informative regarding the error it
encountered. :-)

John Hansen

   
         
   
Subject: 
Re: File Error - what does it exactly mean?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Fri, 17 Aug 2007 11:33:40 GMT
Viewed: 
23366 times
  

In lugnet.robotics.nxt, John Hansen wrote:
In lugnet.robotics.nxt, Pavel Petrovic wrote:
a message "File Error!" shown on the LCD for a short moment
and terminated.

The error occured when trying to access elements of array
outside of the initialized range.

I would guess that 99% of the time that you get a File Error abend in an NXT
program it is because of trying to access an element beyond the end of the
array.

But I am getting it when trying to allocate an array that is larger
than the amount of heap available. And it seems there is no way of
checking how much space remains free, so I have no way of preventing
this File Error! from happening if I have a program that needs to
allocate memory during the run without knowing in advance how much it
would be. The only way I see is ardously manually try how much heap
there is on the start and then try to keep track of it somehow by
computing the amounts eaten by dv, etc...?

To conclude: I am missing a system call/macro that can tell me how
much is ok to pass to arrinit for some particular array. Or alternately,
make arrinit not to crash when there is not enough memory, simply return
empty array, and I will check with arrsize whether the allocation worked out.
I.e. arrinit that does not fill the array with some value...
Or even another way: passing some special constant to arrinit would allocate
the largest possible array that can be allocated (ideally after compacting
the memory)

   
         
   
Subject: 
Re: File Error - what does it exactly mean?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Fri, 17 Aug 2007 15:35:55 GMT
Viewed: 
23193 times
  

In lugnet.robotics.nxt, Pavel Petrovic wrote:
But I am getting it when trying to allocate an array that is larger
than the amount of heap available.

You've got 32k to work with for all variables of all types, including
user-defined types and arrays.  Every time you manipulate an array you use up
more memory due to copying taking place in the VM.

If you shared with me some information about your program I might be able to
help you avoid excessive memory allocations. Email me and I'll try to help.

John Hansen

   
         
   
Subject: 
Re: File Error - what does it exactly mean?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Fri, 17 Aug 2007 21:39:28 GMT
Viewed: 
23441 times
  

In lugnet.robotics.nxt, John Hansen wrote:
In lugnet.robotics.nxt, Pavel Petrovic wrote:
But I am getting it when trying to allocate an array that is larger
than the amount of heap available.

You've got 32k to work with for all variables of all types, including
user-defined types and arrays.  Every time you manipulate an array you use up
more memory due to copying taking place in the VM.

If you shared with me some information about your program I might be able to
help you avoid excessive memory allocations. Email me and I'll try to help.

Well, I try to allocate all memory available for one big array and then deal
with it using my own memory manager with C-like calls of malloc and free. It
works fine, but I'd need to know how big this one array I can make while the
program still avoiding the File Error message. Other allocations I make are only
for retrieving/sending messages from BT and writing/reading data to file system.

Every once and then I get this message, because I add some more variables and
strings used in debug printouts in the program and then the arrinit fails and I
have to manually figure out what size is still ok... I'd like a feeback from
arrinit call that there's not enough memory instead of crashing the program.

 

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR