liblightmodbus 3.0
A lightweight, header-only, hardware-agnostic Modbus RTU/TCP library
Loading...
Searching...
No Matches
lightmodbus.hpp
Go to the documentation of this file.
1#ifndef LIGHTMODBUS_HPP
2#define LIGHTMODBUS_HPP
3#include <stdexcept>
4
5#ifndef LIGHTMODBUS_DEBUG
6#define LIGHTMODBUS_DEBUG // FIXME
7#endif
8
9#include "lightmodbus.h"
10
21namespace llm {
22
23
27class RequestError : public std::exception
28{
29public:
30 explicit RequestError(ModbusError err) :
31 m_error(err)
32 {
33 }
34
35 const char *what() const noexcept override
36 {
37 return modbusErrorStr(m_error);
38 }
39
40private:
41 ModbusError m_error;
42};
43
47class ResponseError : public std::exception
48{
49public:
50 explicit ResponseError(ModbusError err) :
51 m_error(err)
52 {
53 }
54
55 const char *what() const noexcept override
56 {
57 return modbusErrorStr(m_error);
58 }
59
60private:
61 ModbusError m_error;
62};
63
67class GeneralError : public std::exception
68{
69public:
70 explicit GeneralError(ModbusError err) :
71 m_error(err)
72 {
73 }
74
75 const char *what() const noexcept override
76 {
77 return modbusErrorStr(m_error);
78 }
79
80private:
81 ModbusError m_error;
82};
83
91static inline void throwErrorInfo(ModbusErrorInfo err)
92{
95 else if (modbusGetRequestError(err) != MODBUS_OK)
97 else if (modbusGetResponseError(err) != MODBUS_OK)
99}
100
101#ifdef LIGHTMODBUS_SLAVE
102
106class Slave
107{
108public:
110 ModbusRegisterCallback registerCallback,
111 ModbusSlaveExceptionCallback exceptionCallback = nullptr,
114 uint16_t functionCount = modbusSlaveDefaultFunctionCount)
115 {
117 &m_slave,
118 registerCallback,
119 exceptionCallback,
120 allocator,
121 functions,
122 functionCount));
123 }
124
126 {
128 }
129
130 // Disable copy (and move for now)
131 Slave(const Slave &) = delete;
132 Slave(Slave &&) = delete;
133 Slave &operator=(const Slave &) = delete;
134 Slave &operator=(Slave &&) = delete;
135
136 void parseRequestPDU(const uint8_t *frame, uint16_t length)
137 {
138 ModbusErrorInfo err = modbusParseRequestPDU(&m_slave, frame, length);
139 m_ok = modbusIsOk(err);
140 throwErrorInfo(err);
141 }
142
143 void parseRequestRTU(uint8_t address, const uint8_t *frame, uint16_t length)
144 {
145 ModbusErrorInfo err = modbusParseRequestRTU(&m_slave, address, frame, length);
146 m_ok = modbusIsOk(err);
147 throwErrorInfo(err);
148 }
149
150 void parseRequestTCP(const uint8_t *frame, uint16_t length)
151 {
152 ModbusErrorInfo err = modbusParseRequestTCP(&m_slave, frame, length);
153 m_ok = modbusIsOk(err);
154 throwErrorInfo(err);
155 }
156
157 void buildExceptionPDU(uint8_t function, ModbusExceptionCode code)
158 {
159 ModbusErrorInfo err = modbusBuildExceptionPDU(&m_slave, function, code);
160 m_ok = modbusIsOk(err);
161 throwErrorInfo(err);
162 }
163
164 void buildExceptionRTU(uint8_t address, uint8_t function, ModbusExceptionCode code)
165 {
166 ModbusErrorInfo err = modbusBuildExceptionRTU(&m_slave, address, function, code);
167 m_ok = modbusIsOk(err);
168 throwErrorInfo(err);
169 }
170
171 void buildExceptionTCP(uint16_t transactionID, uint8_t unitID, uint8_t function, ModbusExceptionCode code)
172 {
173 ModbusErrorInfo err = modbusBuildExceptionTCP(&m_slave, transactionID, unitID, function, code);
174 m_ok = modbusIsOk(err);
175 throwErrorInfo(err);
176 }
177
178 const uint8_t *getResponse() const
179 {
182 }
183
184 uint16_t getResponseLength() const
185 {
188 }
189
191 {
193 m_ok = false;
194 }
195
196 void setUserPointer(void *ptr)
197 {
199 }
200
201 void *getUserPointer() const
202 {
204 }
205
206protected:
208 bool m_ok = false;
209};
210#endif
211
212#ifdef LIGHTMODBUS_MASTER
213
214#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(f_suffix, ...) \
215 void buildRequest##f_suffix##PDU(__VA_ARGS__)
216
217#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY(f_suffix, ...) \
218 { \
219 ModbusErrorInfo err = modbusBuildRequest##f_suffix##PDU(&m_master, __VA_ARGS__); \
220 m_ok = modbusIsOk(err); \
221 throwErrorInfo(err); \
222 }
223
224#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(f_suffix, ...) \
225 void buildRequest##f_suffix##RTU(uint8_t address, __VA_ARGS__)
226
227#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY(f_suffix, ...) \
228 { \
229 ModbusErrorInfo err = modbusBuildRequest##f_suffix##RTU(&m_master, address, __VA_ARGS__); \
230 m_ok = modbusIsOk(err); \
231 throwErrorInfo(err); \
232 }
233
234#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(f_suffix, ...) \
235 void buildRequest##f_suffix##TCP(uint16_t transactionID, uint8_t unitID, __VA_ARGS__)
236
237#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY(f_suffix, ...) \
238 { \
239 ModbusErrorInfo err = modbusBuildRequest##f_suffix##TCP(&m_master, transactionID, unitID, __VA_ARGS__); \
240 m_ok = modbusIsOk(err); \
241 throwErrorInfo(err); \
242 }
243
244
249{
250public:
252 ModbusDataCallback dataCallback,
253 ModbusMasterExceptionCallback exceptionCallback = nullptr,
256 uint16_t functionCount = modbusMasterDefaultFunctionCount)
257 {
259 &m_master,
260 dataCallback,
261 exceptionCallback,
262 allocator,
263 functions,
264 functionCount));
265 }
266
271
272 // Disable copy (and move for now)
273 Master(const Master &) = delete;
274 Master(Master &&) = delete;
275 Master &operator=(const Master &) = delete;
276 Master &operator=(Master &&) = delete;
277
279 uint8_t address,
280 const uint8_t *request,
281 uint8_t requestLength,
282 const uint8_t *response,
283 uint8_t responseLength)
284 {
286 &m_master,
287 address,
288 request,
289 requestLength,
290 response,
291 responseLength);
292 m_ok = modbusIsOk(err);
293 throwErrorInfo(err);
294 }
295
297 const uint8_t *request,
298 uint8_t requestLength,
299 const uint8_t *response,
300 uint8_t responseLength)
301 {
303 &m_master,
304 request,
305 requestLength,
306 response,
307 responseLength);
308 m_ok = modbusIsOk(err);
309 throwErrorInfo(err);
310 }
311
313 const uint8_t *request,
314 uint8_t requestLength,
315 const uint8_t *response,
316 uint8_t responseLength)
317 {
319 &m_master,
320 request,
321 requestLength,
322 response,
323 responseLength);
324 m_ok = modbusIsOk(err);
325 throwErrorInfo(err);
326 }
327
328 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(01, uint16_t index, uint16_t count)
330 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(02, uint16_t index, uint16_t count)
332 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(03, uint16_t index, uint16_t count)
334 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(04, uint16_t index, uint16_t count)
336 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(05, uint16_t index, uint16_t count)
338 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(06, uint16_t index, uint16_t count)
340 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(15, uint16_t index, uint16_t count, const uint8_t *values)
341 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY(15, index, count, values)
342 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(16, uint16_t index, uint16_t count, const uint16_t *values)
343 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY(16, index, count, values)
344 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(22, uint16_t index, uint16_t andmask, uint16_t ormask)
345 LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY(22, index, andmask, ormask)
346
347 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(01, uint16_t index, uint16_t count)
349 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(02, uint16_t index, uint16_t count)
351 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(03, uint16_t index, uint16_t count)
353 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(04, uint16_t index, uint16_t count)
355 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(05, uint16_t index, uint16_t count)
357 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(06, uint16_t index, uint16_t count)
359 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(15, uint16_t index, uint16_t count, const uint8_t *values)
360 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY(15, index, count, values)
361 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(16, uint16_t index, uint16_t count, const uint16_t *values)
362 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY(16, index, count, values)
363 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(22, uint16_t index, uint16_t andmask, uint16_t ormask)
364 LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY(22, index, andmask, ormask)
365
366 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(01, uint16_t index, uint16_t count)
368 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(02, uint16_t index, uint16_t count)
370 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(03, uint16_t index, uint16_t count)
372 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(04, uint16_t index, uint16_t count)
374 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(05, uint16_t index, uint16_t count)
376 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(06, uint16_t index, uint16_t count)
378 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(15, uint16_t index, uint16_t count, const uint8_t *values)
379 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY(15, index, count, values)
380 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(16, uint16_t index, uint16_t count, const uint16_t *values)
381 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY(16, index, count, values)
382 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(22, uint16_t index, uint16_t andmask, uint16_t ormask)
383 LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY(22, index, andmask, ormask)
384
385 const uint8_t *getRequest() const
386 {
389 }
390
391 uint16_t getRequestLength() const
392 {
395 }
396
398 {
400 m_ok = false;
401 }
402
403 void setUserPointer(void *ptr)
404 {
406 }
407
408 void *getUserPointer() const
409 {
411 }
412protected:
414 bool m_ok = false;
415};
416#endif
417
418}
419
420#endif
ModbusExceptionCode
Represents a Modbus exception code.
Definition base.h:230
ModbusError
Represtents different kinds of errors.
Definition base.h:137
@ MODBUS_ERROR_OTHER
Other error.
Definition base.h:223
@ MODBUS_OK
No error.
Definition base.h:143
static ModbusError modbusGetRequestError(ModbusErrorInfo err)
Returns request error from ModbusErrorInfo.
Definition base.h:462
static uint8_t modbusIsOk(ModbusErrorInfo err)
Checks if ModbusErrorInfo contains an error.
Definition base.h:442
static ModbusError modbusGetGeneralError(ModbusErrorInfo err)
Returns general error from ModbusErrorInfo.
Definition base.h:452
ModbusError modbusDefaultAllocator(ModbusBuffer *buffer, uint16_t size, void *context)
The default memory allocator based on realloc()
Definition base.impl.h:21
ModbusError(* ModbusAllocator)(struct ModbusBuffer *buffer, uint16_t size, void *context)
Pointer to a memory allocator function.
Definition base.h:259
static ModbusError modbusGetResponseError(ModbusErrorInfo err)
Returns response error from ModbusErrorInfo.
Definition base.h:472
General error exception class.
Definition lightmodbus.hpp:68
const char * what() const noexcept override
Definition lightmodbus.hpp:75
GeneralError(ModbusError err)
Definition lightmodbus.hpp:70
Represents a Modbus master device.
Definition lightmodbus.hpp:249
uint16_t getRequestLength() const
Definition lightmodbus.hpp:391
void parseResponsePDU(uint8_t address, const uint8_t *request, uint8_t requestLength, const uint8_t *response, uint8_t responseLength)
Definition lightmodbus.hpp:278
void setUserPointer(void *ptr)
Definition lightmodbus.hpp:403
Master & operator=(Master &&)=delete
void freeRequest()
Definition lightmodbus.hpp:397
const uint8_t * getRequest() const
Definition lightmodbus.hpp:385
ModbusMaster m_master
Definition lightmodbus.hpp:413
Master(Master &&)=delete
void parseResponseRTU(const uint8_t *request, uint8_t requestLength, const uint8_t *response, uint8_t responseLength)
Definition lightmodbus.hpp:296
void * getUserPointer() const
Definition lightmodbus.hpp:408
Master(ModbusDataCallback dataCallback, ModbusMasterExceptionCallback exceptionCallback=nullptr, ModbusAllocator allocator=modbusDefaultAllocator, ModbusMasterFunctionHandler *functions=modbusMasterDefaultFunctions, uint16_t functionCount=modbusMasterDefaultFunctionCount)
Definition lightmodbus.hpp:251
Master(const Master &)=delete
bool m_ok
Definition lightmodbus.hpp:414
void parseResponseTCP(const uint8_t *request, uint8_t requestLength, const uint8_t *response, uint8_t responseLength)
Definition lightmodbus.hpp:312
~Master()
Definition lightmodbus.hpp:267
Master & operator=(const Master &)=delete
Request error exception class.
Definition lightmodbus.hpp:28
const char * what() const noexcept override
Definition lightmodbus.hpp:35
RequestError(ModbusError err)
Definition lightmodbus.hpp:30
Response error exception class.
Definition lightmodbus.hpp:48
ResponseError(ModbusError err)
Definition lightmodbus.hpp:50
const char * what() const noexcept override
Definition lightmodbus.hpp:55
Represents a Modbus slave device.
Definition lightmodbus.hpp:107
void parseRequestRTU(uint8_t address, const uint8_t *frame, uint16_t length)
Definition lightmodbus.hpp:143
void parseRequestTCP(const uint8_t *frame, uint16_t length)
Definition lightmodbus.hpp:150
void buildExceptionRTU(uint8_t address, uint8_t function, ModbusExceptionCode code)
Definition lightmodbus.hpp:164
Slave & operator=(Slave &&)=delete
bool m_ok
Definition lightmodbus.hpp:208
Slave & operator=(const Slave &)=delete
~Slave()
Definition lightmodbus.hpp:125
const uint8_t * getResponse() const
Definition lightmodbus.hpp:178
Slave(ModbusRegisterCallback registerCallback, ModbusSlaveExceptionCallback exceptionCallback=nullptr, ModbusAllocator allocator=modbusDefaultAllocator, ModbusSlaveFunctionHandler *functions=modbusSlaveDefaultFunctions, uint16_t functionCount=modbusSlaveDefaultFunctionCount)
Definition lightmodbus.hpp:109
Slave(Slave &&)=delete
void buildExceptionTCP(uint16_t transactionID, uint8_t unitID, uint8_t function, ModbusExceptionCode code)
Definition lightmodbus.hpp:171
Slave(const Slave &)=delete
void freeResponse()
Definition lightmodbus.hpp:190
uint16_t getResponseLength() const
Definition lightmodbus.hpp:184
ModbusSlave m_slave
Definition lightmodbus.hpp:207
void buildExceptionPDU(uint8_t function, ModbusExceptionCode code)
Definition lightmodbus.hpp:157
void setUserPointer(void *ptr)
Definition lightmodbus.hpp:196
void * getUserPointer() const
Definition lightmodbus.hpp:201
void parseRequestPDU(const uint8_t *frame, uint16_t length)
Definition lightmodbus.hpp:136
const char * modbusErrorStr(ModbusError err)
Returns a string containing the name of the ModbusError value.
Definition debug.impl.h:26
The main library header file (include this one)
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_HEADER(f_suffix,...)
Definition lightmodbus.hpp:214
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_PDU_BODY(f_suffix,...)
Definition lightmodbus.hpp:217
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_BODY(f_suffix,...)
Definition lightmodbus.hpp:237
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_BODY(f_suffix,...)
Definition lightmodbus.hpp:227
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_RTU_HEADER(f_suffix,...)
Definition lightmodbus.hpp:224
#define LIGHTMODBUS_DEFINE_MEMBER_BUILD_TCP_HEADER(f_suffix,...)
Definition lightmodbus.hpp:234
static void modbusMasterFreeRequest(ModbusMaster *status)
Frees memory allocated for master's request frame.
Definition master.h:172
static void modbusMasterSetUserPointer(ModbusMaster *status, void *ptr)
Allows user to set the custom context pointer.
Definition master.h:144
ModbusErrorInfo modbusParseResponseRTU(ModbusMaster *status, const uint8_t *request, uint16_t requestLength, const uint8_t *response, uint16_t responseLength)
Parses a Modbus RTU slave response.
Definition master.impl.h:260
static uint16_t modbusMasterGetRequestLength(const ModbusMaster *status)
Returns the length of the request generated by the master.
Definition master.h:136
static void * modbusMasterGetUserPointer(const ModbusMaster *status)
Retreieves the custom context pointer.
Definition master.h:152
ModbusErrorInfo modbusParseResponseTCP(ModbusMaster *status, const uint8_t *request, uint16_t requestLength, const uint8_t *response, uint16_t responseLength)
Parses a Modbus TCP slave response.
Definition master.impl.h:329
void modbusMasterDestroy(ModbusMaster *status)
Deinitializes a ModbusMaster struct.
Definition master.impl.h:102
static const uint8_t * modbusMasterGetRequest(const ModbusMaster *status)
Returns a pointer to the request generated by the master.
Definition master.h:128
ModbusError(* ModbusDataCallback)(const ModbusMaster *status, const ModbusDataCallbackArgs *args)
A pointer to a callback used for handling data incoming to master.
Definition master.h:52
ModbusMasterFunctionHandler modbusMasterDefaultFunctions[]
Default array of supported functions. Length is stored in modbusMasterDefaultFunctionCount.
Definition master.impl.h:18
const uint8_t modbusMasterDefaultFunctionCount
Stores length of modbusMasterDefaultFunctions array.
Definition master.impl.h:63
ModbusErrorInfo modbusParseResponsePDU(ModbusMaster *status, uint8_t address, const uint8_t *request, uint8_t requestLength, const uint8_t *response, uint8_t responseLength)
Parses a PDU section of a slave response.
Definition master.impl.h:198
ModbusErrorInfo modbusMasterInit(ModbusMaster *status, ModbusDataCallback dataCallback, ModbusMasterExceptionCallback exceptionCallback, ModbusAllocator allocator, const ModbusMasterFunctionHandler *functions, uint8_t functionCount)
Initializes a ModbusMaster struct.
Definition master.impl.h:79
ModbusError(* ModbusMasterExceptionCallback)(const ModbusMaster *status, uint8_t address, uint8_t function, ModbusExceptionCode code)
A pointer to a callback called when a Modbus exception is generated (for master)
Definition master.h:60
The liblightmodbus C++ namepsace.
Definition lightmodbus.hpp:21
static void throwErrorInfo(ModbusErrorInfo err)
Throws an exception based on ModbusErrorInfo.
Definition lightmodbus.hpp:91
ModbusSlaveFunctionHandler modbusSlaveDefaultFunctions[]
Associates function IDs with pointers to functions responsible for parsing. Length of this array is s...
Definition slave.impl.h:18
static void modbusSlaveSetUserPointer(ModbusSlave *status, void *ptr)
Allows user to set the custom context pointer.
Definition slave.h:166
ModbusErrorInfo modbusBuildExceptionRTU(ModbusSlave *status, uint8_t address, uint8_t function, ModbusExceptionCode code)
Builds a Modbus RTU exception.
Definition slave.impl.h:168
const uint8_t modbusSlaveDefaultFunctionCount
Stores length of modbusSlaveDefaultFunctions.
Definition slave.impl.h:63
ModbusErrorInfo modbusSlaveInit(ModbusSlave *status, ModbusRegisterCallback registerCallback, ModbusSlaveExceptionCallback exceptionCallback, ModbusAllocator allocator, const ModbusSlaveFunctionHandler *functions, uint8_t functionCount)
Initializes slave device.
Definition slave.impl.h:79
ModbusErrorInfo modbusBuildExceptionPDU(ModbusSlave *status, uint8_t function, ModbusExceptionCode code)
Builds an exception PDU.
Definition slave.impl.h:143
ModbusErrorInfo modbusParseRequestTCP(ModbusSlave *status, const uint8_t *request, uint16_t requestLength)
Parses provided Modbus TCP request frame and generates a Modbus TCP response.
Definition slave.impl.h:362
static void * modbusSlaveGetUserPointer(const ModbusSlave *status)
Retreieves the custom context pointer.
Definition slave.h:174
ModbusErrorInfo modbusParseRequestRTU(ModbusSlave *status, uint8_t slaveAddress, const uint8_t *request, uint16_t requestLength)
Parses provided Modbus RTU request frame and generates a Modbus RTU response.
Definition slave.impl.h:299
void modbusSlaveDestroy(ModbusSlave *status)
Frees memory allocated in the ModbusSlave struct.
Definition slave.impl.h:99
ModbusErrorInfo modbusBuildExceptionTCP(ModbusSlave *status, uint16_t transactionID, uint8_t unitID, uint8_t function, ModbusExceptionCode code)
Builds a Modbus TCP exception.
Definition slave.impl.h:207
static void modbusSlaveFreeResponse(ModbusSlave *status)
Frees memory allocated for slave's response frame.
Definition slave.h:192
static uint16_t modbusSlaveGetResponseLength(const ModbusSlave *status)
Returns the length of the response generated by the slave.
Definition slave.h:158
ModbusErrorInfo modbusParseRequestPDU(ModbusSlave *status, const uint8_t *request, uint8_t requestLength)
Parses provided PDU and generates PDU for the response frame.
Definition slave.impl.h:275
ModbusError(* ModbusRegisterCallback)(const ModbusSlave *status, const ModbusRegisterCallbackArgs *args, ModbusRegisterCallbackResult *out)
A pointer to callback for performing all register operations.
Definition slave.h:69
ModbusError(* ModbusSlaveExceptionCallback)(const ModbusSlave *status, uint8_t function, ModbusExceptionCode code)
A pointer to a callback called when a Modbus exception is generated (for slave)
Definition slave.h:78
static const uint8_t * modbusSlaveGetResponse(const ModbusSlave *status)
Returns a pointer to the response generated by the slave.
Definition slave.h:147
Richer error represenation - source and type of error.
Definition base.h:126
Associates Modbus function ID with a pointer to a response parsing function.
Definition master.h:31
Master device status.
Definition master.h:73
Associates Modbus function ID with a pointer to a parsing function.
Definition slave.h:28
Slave device status.
Definition slave.h:90