I have a requirement to read the last byte from a custom file we store in the flash using the MDot File Api.
Here is a log information, when attempting to read the last byte of the file.
[TRACE] File Name: DeviceInfoBkp.dat, Size: 162 bytes.
[ERROR] SPIFFS_lseek failed -10003
This is the version of the production mbed mdot library we are using.
MDOT Library version: 3.1.0 and MBED OS Version: 5.7.7.
Also here is the code that we are using
uint8_t nChannelPlan = 0;
//check and see if the bkp file exists, if so read the file and read the last //byte of the file.
mDot::mdot_file file = m_pDot->openUserFile(DeviceInfoBkpFileName, mDot::FM_RDONLY);
//check if the file exists.
if(file.fd >= 0 && file.size > 0) {
if(m_pDot->seekUserFile(file, 1, SEEK_END)) {
if(m_pDot->readUserFile(file, &nChannelPlan , sizeof(uint8_t))){
logDebug("Channel Plan: %u", nChannelPlan);
}
}
}
m_pDot->closeUserFile(file);
Thanks,
Ajay.