Skip to main content
Skip table of contents

LJM Modbus/Errorcode Interpretation Constants

LJM translates between register names and addresses and between errorcodes and error names. To do so, it loads .json data.

For more LJM configurations, see Library Configuration Functions.

LJM_CONSTANTS_FILE

LJM_CONSTANTS_FILE is a string-based write-only LJM library configuration which sets the absolute or relative path of an existing file to read Modbus constants and error constants from. It is a shortcut for writing to both LJM_MODBUS_MAP_CONSTANTS_FILE and LJM_ERROR_CONSTANTS_FILE.

The constant LJM_CONSTANTS_FILE can be used interchangeably with the string "LJM_CONSTANTS_FILE".

Default Value

Windows Vista and later:

C:\ProgramData\LabJack\LJM\ljm_constants.json

Windows XP (deprecated):

C:\Documents and Settings\All Users\Application Data\LabJack\LJM\ljm_constants.json

Mac OS X and Linux:

/usr/local/share/LabJack/LJM/ljm_constants.json

Relevant Constants

LJM_MODBUS_MAP_CONSTANTS_FILE and LJM_ERROR_CONSTANTS_FILE

Relevant Functions

To write LJM_CONSTANTS_FILE, use LJM_WriteLibraryConfigStringS or LJM_LoadConfigurationFile.

Setting LJM_CONSTANTS_FILE may affect the output of the following functions:

Example

Set LJM_CONSTANTS_FILE to "alternate_constants.json"

C
char ErrorString[LJM_MAX_NAME_SIZE];
int LJMError = LJM_WriteLibraryConfigStringS(LJM_CONSTANTS_FILE, "alternate_constants.json");
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_WriteLibraryConfigStringS error: %s\n", ErrorString);
}

LJM_ERROR_CONSTANTS_FILE

LJM_ERROR_CONSTANTS_FILE is a string-based readable-writable LJM library configuration which sets the absolute or relative path of an existing file to use as error constants for use with the function LJM_ErrorToString.

The constant LJM_ERROR_CONSTANTS_FILE can be used interchangeably with the string "LJM_ERROR_CONSTANTS_FILE".

Default Value

  • Windows Vista and later: "C:\ProgramData\LabJack\LJM\ljm_constants.json"

  • Windows XP: "C:\Documents and Settings\All Users\Application Data\LabJack\LJM\ljm_constants.json"

  • Mac OS X and Linux: "/usr/local/share/LabJack/LJM/ljm_constants.json"

Relevant Constants

To set LJM_ERROR_CONSTANTS_FILE and LJM_MODBUS_MAP_CONSTANTS_FILE simultaneously, use LJM_CONSTANTS_FILE.

Relevant Functions

To read, use LJM_ReadLibraryConfigStringS.

To write, use LJM_WriteLibraryConfigStringS or LJM_LoadConfigurationFile.

Example

Read LJM_ERROR_CONSTANTS_FILE, then set it to "alternate_error_constants.json"

C
char ErrorString[LJM_MAX_NAME_SIZE];
char defaultErrorConstantsFile[LJM_MAX_NAME_SIZE];
char * newErrorConstantsFile = "alternate_error_constants.json";

int LJMError = LJM_ReadLibraryConfigStringS(LJM_ERROR_CONSTANTS_FILE, defaultErrorConstantsFile);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_ReadLibraryConfigStringS error: %s\n", ErrorString);
}
printf("The default for LJM_ERROR_CONSTANTS_FILE is %s\n", defaultErrorConstantsFile);

printf("Setting LJM_ERROR_CONSTANTS_FILE to %s\n", newErrorConstantsFile);
LJMError = LJM_WriteLibraryConfigStringS(LJM_ERROR_CONSTANTS_FILE, newErrorConstantsFile);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_WriteLibraryConfigStringS error: %s\n", ErrorString);
}

LJM_MODBUS_MAP_CONSTANTS_FILE

LJM_MODBUS_MAP_CONSTANTS_FILE is a string-based readable-writable LJM library configuration which sets the absolute or relative path of an existing file to use as Modbus constants for use with the functions that use the Modbus map constants, such as LJM_NamesToAddresses.

The constant LJM_MODBUS_MAP_CONSTANTS_FILE can be used interchangeably with the string "LJM_MODBUS_MAP_CONSTANTS_FILE".

Default Value

  • Windows Vista and later: "C:\ProgramData\LabJack\LJM\ljm_constants.json"

  • Windows XP: "C:\Documents and Settings\All Users\Application Data\LabJack\LJM\ljm_constants.json"

  • Mac OS X and Linux: "/usr/local/share/LabJack/LJM/ljm_constants.json"

Relevant Constants

To set LJM_ERROR_CONSTANTS_FILE and LJM_MODBUS_MAP_CONSTANTS_FILE simultaneously, use LJM_CONSTANTS_FILE.

Relevant Functions

To read, use LJM_ReadLibraryConfigStringS.

To write, use LJM_WriteLibraryConfigStringS or LJM_LoadConfigurationFile.

Example

Read LJM_MODBUS_MAP_CONSTANTS_FILE, then set to "alternate_modbus_constants.json"

C
char ErrorString[LJM_MAX_NAME_SIZE];
char defaultModbusConstantsFile[LJM_MAX_NAME_SIZE];
char * newModbusConstantsFile = "alternate_modbus_constants.json";

int LJMError = LJM_ReadLibraryConfigStringS(LJM_MODBUS_MAP_CONSTANTS_FILE, defaultModbusConstantsFile);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_ReadLibraryConfigStringS error: %s\n", ErrorString);
}
printf("The default for LJM_MODBUS_MAP_CONSTANTS_FILE is %s\n", defaultModbusConstantsFile);

printf("Setting LJM_MODBUS_MAP_CONSTANTS_FILE to %s\n", newModbusConstantsFile);
LJMError = LJM_WriteLibraryConfigStringS(LJM_MODBUS_MAP_CONSTANTS_FILE, newModbusConstantsFile);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_WriteLibraryConfigStringS error: %s\n", ErrorString);
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.