DLN_I2C_MASTER_READ Command and Response

The DLN_I2C_MASTER_READ command is used to read data from I2C slave device.

DLN_I2C_MASTER_READ Command

Go to response

 typedef struct
 {
    DLN_MSG_HEADER header;
    uint8_t port;
    uint8_t slaveDeviceAddress;
    uint8_t memoryAddressLength;
    uint32_t memoryAddress;
    uint16_t bufferLength;
 } __PACKED_ATTR DLN_I2C_MASTER_READ_CMD;

Parameters:

header

Defines the DLN message header DLN_MSG_HEADER. The header contains several predefined fields and is used to identify and route messages. You must fill the following fields before sending the command:

Field Description
size The size of the message. Must be equal to the size of the DLN_I2C_MASTER_READ_CMD structure.
msgId Identifies the message. For the DLN_I2C_MASTER_READ command it must be set to 0x0307. You can use the DLN_MSG_ID_I2C_MASTER_READ constant.
echoCounter Can be used to link a command to a response. The response will have the same echoCounter value. This field can be any numerical value from 0 to 0xFFFF (65536).
handle A handle to the DLN-series adapter.
port
A number of the I2C master port to be used.
slaveDeviceAddress
A 7-bit number, uniquely assigned to each I2C slave device.
memoryAddressLength
An the internal address length. If set to zero, no internal address is sent.
memoryAddress
An the internal I2C slave device address.
bufferLength
The size of the message buffer (in the range from 1 to 256 bytes).

DLN_I2C_MASTER_READ Response

Go to command

The adapter sends the DLN_I2C_MASTER_READ response after the DLN_I2C_MASTER_READ command execution. The response contains confirmation of data transfer as well as data received from a slave.

 typedef struct
 {
    DLN_MSG_HEADER header;
    DLN_RESULT result;
    uint16_t bufferLength;
    uint8_t buffer[256];
 } __PACKED_ATTR DLN_I2C_MASTER_READ_RSP;

Parameters:

header

Defines the DLN message header DLN_MSG_HEADER. The response header contains the following fields:

Field Description
size The size of the message. It is equal to the size of the DLN_I2C_MASTER_READ_RSP structure.
msgId Contains the message id. For the DLN_I2C_MASTER_READ response it is set to 0x0307. The DLN_MSG_ID_I2C_MASTER_READ constant can be used to check the message ID.
echoCounter Links a command to a response. The echoCounter value is copied from the respective command header.
handle A handle to the DLN-series adapter. You can use the handle field to determine the adapter that have sent the response.
result

Contains the result of the command execution. For DLN_I2C_MASTER_READ command DLN-series adapter can return the following result values:

Return Code Description
DLN_RES_SUCCESS An I2C data reading completed successfully.
bufferLength
The size of the message buffer.
buffer
A 256-element array. Each of the elements is an 8-bit value. The buffer will be filled with the data received from the I2C slave device. The array must contain at least bufferLength elements.