eReadAddress [LJM User's Guide]
Read one value, specified by address.
Syntax
LJM_ERROR_RETURN LJM_eReadAddress(
int Handle,
int Address,
int Type,
double * Value)
Parameters
Handle [in]
A device handle. The handle is a connection ID for an active device. Generate a handle with LJM_Open or LJM_OpenS.
Address [in]
The address that specifies the Modbus register(s) to write. Addresses can be found throughout the device datasheet or in the Modbus Map.
Type [in]
The data type of the value:
Type | Integer Value |
---|---|
LJM_UINT16 | 0 |
LJM_UINT32 | 1 |
LJM_INT32 | 2 |
LJM_FLOAT32 | 3 |
Value [out]
The value returned from the device. The output data type is a double, and will be converted according to the Type
input.
Returns
LJM errorcodes or 0
for no error.
Remarks
For an alternate function using a name rather than address, see LJM_eReadName. More code examples coming soon.
Example
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);