eWriteAddresses [LJM User's Guide]
Write multiple device registers in one command, specified by address.
Syntax
LJM_ERROR_RETURN LJM_eWriteAddresses(
int Handle,
int NumFrames,
const int * aAddresses,
const int * aTypes,
const 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 write. 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 [in]
An array of values to send to the device. The array size should be the size of the aAddresses
array. The input data type of each value is a double, and they will be converted into 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 write 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_eWriteNames.
Example
Change digital I/O 0, 1, and 2 to output high, and digital I/O 6 to output low.
int LJMError;
int errorAddress;
int aAddresses[4] = {2000, 2001, 2002, 2006};
int aTypes[4] = {0, 0, 0, 0};
double aValues[4] = {1, 1, 1, 0};
// handle comes from LJM_Open()
LJMError = LJM_eWriteAddresses(handle, 4, aAddresses, aTypes, aValues, &errorAddress);
if (LJMError != LJME_NOERROR) {
// Deal with error
}