Skip to main content
Skip table of contents

eReadAddressByteArray [LJM User's Guide]

Read a device register that returns consecutive byte values, the register specified by an address.


LJM_ERROR_RETURN LJM_eReadAddressByteArray(
int Handle,
int Address,
int NumBytes,
char * aBytes,
int * ErrorAddress)


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 read.  Addresses can be found throughout the device datasheet or in the Modbus Map.

NumBytes [in]

The number of consecutive bytes.

aBytes [out]

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

ErrorAddress [out]

If error, the address responsible for causing an error.


LJM errorcodes or 0 for no error.


The Name version of this function is LJM_eReadNameByteArray.

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

If NumBytes is large enough, these functions will automatically split reads 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.


Read Lua output from LUA_DEBUG_DATA

int byteIter, err;
double numBytes;
char * aBytes;
int errorAddress;
numBytes = 0;

// handle comes from LJM_Open()
err = LJM_eReadName(handle, "LUA_DEBUG_NUM_BYTES", &numBytes);
if (err != LJME_NOERROR) {
    // Deal with error
aBytes = malloc(sizeof(char) * (int)numBytes);
errorAddress = -2; // Something impossible for a Modbus address
err = LJM_eReadAddressByteArray(
    6024, // LUA_DEBUG_DATA
if (err == LJME_NOERROR) {
    printf("LUA_DEBUG_DATA: ");
    for (byteIter = 0; byteIter < numBytes; byteIter++) {
        printf("%c", aBytes[byteIter]);
if (err != 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.