tmp_log.bin file

Hi there,

I had been using the great SdFat library and the example LowLatencyLogger. It is super powerful and efficient. However, sometime i did not truncate properly and my file cannot be save properly, so instead of getting a proper .bin file, I end up getting a temporary file (tmp_log.bin).

If my understanding is correct, this tmp_log.bin file still contain the info from my sensors. The sequence of LowLatencyLogger should be something like this:

  1. create tmp_log.bin file
  2. start logging data and store all the results in this tmp_log.bin file
  3. once reach the size of tmp_log.bin file or truncate the logging, this tmp_log.bin file will be deleted and a proper .bin file will be create.

So if this sequence is correct, which means part of my data is still in this temporary file. So how can I read or convert this tmp_log.bin file into readable file?

Thank you.

Your sequence of steps is nearly correct.

Step three: If the all space in tmp_log.bin is used or the run is terminated, tmp_log.bin is truncated and renamed.

If the the logger does not terminate correctly, data will be in tmp_log.bin plus any unused space.

With the latest LowLatencyLogger you could manually rename the file and then use the new 'b' command to open the file and convert it to csv.

Looks like a command to recover data in tmp_log.bin would be useful.

I have added tmp file recovery to versions of LowLatencyLogger in SdFat-beta.

I have changed the tmp file name to the base file name with “##” in place of the file version number. This should prevent recovery of the wrong data if you use appropriate base file names.

It is fast since I use a binary search to find the last good data block and truncate the file at that point.

It is automatic. Here is an example:

--------------- start logging here ------------------

Creating new file
Erasing all data
FreeStack: 765
Logging - type any character to stop

---------- crash and reboot happens here ----------

FreeStack: 1316
Records/block: 42

Type ‘Y’ to recover existing tmp file adc4pin##.bin

---------- type ‘Y’ here -----------------------------

Recovering data in tmp file adc4pin##.bin
File renamed: adc4pin04.bin
File size: 55 blocks

The file will be open as the current binFile but you can also open it later using the new ‘b’ command.

fat16lib:
I have added tmp file recovery to versions of LowLatencyLogger in SdFat-beta.

I have changed the tmp file name to the base file name with “##” in place of the file version number. This should prevent recovery of the wrong data if you use appropriate base file names.

It is fast since I use a binary search to find the last good data block and truncate the file at that point.

It is automatic. Here is an example:
The file will be open as the current binFile but you can also open it later using the new ‘b’ command.

Dear OP fat16lib,

You may not know me But you have save me so many times.Please allow me to say thank you and you are the best.

Thank you so so so much.