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

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

#include <slave.h>

+ Collaboration diagram for modbusSlave:

Data Fields

uint8_t address
 The slave's address. More...
 
ModbusRegisterCallbackFunction registerCallback
 The pointer to the user-defined register callback function. More...
 
void * registerCallbackContext
 The user data pointer passed to the callback function each time it's used. More...
 
uint16_t * registers
 Pointer to registers data. More...
 
uint16_t * inputRegisters
 Pointer to input registers data. More...
 
uint8_t * registerMask
 Mask for register write protection (each bit corresponds to one register) More...
 
uint16_t registerMaskLength
 Write protection mask (registerMask) length in bytes (each byte covers 8 registers) More...
 
uint16_t registerCount
 Slave's register count. More...
 
uint16_t inputRegisterCount
 Slave's input register count. More...
 
uint8_t * coils
 Pointer to coils data. More...
 
uint8_t * discreteInputs
 Pointer to discrete inputs data. More...
 
uint8_t * coilMask
 Masks for coil write protection (each bit corresponds to one coil) More...
 
uint16_t coilMaskLength
 Write protection mask (coilMask) length in bytes (each byte covers 8 coils) More...
 
uint16_t coilCount
 Slave's coil count. More...
 
uint16_t discreteInputCount
 Slave's discrete input count. More...
 
ModbusExceptionCode lastException
 Exception code of the last exception generated by modbusBuildException. More...
 
ModbusFrameError parseError
 More specific error code of problem encountered during frame parsing. More...
 
ModbusSlaveUserFunctionuserFunctions
 A pointer to user defined Modbus functions array. More...
 
uint16_t userFunctionCount
 Number of user-defined Modbus functions /see userFunctions. More...
 
struct {
   uint8_t   frame [LIGHTMODBUS_STATIC_MEM_SLAVE_RESPONSE]
 Statically allocated memory for the response frame. More...
 
   uint8_t *   frame
 A pointer to dynamically allocated memory for the response frame. More...
 
   uint8_t   length
 Frame length in bytes. More...
 
response
 Struct containing slave's response to the master's request. More...
 
struct {
   uint8_t   frame [LIGHTMODBUS_STATIC_MEM_SLAVE_REQUEST]
 Statically allocated memory for the request frame. More...
 
   const uint8_t *   frame
 A pointer to dynamically allocated memory for the request frame. More...
 
   uint8_t   length
 Frame length in bytes. More...
 
request
 Struct containing master's request frame. More...
 

Detailed Description

Represents Modbus slave device's status and configuration.

Field Documentation

◆ address

uint8_t modbusSlave::address

The slave's address.

◆ coilCount

uint16_t modbusSlave::coilCount

Slave's coil count.

◆ coilMask

uint8_t* modbusSlave::coilMask

Masks for coil write protection (each bit corresponds to one coil)

◆ coilMaskLength

uint16_t modbusSlave::coilMaskLength

Write protection mask (coilMask) length in bytes (each byte covers 8 coils)

◆ coils

uint8_t* modbusSlave::coils

Pointer to coils data.

◆ discreteInputCount

uint16_t modbusSlave::discreteInputCount

Slave's discrete input count.

◆ discreteInputs

uint8_t* modbusSlave::discreteInputs

Pointer to discrete inputs data.

◆ frame [1/3]

uint8_t modbusSlave::frame[LIGHTMODBUS_STATIC_MEM_SLAVE_REQUEST]

Statically allocated memory for the response frame.

Statically allocated memory for the request frame.

◆ frame [2/3]

uint8_t* modbusSlave::frame

A pointer to dynamically allocated memory for the response frame.

◆ frame [3/3]

const uint8_t* modbusSlave::frame

A pointer to dynamically allocated memory for the request frame.

◆ inputRegisterCount

uint16_t modbusSlave::inputRegisterCount

Slave's input register count.

◆ inputRegisters

uint16_t* modbusSlave::inputRegisters

Pointer to input registers data.

◆ lastException

ModbusExceptionCode modbusSlave::lastException

Exception code of the last exception generated by modbusBuildException.

See also
modbusBuildException

◆ length

uint8_t modbusSlave::length

Frame length in bytes.

◆ parseError

ModbusFrameError modbusSlave::parseError

More specific error code of problem encountered during frame parsing.

This variable is set up by modbusBuildExceptionErr function

See also
modbusBuildExceptionErr

◆ registerCallback

ModbusRegisterCallbackFunction modbusSlave::registerCallback

The pointer to the user-defined register callback function.

Note
Requires LIGHTMODBUS_COIL_CALLBACK or LIGHTMODBUS_REGISTER_CALLBACK to be defined

◆ registerCallbackContext

void* modbusSlave::registerCallbackContext

The user data pointer passed to the callback function each time it's used.

Warning
This pointer is not managed nor controlled by library. So, what you set is what you get.

◆ registerCount

uint16_t modbusSlave::registerCount

Slave's register count.

◆ registerMask

uint8_t* modbusSlave::registerMask

Mask for register write protection (each bit corresponds to one register)

◆ registerMaskLength

uint16_t modbusSlave::registerMaskLength

Write protection mask (registerMask) length in bytes (each byte covers 8 registers)

◆ registers

uint16_t* modbusSlave::registers

Pointer to registers data.

◆ request

struct { ... } modbusSlave::request

Struct containing master's request frame.

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_SLAVE_REQUEST macro
See also
Disabling dynamic memory allocation

◆ response

struct { ... } modbusSlave::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_SLAVE_RESPONSE macro
See also
Disabling dynamic memory allocation

◆ userFunctionCount

uint16_t modbusSlave::userFunctionCount

Number of user-defined Modbus functions /see userFunctions.

◆ userFunctions

ModbusSlaveUserFunction* modbusSlave::userFunctions

A pointer to user defined Modbus functions array.

Note
Requires SLAVE_USER_FUNCTIONS module (see Building liblightmodbus)
See also
user-functions

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