« Close

Datasheets and User Guides

App Notes

Software & Driver

 

2.2.4 - eReadAddress

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 read. Addresses can be found throughout the device datasheet or in the Modbus Map.
Type [in]
The data type of the 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
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.

Examples

[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);