28 #ifndef LIGHTMODBUS_MASTER_H 29 #define LIGHTMODBUS_MASTER_H 41 #ifdef LIGHTMODBUS_MASTER_BASE 43 #if defined( LIGHTMODBUS_MASTER_INVASIVE_PARSING ) && !defined( LIGHTMODBUS_NO_MASTER_DATA_BUFFER ) 44 #warning LIGHTMODBUS_MASTER_INVASIVE_PARSING has no effect if LIGHTMODBUS_NO_MASTER_DATA_BUFFER is not defined 47 #if defined( LIGHTMODBUS_NO_MASTER_DATA_BUFFER ) && !defined( LIGHTMODBUS_EXPERIMENTAL ) 48 #error Disabling exclusive master data buffer is an experimental feature that may cause problems. Please define LIGHTMODBUS_EXPERIMENTAL to dismiss this error message, but please make sure your system permits unaligned memory acces beforehand. 51 #if defined( LIGHTMODBUS_NO_MASTER_DATA_BUFFER ) && defined( LIGHTMODBUS_STATIC_MEM_MASTER_DATA ) 52 #error LIGHTMODBUS_STATIC_MEM_MASTER_DATA and LIGHTMODBUS_NO_MASTER_DATA_BUFFER cannot be used at once. Please make up your mind. 55 #ifdef LIGHTMODBUS_MASTER_USER_FUNCTIONS 87 #ifdef LIGHTMODBUS_STATIC_MEM_MASTER_REQUEST 88 uint8_t frame[LIGHTMODBUS_STATIC_MEM_MASTER_REQUEST];
110 #ifdef LIGHTMODBUS_STATIC_MEM_MASTER_RESPONSE 111 uint8_t frame[LIGHTMODBUS_STATIC_MEM_MASTER_RESPONSE];
114 const uint8_t *frame;
137 #ifdef LIGHTMODBUS_STATIC_MEM_MASTER_DATA 147 uint8_t coils[LIGHTMODBUS_STATIC_MEM_MASTER_DATA];
155 uint16_t regs[LIGHTMODBUS_STATIC_MEM_MASTER_DATA >> 1];
197 #ifdef LIGHTMODBUS_MASTER_USER_FUNCTIONS 212 #ifdef LIGHTMODBUS_MASTER_BASE Associates user-defined response parser function with the function ID.
Definition: master.h:61
Master's coil-related frame building functions.
ModbusMasterUserFunction * userFunctions
A pointer to an array of user-defined Modbus functions.
Definition: master.h:202
ModbusError modbusMasterInit(ModbusMaster *status)
Performs initialization of the ModbusMaster structure.
Definition: master.c:216
uint8_t length
Length of the request frame in bytes.
Definition: master.h:96
uint16_t count
Number of data units (coils, registers, etc.)
Definition: master.h:132
uint8_t predictedResponseLength
Predicted number of response bytes to be received from slave upon succesful request.
Definition: master.h:74
uint16_t index
Modbus address of the first register/coil.
Definition: master.h:131
struct modbusMaster ModbusMaster
Represents Modbus master device's status and configuration.
A big union of structures used for parsing standard Modbus requests and building responses.
Definition: parser.h:43
Contains the modbusParser union used during frame creation and parsing.
enum modbusExceptionCode ModbusExceptionCode
Represents a Modbus exception code, defined by the standart.
enum modbusFrameError ModbusFrameError
Provides more information on frame building/parsing error.
uint16_t userFunctionCount
Number of the user functions in the array.
Definition: master.h:203
ModbusFrameError buildError
More precise information according encountered frame building error.
Definition: master.h:194
uint8_t * coils
A pointer to dynamically allocated memory for the received coils data.
Definition: master.h:166
ModbusDataType type
Type of data.
Definition: master.h:134
ModbusExceptionCode code
Exception code.
Definition: master.h:187
Master's register-related frame building functions.
ModbusFrameError parseError
More precise information according encountered frame parsing error.
Definition: master.h:191
ModbusError(* handler)(struct modbusMaster *status, ModbusParser *parser, ModbusParser *requestParser)
Pointer to the user defined parsing function.
Definition: master.h:64
uint8_t address
Addres of slave that sent in the data.
Definition: master.h:130
struct modbusMasterUserFunction ModbusMasterUserFunction
Associates user-defined response parser function with the function ID.
ModbusError modbusParseResponse(ModbusMaster *status)
Interprets the incoming response frame located in the master structure.
Definition: master.c:47
Represents Modbus master device's status and configuration.
Definition: master.h:71
uint16_t * regs
A pointer to dynamically allocated memory for the received registers data.
Definition: master.h:173
ModbusError modbusMasterEnd(ModbusMaster *status)
Frees memory used by the ModbusMaster structure, previously initialized with modbusMasterInit.
Definition: master.c:258
enum modbusDataType ModbusDataType
Stores information about Modbus data types.
enum modbusError ModbusError
Represents a library runtime error code.