LoadConstantsFromFile [LJM User's Guide]
Loads a specified file as the Modbus map and Error constants.
Syntax
LJM_ERROR_RETURN LJM_LoadConstantsFromFile(const char * FileName)
Parameters
FileName [in]
The absolute or relative file path to load as the constants. Must null-terminate. "default"
maps to the default configuration file ljm_startup_config.json
in the constants file location (see Constants file parameters).
Returns
LJM errorcodes or 0
for no error.
LJME_CONSTANTS_FILE_NOT_FOUND
(1292
): FileName did not point to a readable file location.
LJME_INVALID_CONSTANTS_FILE
(1293
): The file located at FileName was not a valid constants file. LJM_ErrorToString
outputs a specific error message.
Remarks
LJM_LoadConstantsFromFile
is an alias for executing LJM_WriteLibraryConfigStringS with LJM_CONSTANTS_FILE
as the input Parameter
and FileName
as the input String
:
LJM_WriteLibraryConfigStringS(LJM_CONSTANTS_FILE, FileName)
To load the Modbus constants and error constants separately, use LJM_WriteLibraryConfigStringS
with LJM_MODBUS_MAP_CONSTANTS_FILE
or LJM_ERROR_CONSTANTS_FILE
as the Parameter
.
Example
Load the constants file "custom_modbus_map.json"
char ErrorString[LJM_MAX_NAME_SIZE];
int LJMError;
LJMError = LJM_LoadConstantsFromFile("custom_modbus_map.json");
if (LJMError != 0) {
LJM_ErrorToString(LJMError, ErrorString);
printf("LJM_LoadConstantsFromFile error: %s\n", ErrorString);
}