Fd. Object's Status Codes

Top  Previous  Next

Discussed in this topic: fd.laststatus.

 

Many things can go wrong when working with the flash memory. This is why methods of the fd. object return a status code. Good Tibbo BASIC/C application doesn't just assume that all will be well and always checks the result of method execution.

Listed below are possible status codes retuned by the flash disk object. Of course, not every code can be generated by every method:

0- PL_FD_STATUS_OK: Completed successfully.

1- PL_FD_STATUS_FAIL : Physical flash memory failure (fatal: disk dismounted, must be reformatted).

2- PL_FD_STATUS_CHECKSUM_ERR: Checksum error has been detected in one of the disk sectors (fatal: disk dismounted, mast be reformatted).

3- PL_FD_STATUS_FORMAT_ERR: Disk formatting error has been detected (fatal: disk dismounted, mast be reformatted).

4- PL_FD_STATUS_INV_PARAM: Invalid argument have been provided for the invoked method.

5- PL_FD_STATUS_DUPLICATE_NAME: File with this name already exists.

6- PL_FD_STATUS_FILE_TABLE_FULL: Maximum number of files that can be stored on the disk has been reached, new file cannot be created.

7- PL_FD_STATUS_DATA_FULL: The disk is full, new data cannot be added.

8- PL_FD_STATUS_NOT_READY: The disk is not mounted.

9- PL_FD_STATUS_NOT_FOUND: File not found.

10- PL_FD_STATUS_NOT_OPENED: No file is currently opened "on" the current fd.filenum.

11- PL_FD_STATUS_ALREADY_OPENED: This file is already opened on some other file number.

12- PL_FD_STATUS_TRANSACTION_ALREADY_STARTED: Disk transaction has already been started (and cannot be restarted).

13- PL_FD_STATUS_TRANSACTION_NOT_YET_STARTED: Disk transaction hasn't been started yet.

14- PL_FD_STATUS_TRANSACTION_CAPACITY_EXCEEDED: Too many disk sectors have been modified in the cause of the current transaction (fatal: disk dismounted).

15- PL_FD_STATUS_TRANSACTIONS_NOT_SUPPORTED: The disk wasn't formatted to support transactions (use fd.formatj with maxjournalsectors>1 to enable transactions).

16- PL_FD_STATUS_FLASH_NOT_DETECTED: Flash IC wasn't detected during boot, fd. object cannot operate normally.

 

The status code generated by the most recently invoked method is always kept by the fd.laststatus R/O property. Some methods also return the status code directly:

 

 

If fd.create("File1.dat")<>PL_FD_STATUS_OK Then

  'some problem

End If

 

 

Other methods return data, so the only way to check the result of their execution is through the fd.laststatus:

 

 

s=fd.getdata(50) 'returns the data from the file, not the status code

If fd.laststatus<>PL_FD_STATUS_OK Then

  'some problem

End If

 

 

Most status codes are non-fatal, that is, they allow the disk to continue working.

Selected status conditions result in the automatic dismounting of the flash disk (fd.ready R/O property becomes 0- NO). Among these status codes, some (but not all) conditions also indicate that the disk is permanently damaged and must be reformatted.