Hello,
I am developing a project that counts, in seconds, how long signals is active. My approach requires a JSON file to be read and written to every 1 second. So this file is pretty much always in use. During system testing, I noticed that whenever I power down the groov EPIC and turn it back on, that file gets corrupted. It is a JSON file that contains 4 key value pairs:
{
“timestamp”: 1699898856527,
“sig_1”: 291034,
“sig_2”: 287280,
“sig_3”: 285840
}
When the EPIC powers back on, this is what the file turns into:
��������������������������������������������������������������������
The file is located in /home/dev/secured/seconds.json
At first, I assumed it was the Node-RED read / write nodes that are improperly closing the file or something. So I decided to make two backups of that file, and to alternate writing to each backup file once every 10 seconds. If the ‘original’ file was corrupted, I would compare timestamps between the two backup files and grab the latest one. to My assumption was that 20 seconds would be more than plenty to ensure that at least one backup file is closed. That did not work as all three files are corrupted when the device restarts.
I decided to ditch the Node-RED read / write nodes and to use the exec node to read and write. I used cat to read in a file, then echo to write it back. That still didn’t resolve the issue, even when using the two backup files method mentioned above.
There are other files in /home/dev/secured/ that remain intact on restart. Of course, I am assuming the problem is that the file is not closing. Really, I am unsure what the cause of this problem is. Any insight would be appreciated!