To access device data one value at a time, use the following functions. See the Modbus map to see what values can be accessed.
Name functions access data by a name, such as "AIN5" for analog input 5.
Address functions access data by an address and data type. For example, analog input 5 ("AIN5") would have address 10 and a 32-bit floating point type.
Need to read or write multiple values at once? Use the Multiple Value Functions.
Write one value, specified by name.
LJM_ERROR_RETURN LJM_eWriteName(
int Handle,
const char * Name,
double Value)
LJM errorcodes or 0 for no error.
For an alternate function using an address rather than name, see LJM_eWriteAddress. More code examples coming soon.
[C/C++] Write a value of 2.5V to the DAC0 analog output
int LJMError; // handle comes from LJM_Open() LJMError = LJM_eWriteName(handle, "DAC0", 2.5); if (LJMError != LJME_NOERROR) { // Deal with error }
Read one value, specified by name.
LJM_ERROR_RETURN LJM_eReadName(
int Handle,
const char * Name,
double * Value)
LJM errorcodes or 0 for no error.
For an alternate function using an address rather than name, see LJM_eReadAddress. More code examples coming soon.
[C/C++] Read the serial number of the device.
int LJMError; double newValue; // handle comes from LJM_Open() LJMError = LJM_eReadName(handle, "SERIAL_NUMBER", &newValue); if (LJMError != LJME_NOERROR) { // Deal with error } printf("SERIAL_NUMBER: %f\n", newValue);
Write one value, specified by address.
LJM_ERROR_RETURN LJM_eWriteAddress(
int Handle,
int Address,
int Type,
double Value)
Type | LJM Constant Name | LJM Constant Value |
unsigned 16-bit integer | LJM_UINT16 | 0 |
unsigned 32-bit integer | LJM_UINT32 | 1 |
signed 32-bit integer | LJM_INT32 | 2 |
floating point 32-bit | LJM_FLOAT32 | 3 |
LJM errorcodes or 0 for no error.
For an alternate function using a name rather than address, see LJM_eWriteName.
[C/C++] Write a value of 2.5V to the DAC0 analog output.
int LJMError; // handle comes from LJM_Open() LJMError = LJM_eWriteAddress(handle, 1000, 3, 2.5); if (LJMError != LJME_NOERROR) { // Deal with error }
Read one value, specified by address.
LJM_ERROR_RETURN LJM_eReadAddress(
int Handle,
int Address,
int Type,
double * Value)
Type | LJM Constant Name | LJM Constant Value |
unsigned 16-bit integer | LJM_UINT16 | 0 |
unsigned 32-bit integer | LJM_UINT32 | 1 |
signed 32-bit integer | LJM_INT32 | 2 |
floating point 32-bit | LJM_FLOAT32 | 3 |
LJM errorcodes or 0 for no error.
For an alternate function using a name rather than address, see LJM_eReadName. More code examples coming soon.
[C/C++] Read the serial number of the device.
int LJMError; double newValue; // handle comes from LJM_Open() LJMError = LJM_eReadAddress(handle, 60028, 1, &newValue); if (LJMError != LJME_NOERROR) { // Deal with error } printf("SERIAL_NUMBER: %f\n", newValue);
Writes a string, specified by name.
LJM_ERROR_RETURN LJM_eWriteNameString(
int Handle,
const char * Name,
const char * String)
LJM errorcodes or 0 for no error.
See also LJM_eReadNameString. This is a convenience function that uses LJM_eNames. Only for use with Modbus register(s) listed as type LJM_STRING (98). More code examples coming soon.
[C/C++] Change the device name.
int LJMError; // LJM_STRING_ALLOCATION_SIZE is 50 char newName[LJM_STRING_ALLOCATION_SIZE] = "My Favorite DAQ Device"; // handle comes from LJM_Open() LJMError = LJM_eWriteNameString(handle, "DEVICE_NAME_DEFAULT", newName); if (LJMError != LJME_NOERROR) { // Deal with error }
Reads a string, specified by name.
LJM_ERROR_RETURN LJM_eReadNameString(
int Handle,
const char * Name,
char * String)
LJM errorcodes or 0 for no error.
See also LJM_eWriteNameString. This is a convenience function that uses LJM_eNames. Only for use with Modbus register(s) listed as type LJM_STRING (98).
[C/C++] Read the device name.
int LJMError; // LJM_STRING_ALLOCATION_SIZE is 50 char devName[LJM_STRING_ALLOCATION_SIZE]; // handle comes from LJM_Open() LJMError = LJM_eReadNameString(handle, "DEVICE_NAME_DEFAULT", devName); if (LJMError != LJME_NOERROR) { // Deal with error } printf ("%s \n", devName);
Writes a string, specified by address.
LJM_ERROR_RETURN LJM_eWriteAddressString(
int Handle,
int Address,
const char * String)
LJM errorcodes or 0 for no error.
See also LJM_eReadAddressString. This is a convenience function that uses LJM_eAddresses. Only for use with Modbus registers listed as type LJM_STRING (98). More code examples coming soon.
[C/C++] Change the device name.
int LJMError; // LJM_STRING_ALLOCATION_SIZE is 50 char newName[LJM_STRING_ALLOCATION_SIZE] = "My Favorite DAQ Device"; // handle comes from LJM_Open() LJMError = LJM_eWriteAddressString(handle, 60500, newName); if (LJMError != LJME_NOERROR) { // Deal with error }
Reads a string, specified by address.
LJM_ERROR_RETURN LJM_eReadAddressString(
int Handle,
int Address,
char * String)
Handle [in]A device handle. The handle is a connection ID for an active device. Generate a handle with LJM_Open or LJM_OpenS.
LJM errorcodes or 0 for no error.
See also LJM_eWriteAddressString. This is a convenience function that uses LJM_eAddresses. Only for use with Modbus registers listed as type LJM_STRING (98).
[C/C++] Read the device name.
int LJMError; // LJM_STRING_ALLOCATION_SIZE is 50 char devName[LJM_STRING_ALLOCATION_SIZE]; // handle comes from LJM_Open() LJMError = LJM_eReadAddressString(handle, 60500, devName); if (LJMError != LJME_NOERROR) { // Deal with error } printf ("%s \n", devName);