Announcement

Collapse
No announcement yet.

Rare file_Open() failure? Something else?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rare file_Open() failure? Something else?

    Alright, here's my problem.

    I have a save function, which is in it's own 4fn file. It is writing data to the sdcard.

    It has two files that it updates. Here is my process:

    1) Read total from file
    2) Increment total, reopen file, and write
    3) reopen file and write new data to the end

    I kinda mix it up though, if you have file A and file B it goes like this.

    A1
    A2

    B1
    B2
    B3

    A3

  • #2


    Yes, things like this are difficult to isolate, but your on the right track with what you have suggested
    and check for corrupted file pointers etc.

    Also, file_Error should be non zero if a failure occured, so monitoring this somewhere and printing to the screen may give you some idea of the failure.

    Re-mounting the drive if it is already open is ok to do, if the system detects that it is already mounted
    it will unmount, then remount.

    For infrequent disk operations, or data logging, it is recommended to mount only when needed, and unmount when finished.
    Regards,
    Dave

    Comment


    • #3


      Okay, well that's what I'm doing so far, we'll see what it comes up with the next time it happens. How about the file_Close() function. If the pointer got corrupted and I tried to close with the corrupted pointer, could it nullify everything I just tried to write? It seems like it would just leave the memory allocation but the data would be written.

      Comment


      • #4


        Yes, closing a file with a corrupted file pointer will usually casue a catastrophic event which can trash the entire drive.
        Regards,
        Dave

        Comment

        Working...
        X