Skip to content

Best Practices

In this section we present some best practices that should be taken into account while using the eManager.

How to write files in an eManager

Important information for eManagers (non-Pro).

The eManager has NAND Flash memory for the file system, unlike the eManager Pro which has eMMC flash memory.

NAND Flash memory has the particularity that it does not ensure the atomicity of file writes if the device is disconnected from the power supply, in addition to being slower than eMMC Flash memory.

Atomicity is the property that ensures that an operation has been carried out or not, and therefore, in the event of a system failure, it cannot be left halfway. An operation is said to be atomic when it is impossible for any other part of a system to find intermediate steps.

Hence, unexpected power outages during non-atomic file writes can cause data loss and file corruption, mainly in non-Pro eManagers.

To avoid this problem and guarantee the atomicity in an eManager, it is very important to use the sync command after modifying files.

In this way, atomicity will ensure that the contents of the file have either had time to be fully written, or have not had time, but not halfway through, and thus prevent the file from becoming corrupt.

It is crucial to use atomicity in your Node-RED projects as well, to ensure atomicity during file writes.

We can apply atomicity in our Node-RED projects by using temporary files. The data will be written first in a temporary file and then moved to the final file. To do so, the command mv is used due to its atomicity, since it ensures that all the content of the temporary file will be written to the final file without any data loss.

You can find a Node-RED flow example, working with files atomicity here.