liblightmodbus  2.0
A lightweight, cross-platform Modbus RTU library
Data Fields
modbusMaster Struct Reference

Represents Modbus master device's status and configuration. More...

#include <master.h>

+ Collaboration diagram for modbusMaster:

Data Fields

uint8_t predictedResponseLength
 Predicted number of response bytes to be received from slave upon succesful request. More...
 
struct {
   uint8_t   frame [LIGHTMODBUS_STATIC_MEM_MASTER_REQUEST]
 Statically allocated memory for the request frame. More...
 
   uint8_t *   frame
 A pointer to dynamically allocated memory for the request frame. More...
 
   uint8_t   length
 Length of the request frame in bytes. More...
 
request
 Struct containing master's request for the slave. More...
 
struct {
   uint8_t   frame [LIGHTMODBUS_STATIC_MEM_MASTER_RESPONSE]
 Statically allocated memory for the response frame. More...
 
   const uint8_t *   frame
 A pointer to dynamically allocated memory for the response frame. More...
 
   uint8_t   length
 Length of the response frame in bytes. More...
 
response
 Struct containing slave's response to the master's request. More...
 
struct {
   uint8_t   address
 Addres of slave that sent in the data. More...
 
   uint16_t   index
 Modbus address of the first register/coil. More...
 
   uint16_t   count
 Number of data units (coils, registers, etc.) More...
 
   uint8_t   length
 Length of data in bytes. More...
 
   ModbusDataType   type
 Type of data. More...
 
   uint8_t   function
 Function that accessed the data. More...
 
   union {
      uint8_t   coils [LIGHTMODBUS_STATIC_MEM_MASTER_DATA]
 Statically allocated array for received coils data. More...
 
      uint16_t   regs [LIGHTMODBUS_STATIC_MEM_MASTER_DATA >> 1]
 Statically allocated array for received registers data. More...
 
   } 
 
   uint8_t *   coils
 A pointer to dynamically allocated memory for the received coils data. More...
 
   uint16_t *   regs
 A pointer to dynamically allocated memory for the received registers data. More...
 
data
 Contains data received from the slave. More...
 
struct {
   uint8_t   address
 Slave device address. More...
 
   uint8_t   function
 Function that has thrown the exception. More...
 
   ModbusExceptionCode   code
 Exception code. More...
 
exception
 Contains exception data received from the slave. More...
 
ModbusFrameError parseError
 More precise information according encountered frame parsing error. More...
 
ModbusFrameError buildError
 More precise information according encountered frame building error. More...
 
ModbusMasterUserFunctionuserFunctions
 A pointer to an array of user-defined Modbus functions. More...
 
uint16_t userFunctionCount
 Number of the user functions in the array. More...
 

Detailed Description

Represents Modbus master device's status and configuration.

Field Documentation

◆ address

uint8_t modbusMaster::address

Addres of slave that sent in the data.

Slave device address.

◆ buildError

ModbusFrameError modbusMaster::buildError

More precise information according encountered frame building error.

◆ code

ModbusExceptionCode modbusMaster::code

Exception code.

◆ coils [1/2]

uint8_t modbusMaster::coils[LIGHTMODBUS_STATIC_MEM_MASTER_DATA]

Statically allocated array for received coils data.

Each bit of this array corresponds to one coil value.

See also
modbusMaskRead()

◆ coils [2/2]

uint8_t* modbusMaster::coils

A pointer to dynamically allocated memory for the received coils data.

Each bit of this array corresponds to one coil value.

See also
modbusMaskRead()

◆ count

uint16_t modbusMaster::count

Number of data units (coils, registers, etc.)

◆ data

struct { ... } modbusMaster::data

Contains data received from the slave.

The space for data inside this structure can either be dynamically or statically allocated (see Disabling dynamic memory allocation).

◆ exception

struct { ... } modbusMaster::exception

Contains exception data received from the slave.

Note
Data in this structure is only valid if the processed response frame was an exception frame.

◆ frame [1/3]

uint8_t modbusMaster::frame[LIGHTMODBUS_STATIC_MEM_MASTER_RESPONSE]

Statically allocated memory for the request frame.

Statically allocated memory for the response frame.

◆ frame [2/3]

uint8_t* modbusMaster::frame

A pointer to dynamically allocated memory for the request frame.

◆ frame [3/3]

const uint8_t* modbusMaster::frame

A pointer to dynamically allocated memory for the response frame.

◆ function

uint8_t modbusMaster::function

Function that accessed the data.

Function that has thrown the exception.

◆ index

uint16_t modbusMaster::index

Modbus address of the first register/coil.

◆ length

uint8_t modbusMaster::length

Length of the request frame in bytes.

Length of data in bytes.

Length of the response frame in bytes.

◆ parseError

ModbusFrameError modbusMaster::parseError

More precise information according encountered frame parsing error.

◆ predictedResponseLength

uint8_t modbusMaster::predictedResponseLength

Predicted number of response bytes to be received from slave upon succesful request.

◆ regs [1/2]

uint16_t modbusMaster::regs[LIGHTMODBUS_STATIC_MEM_MASTER_DATA >> 1]

Statically allocated array for received registers data.

Data in this array always has currently used platform's native endianness.

◆ regs [2/2]

uint16_t* modbusMaster::regs

A pointer to dynamically allocated memory for the received registers data.

Data in this array always has currently used platform's native endianness.

◆ request

struct { ... } modbusMaster::request

Struct containing master's request for the slave.

Note
Declaration of the frame member depends on the library configuration. It can be either a statically allocated array or a pointer to dynamically allocated memory. The behavior is dependant on definition of the LIGHTMODBUS_STATIC_MEM_MASTER_REQUEST macro
See also
Disabling dynamic memory allocation

◆ response

struct { ... } modbusMaster::response

Struct containing slave's response to the master's request.

Note
Declaration of the frame member depends on the library configuration. It can be either a statically allocated array or a pointer to dynamically allocated memory. The behavior is dependant on definition of the LIGHTMODBUS_STATIC_MEM_MASTER_RESPONSE macro
See also
Disabling dynamic memory allocation

◆ type

ModbusDataType modbusMaster::type

Type of data.

◆ userFunctionCount

uint16_t modbusMaster::userFunctionCount

Number of the user functions in the array.

◆ userFunctions

ModbusMasterUserFunction* modbusMaster::userFunctions

A pointer to an array of user-defined Modbus functions.

See also
user-functions

The documentation for this struct was generated from the following file: