Files | |
file | CO_OD_storage.h |
CANopen Object Dictionary storage object for Linux SocketCAN. | |
Data Structures | |
struct | CO_OD_storage_t |
Object Dictionary storage object. More... | |
Functions | |
CO_SDO_abortCode_t | CO_ODF_1010 (CO_ODF_arg_t *ODF_arg) |
Callback for use inside CO_OD_configure() function for OD object 1010. | |
CO_SDO_abortCode_t | CO_ODF_1011 (CO_ODF_arg_t *ODF_arg) |
Callback for use inside CO_OD_configure() function for OD object 1011. | |
int | CO_OD_storage_saveSecure (uint8_t *odAddress, uint32_t odSize, char *filename) |
Save memory block to a file. More... | |
int | CO_OD_storage_restoreSecure (char *filename) |
Remove OD storage file. More... | |
CO_ReturnError_t | CO_OD_storage_init (CO_OD_storage_t *odStor, uint8_t *odAddress, uint32_t odSize, char *filename) |
Initialize OD storage object and load data from file. More... | |
CO_ReturnError_t | CO_OD_storage_autoSave (CO_OD_storage_t *odStor, uint32_t timer1usDiff, uint32_t delay_us) |
Automatically save memory block if differs from file. More... | |
void | CO_OD_storage_autoSaveClose (CO_OD_storage_t *odStor) |
Closes file opened by CO_OD_storage_autoSave. More... | |
Object Dictionary storage implementation for CANopenNode on Linux
Save memory block to a file.
Function renames current file to filename.old, copies contents from odAddress to filename, adds two bytes of CRC code. It then verifies the written file and in case of errors sets back the old file and returns error.
Function is used with CANopen OD object at index 1010.
odAddress | Address of the memory block, which will be stored. |
odSize | Size of the above memory block. |
filename | Name of the file, where data will be stored. |
int CO_OD_storage_restoreSecure | ( | char * | filename | ) |
Remove OD storage file.
Function renames current file to filename.old, then creates empty file and writes two bytes "-\n" to it. When program will start next time, default values are used for Object Dictionary. In case of error in renaming to .old it keeps the original file and returns error.
Writing data to file is secured with mutex CO_LOCK_OD.
Function is used with CANopen OD object at index 1011.
filename | Name of the file. |
CO_ReturnError_t CO_OD_storage_init | ( | CO_OD_storage_t * | odStor, |
uint8_t * | odAddress, | ||
uint32_t | odSize, | ||
char * | filename | ||
) |
Initialize OD storage object and load data from file.
Called after program startup. Load storage file and copy data to Object Dictionary variables.
odStor | This object will be initialized. |
odAddress | Address of the memory block from Object dictionary, where data will be copied. |
odSize | Size of the above memory block. |
filename | Name of the file, where data are stored. |
CO_ReturnError_t CO_OD_storage_autoSave | ( | CO_OD_storage_t * | odStor, |
uint32_t | timer1usDiff, | ||
uint32_t | delay_us | ||
) |
Automatically save memory block if differs from file.
Should be called cyclically by program. It first verifies, if memory block differs from file and if it does, it saves it to file with two additional CRC bytes. File remains opened.
odStor | OD storage object. |
timer1usDiff | Time difference in microseconds since last call. |
delay_us | Delay (inhibit) time between writes to disk in microseconds (60000 for example). |
void CO_OD_storage_autoSaveClose | ( | CO_OD_storage_t * | odStor | ) |
Closes file opened by CO_OD_storage_autoSave.
odStor | OD storage object. |