Skip to main content
Skip table of contents

eWriteAddressByteArray [LJM User's Guide]

Write a device register that expects an array consecutive byte values, the register specified by an address.

Syntax

LJM_ERROR_RETURN LJM_eWriteAddressByteArray(
int Handle,
int Address,
int NumBytes,
const char * aBytes,
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.  Address can be found throughout the device datasheet or in the Modbus Map.

NumBytes [in]

The number of consecutive bytes.

aBytes [in]

An array of bytes to be transferred to the device. The array size should be equal to NumBytes.

ErrorAddress [out]

If error, the address responsible for causing an error.

Returns

LJM errorcodes or 0 for no error.

This function will append a 0x00 byte to aBytes for odd-numbered NumBytes.

If NumBytes 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.

Remarks

The Name version of this function is LJM_eWriteNameByteArray.

Example

Write a Lua script to LUA_SOURCE_WRITE

C
int LJMError;
int ErrorAddress;
const char * luaScript =
    "LJ.IntervalConfig(0, 1000)\n"
    "while true do\n"
    "  if LJ.CheckInterval(0) then\n"
    "    print(LJ.Tick())\n"
    "  end\n"
    "end\n"
    "\0";
const unsigned scriptLength = strlen(luaScript) + 1;

// handle comes from LJM_Open()
LJMError = LJM_eWriteAddressByteArray(
    handle,
    LUA_SOURCE_WRITE_ADDRESS,
    scriptLength,
    luaScript,
    &ErrorAddress
);
if (LJMError != LJME_NOERROR) {
    // Deal 

with error }

JavaScript errors detected

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

If this problem persists, please contact our support.