« Close

Datasheets and User Guides

App Notes

Software & Driver

 

2.3.1 - eWriteNames

Write multiple values, specified by name.

Syntax

LJM_ERROR_RETURN LJM_eWriteNames(
                      int Handle, 
                      int NumFrames, 
                      const char ** aNames,
	              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 aNames array. 
aNames [in]
An array of names that specify the Modbus register(s) to write. Names can be found throughout the device datasheet or in the Modbus Map.
aValues [in]
An array of values to send to the device. The array size should be the same as the aNames array. The input data type of each value is a double, and will be converted into the correct data type automatically.
ErrorAddress [out]
If error, the address responsible for causing an error.

Returns

LJM errorcodes or 0 for no error.

Remarks

This function is commonly used to write a handful of values at once, and is more convenient than LJM_eWriteAddresses because it is not necessary to know the data type. More code examples coming soon.

Examples

[C/C++] Change digital I/O 0, 1, and 2 to output high, and digital I/O 6 to output low.

int LJMError;
int errorAddress;
const char * aNames[4] = {"FIO0", "FIO1", "FIO2", "FIO6"};
double aValues[4] = {1, 1, 1, 0};

// handle comes from LJM_Open()
LJMError = LJM_eWriteNames(handle, 4, aNames, aValues, &errorAddress);
if (LJMError != LJME_NOERROR) {
    // Deal with error
}

2 comments

I think your example code is missing a quotation mark near FI06.

Thanks, should be fixed now.