Hello Group,
How can I save a structure to a file using the LITTLEFS library?
I have a series of values that don't fit in RAM. This is the structure I'm attaching.
The values are saved in the variable "LOGGER1" at a time interval of 20 to 40 mS.
I need to store about 800 values, but if I expand the variable to more than 500, I'll run out of memory on the ESP32.
Since the data collection process is in two parts: about 2 seconds of activation in one direction, 1 second of pause where I don't need to store data, and 4 seconds in the opposite direction where I need to store data again.
The idea is to use the 420 positions I have available to take two blocks of data, the first and the third. During the second block, store the values from the first block in a file, and when finished, store the data from the third block.
In short, I need to store the 420 positions of the variable in a file as quickly and efficiently as possible.
This would involve opening the file in write mode. The data in the file would be deleted. Write the 420 positions, and then close the file.
I have two problems.
1. The problem is with the length when saving. How do I know the length of the variables?
2. How do I convert the variable LOGGER1(n) to a byte to store it with the LITTLEFS library?
Thank you.
How can I save a structure to a file using the LITTLEFS library?
I have a series of values that don't fit in RAM. This is the structure I'm attaching.
Type D_Logger1 (P_Encoder As Int, _ ' Posicion del Encoder
P_Encoder_F As Int, _ ' Posicion del Encoder Filtrada
P_Puerta As Int, _ ' Posicion de la Puerta en %
C_Velocidad As Int, _ ' Consigna de Velocidad al Accionamiento
Intensidad_M As Int, _ ' Intensidad Consumida por el Motor
Secuencia As Byte, _ ' Numero de Secuencia
CP_Encoder As Byte, _ ' Calidad de la Comunicacion con el Encoder en el ultimo Segundo
CT_Encoder As Byte, _ ' Calidad de la Comunicacion con el Encoder Total
Modo_M As Byte, _ ' Indica el Modo de maniobra de la Puerta
SG1 As Byte, _ ' Grupo 1 de Variables
SG2 As Byte, _ ' Grupo 2 de Variables
SG3 As Byte, _ ' Grupo 3 de Variables
SG4 As Byte _ ' Grupo 4 de Variables
)
Public Logger1(420) As D_Logger1 ' Datos del Logger
The values are saved in the variable "LOGGER1" at a time interval of 20 to 40 mS.
I need to store about 800 values, but if I expand the variable to more than 500, I'll run out of memory on the ESP32.
Since the data collection process is in two parts: about 2 seconds of activation in one direction, 1 second of pause where I don't need to store data, and 4 seconds in the opposite direction where I need to store data again.
The idea is to use the 420 positions I have available to take two blocks of data, the first and the third. During the second block, store the values from the first block in a file, and when finished, store the data from the third block.
In short, I need to store the 420 positions of the variable in a file as quickly and efficiently as possible.
This would involve opening the file in write mode. The data in the file would be deleted. Write the 420 positions, and then close the file.
I have two problems.
1. The problem is with the length when saving. How do I know the length of the variables?
2. How do I convert the variable LOGGER1(n) to a byte to store it with the LITTLEFS library?
Thank you.