Skip to main content
Skip table of contents

eReadAddresses [LJM User's Guide]

Read multiple device registers in one command, each register specified by address.

Syntax

LJM_ERROR_RETURN LJM_eReadAddresses(
int Handle,
int NumFrames,
const int * aAddresses,
const int * aTypes,
double * aValues,
int * ErrorAddress)

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.

NumFrames [in]

The total number of frames to access. A frame consists of one value, so the number of frames is the size of the aAddresses array.

aAddresses [in]

An array of addresses that specify the Modbus register(s) to read. Addresses can be found throughout the device datasheet or in the Modbus Map.

aTypes [in]

An array containing the data type of each value:

Type

Integer Value

LJM_UINT16

0

LJM_UINT32

1

LJM_INT32

2

LJM_FLOAT32

3

aValues [out]

An array of values received from the device. The array size should be the size of the aAddresses array.  The output data type of each value is a double, and they will be converted from the data type entered in aTypes.

ErrorAddress [out]

If error, the address responsible for causing an error.

Returns

LJM errorcodes or 0 for no error.

Remarks

This function is used to read a handful of values at once, and is useful in programming languages that are not friendly towards the usage of strings.  For programming languages that can use strings easily, see LJM_eReadNames.

Example

Reading analog inputs 5, 6, and 10.

C
int LJMError;
int errorAddress;
int aAddresses[3] = {10, 12, 20};
int aTypes[3] = {3, 3, 3};
double ainValues[3];
double ain5;
double ain6;
double ain10;

// handle comes from LJM_Open()
LJMError = LJM_eReadAddresses(handle, 3, aAddresses, aTypes, ainValues, &errorAddress);
if (LJMError != LJME_NOERROR) {
    // Deal with error
}
ain5 = ainValues[0];
ain6 = ainValues[1];
ain10 = ainValues[2];
JavaScript errors detected

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

If this problem persists, please contact our support.