« Close

Datasheets and User Guides

App Notes

Software & Driver

 

2.3.11 - eWriteAddressArray

Write consecutive values, specified by an address and type.

Syntax

LJM_ERROR_RETURN LJM_eWriteAddressArray(
                      int Handle,
                      int Address,
                      int Type,
                      int NumValues,
                      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.
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(s):
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
NumValues [in]
The number of consecutive values.
aValues [in]
An array of values to be transferred to the device. The array size should be equal to NumValues. Each value will be converted according to Type.
ErrorAddress [out]
If error, the address responsible for causing an error.

Returns

LJM errorcodes or 0 for no error.

Remarks

The Name version of this function is LJM_eWriteNameArray.

If NumValues is large enough, these functions will automatically split writes into multiple packets based on the current device's effective data packet size. Using both non-buffer and buffer registers in one function call is not supported.

Examples

[C/C++] Write DAC0 and DAC1 as an array

int LJMError;
int errorAddress;
double newValues[2] = {1.2, 3.4};

// handle comes from LJM_Open()
LJMError = LJM_eWriteAddressArray(handle, 1000, LJM_FLOAT32, 2, newValues, &errorAddress);
if (LJMError != LJME_NOERROR) {
    // Deal with error
}