modbus_debug.c
Go to the documentation of this file.
1 /**
2  * @file modbus_debug.c
3  * @brief Data logging functions for debugging purpose (Modbus/TCP)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL MODBUS_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "modbus/modbus_client.h"
37 #include "modbus/modbus_server.h"
38 #include "modbus/modbus_debug.h"
39 #include "debug.h"
40 
41 //Check TCP/IP stack configuration
42 #if (MODBUS_CLIENT_SUPPORT == ENABLED || MODBUS_SERVER_SUPPORT == ENABLED)
43 
44 //Modbus functions codes
46 {
47  "", //0
48  "Read Coils", //1
49  "Read Discrete Inputs", //2
50  "Read Holding Registers", //3
51  "Read Input Registers", //4
52  "Write Single Coil", //5
53  "Write Single Register", //6
54  "Read Exception Status", //7
55  "Diagnostics", //8
56  "", //9
57  "", //10
58  "Get Comm Event Counter", //11
59  "Get Comm Event Log", //12
60  "", //13
61  "", //14
62  "Write Multiple Coils", //15
63  "Write Multiple Registers", //16
64  "Report Slave ID", //17
65  "", //18
66  "", //19
67  "Read File Record", //20
68  "Write File Record", //21
69  "Mask Write Register", //22
70  "Read/Write Multiple Registers", //23
71  "Read FIFO Queue" //24
72 };
73 
74 //Modbus exception codes
76 {
77  "", //0
78  "Illegal Function", //1
79  "Illegal Data Address", //2
80  "Illegal Data Value", //3
81  "Slave Device Failure", //4
82  "Acknowledge", //5
83  "Slave Device Busy", //6
84  "", //7
85  "Memory Parity Error", //8
86  "", //9
87  "Gateway Path Unavailable", //10
88  "Gateway Target Device Failed To Respond" //11
89 };
90 
91 
92 /**
93  * @brief Dump Modbus request PDU for debugging purpose
94  * @param[in] pdu Pointer to the Modbus request PDU
95  * @param[in] length Length of the PDU, in bytes
96  * @return Error code
97  **/
98 
99 error_t modbusDumpRequestPdu(const void *pdu, size_t length)
100 {
101 #if (MODBUS_TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
102  error_t error;
103  uint8_t functionCode;
104  const char_t *label;
105 
106  //Sanity check
107  if(length == 0)
108  return ERROR_INVALID_LENGTH;
109 
110  //Retrieve function code
111  functionCode = *((uint8_t *) pdu);
112 
113  //Retrieve the name associated with the function code
114  if(functionCode < arraysize(modbusFunctionCodeLabel))
115  {
116  label = modbusFunctionCodeLabel[functionCode];
117  }
118  else
119  {
120  label = "";
121  }
122 
123  //Dump function code
124  TRACE_DEBUG(" Function Code = %" PRIu8 " (%s)\r\n", functionCode, label);
125 
126  //Check function code
127  switch(functionCode)
128  {
129  //Read Coils request?
131  //Dump Modbus PDU
133  break;
134 
135  //Format Read Discrete Inputs request?
137  //Dump Modbus PDU
139  break;
140 
141  //Read Holding Registers request?
143  //Dump Modbus PDU
145  break;
146 
147  //Read Input Registers request?
149  //Dump Modbus PDU
151  break;
152 
153  //Write Single Coil request?
155  //Dump Modbus PDU
157  break;
158 
159  //Write Single Register request?
161  //Dump Modbus PDU
163  break;
164 
165  //Write Multiple Coils request?
167  //Dump Modbus PDU
169  break;
170 
171  //Write Multiple Registers request?
173  //Dump Modbus PDU
175  break;
176 
177  //Mask Write Register request?
179  //Dump Modbus PDU
181  break;
182 
183  //Read/Write Multiple Registers request?
185  //Dump Modbus PDU
187  break;
188 
189  //Illegal function code?
190  default:
191  //Report an error
193  break;
194  }
195 
196  //Return error code
197  return error;
198 #else
199  //Not implemented
200  return NO_ERROR;
201 #endif
202 }
203 
204 
205 /**
206  * @brief Dump Modbus response PDU for debugging purpose
207  * @param[in] pdu Pointer to the Modbus response PDU
208  * @param[in] length Length of the PDU, in bytes
209  * @return Error code
210  **/
211 
213 {
214 #if (MODBUS_TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
215  error_t error;
216  uint8_t functionCode;
217  const char_t *label;
218 
219  //Sanity check
220  if(length == 0)
221  return ERROR_INVALID_LENGTH;
222 
223  //Retrieve function code
224  functionCode = *((uint8_t *) pdu);
225 
226  //Exception response?
227  if((functionCode & MODBUS_EXCEPTION_MASK) != 0)
228  {
229  //Dump Modbus PDU
231  }
232  else
233  {
234  //Retrieve the name associated with the function code
235  if(functionCode < arraysize(modbusFunctionCodeLabel))
236  {
237  label = modbusFunctionCodeLabel[functionCode];
238  }
239  else
240  {
241  label = "";
242  }
243 
244  //Dump function code
245  TRACE_DEBUG(" Function Code = %" PRIu8 " (%s)\r\n", functionCode, label);
246 
247  //Check function code
248  switch(functionCode)
249  {
250  //Read Coils response?
252  //Dump Modbus PDU
254  break;
255 
256  //Format Read Discrete Inputs response?
258  //Dump Modbus PDU
260  break;
261 
262  //Read Holding Registers response?
264  //Dump Modbus PDU
266  break;
267 
268  //Read Input Registers response?
270  //Dump Modbus PDU
272  break;
273 
274  //Write Single Coil response?
276  //Dump Modbus PDU
278  break;
279 
280  //Write Single Register response?
282  //Dump Modbus PDU
284  break;
285 
286  //Write Multiple Coils response?
288  //Dump Modbus PDU
290  break;
291 
292  //Write Multiple Registers response?
294  //Dump Modbus PDU
296  break;
297 
298  //Mask Write Register response?
300  //Dump Modbus PDU
302  break;
303 
304  //Read/Write Multiple Registers response?
306  //Dump Modbus PDU
308  break;
309 
310  //Illegal function code?
311  default:
312  //Report an error
314  break;
315  }
316  }
317 
318  //Return error code
319  return error;
320 #else
321  //Not implemented
322  return NO_ERROR;
323 #endif
324 }
325 
326 
327 /**
328  * @brief Dump Read Coils request
329  * @param[in] request Pointer to the request PDU
330  * @param[in] length Length of the request PDU, in bytes
331  * @return Error code
332  **/
333 
335  size_t length)
336 {
337  //Malformed request PDU?
338  if(length < sizeof(ModbusReadCoilsReq))
339  return ERROR_INVALID_LENGTH;
340 
341  //Dump request PDU
342  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(request->startingAddr));
343  TRACE_DEBUG(" Quantity of Coils = %" PRIu16 "\r\n", ntohs(request->quantityOfCoils));
344 
345  //Successful processing
346  return NO_ERROR;
347 }
348 
349 
350 /**
351  * @brief Dump Read Coils response
352  * @param[in] response Pointer to the response PDU
353  * @param[in] length Length of the response PDU, in bytes
354  * @return Error code
355  **/
356 
358  size_t length)
359 {
360  //Malformed response PDU?
361  if(length < sizeof(ModbusReadCoilsResp))
362  return ERROR_INVALID_LENGTH;
363 
364  //Calculate the length of the data field
365  length -= sizeof(ModbusReadCoilsResp);
366 
367  //Dump response PDU
368  TRACE_DEBUG(" Byte Count = %" PRIu16 "\r\n", response->byteCount);
369  TRACE_DEBUG_ARRAY(" Coil Status = ", response->coilStatus, length);
370 
371  //Successful processing
372  return NO_ERROR;
373 }
374 
375 
376 /**
377  * @brief Dump Read Discrete Inputs request
378  * @param[in] request Pointer to the request PDU
379  * @param[in] length Length of the request PDU, in bytes
380  * @return Error code
381  **/
382 
384  size_t length)
385 {
386  //Malformed request PDU?
387  if(length < sizeof(ModbusReadDiscreteInputsReq))
388  return ERROR_INVALID_LENGTH;
389 
390  //Dump request PDU
391  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(request->startingAddr));
392  TRACE_DEBUG(" Quantity of Inputs = %" PRIu16 "\r\n", ntohs(request->quantityOfInputs));
393 
394  //Successful processing
395  return NO_ERROR;
396 }
397 
398 
399 /**
400  * @brief Dump Read Discrete Inputs response
401  * @param[in] response Pointer to the response PDU
402  * @param[in] length Length of the response PDU, in bytes
403  * @return Error code
404  **/
405 
407  size_t length)
408 {
409  //Malformed response PDU?
411  return ERROR_INVALID_LENGTH;
412 
413  //Calculate the length of the data field
415 
416  //Dump response PDU
417  TRACE_DEBUG(" Byte Count = %" PRIu16 "\r\n", response->byteCount);
418  TRACE_DEBUG_ARRAY(" Input Status = ", response->inputStatus, length);
419 
420  //Successful processing
421  return NO_ERROR;
422 }
423 
424 
425 /**
426  * @brief Dump Read Holding Registers request
427  * @param[in] request Pointer to the request PDU
428  * @param[in] length Length of the request PDU, in bytes
429  * @return Error code
430  **/
431 
433  size_t length)
434 {
435  //Malformed request PDU?
436  if(length < sizeof(ModbusReadHoldingRegsReq))
437  return ERROR_INVALID_LENGTH;
438 
439  //Dump request PDU
440  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(request->startingAddr));
441  TRACE_DEBUG(" Quantity of Registers = %" PRIu16 "\r\n", ntohs(request->quantityOfRegs));
442 
443  //Successful processing
444  return NO_ERROR;
445 }
446 
447 
448 /**
449  * @brief Dump Read Holding Registers response
450  * @param[in] response Pointer to the response PDU
451  * @param[in] length Length of the response PDU, in bytes
452  * @return Error code
453  **/
454 
456  size_t length)
457 {
458  //Malformed response PDU?
459  if(length < sizeof(ModbusReadHoldingRegsResp))
460  return ERROR_INVALID_LENGTH;
461 
462  //Calculate the length of the data field
464 
465  //Dump response PDU
466  TRACE_DEBUG(" Byte Count = %" PRIu16 "\r\n", response->byteCount);
467  TRACE_DEBUG_ARRAY(" Register Value = ", (void *) response->regValue, length);
468 
469  //Successful processing
470  return NO_ERROR;
471 }
472 
473 
474 /**
475  * @brief Dump Read Input Registers request
476  * @param[in] request Pointer to the request PDU
477  * @param[in] length Length of the request PDU, in bytes
478  * @return Error code
479  **/
480 
482  size_t length)
483 {
484  //Malformed request PDU?
485  if(length < sizeof(ModbusReadInputRegsReq))
486  return ERROR_INVALID_LENGTH;
487 
488  //Dump request PDU
489  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(request->startingAddr));
490  TRACE_DEBUG(" Quantity of Registers = %" PRIu16 "\r\n", ntohs(request->quantityOfRegs));
491 
492  //Successful processing
493  return NO_ERROR;
494 }
495 
496 
497 /**
498  * @brief Dump Read Input Registers response
499  * @param[in] response Pointer to the response PDU
500  * @param[in] length Length of the response PDU, in bytes
501  * @return Error code
502  **/
503 
505  size_t length)
506 {
507  //Malformed response PDU?
508  if(length < sizeof(ModbusReadInputRegsResp))
509  return ERROR_INVALID_LENGTH;
510 
511  //Calculate the length of the data field
512  length -= sizeof(ModbusReadInputRegsResp);
513 
514  //Dump response PDU
515  TRACE_DEBUG(" Byte Count = %" PRIu16 "\r\n", response->byteCount);
516  TRACE_DEBUG_ARRAY(" Register Value = ", (void *) response->regValue, length);
517 
518  //Successful processing
519  return NO_ERROR;
520 }
521 
522 
523 /**
524  * @brief Dump Write Single Coil request
525  * @param[in] request Pointer to the request PDU
526  * @param[in] length Length of the request PDU, in bytes
527  * @return Error code
528  **/
529 
531  size_t length)
532 {
533  //Malformed request PDU?
534  if(length < sizeof(ModbusWriteSingleCoilReq))
535  return ERROR_INVALID_LENGTH;
536 
537  //Dump request PDU
538  TRACE_DEBUG(" Output Address = %" PRIu16 "\r\n", ntohs(request->outputAddr));
539  TRACE_DEBUG(" Output Value = %" PRIu16 "\r\n", ntohs(request->outputValue));
540 
541  //Successful processing
542  return NO_ERROR;
543 }
544 
545 
546 /**
547  * @brief Dump Write Single Coil response
548  * @param[in] response Pointer to the response PDU
549  * @param[in] length Length of the response PDU, in bytes
550  * @return Error code
551  **/
552 
554  size_t length)
555 {
556  //Malformed response PDU?
557  if(length < sizeof(ModbusWriteSingleCoilResp))
558  return ERROR_INVALID_LENGTH;
559 
560  //Dump response PDU
561  TRACE_DEBUG(" Output Address = %" PRIu16 "\r\n", ntohs(response->outputAddr));
562  TRACE_DEBUG(" Output Value = %" PRIu16 "\r\n", ntohs(response->outputValue));
563 
564  //Successful processing
565  return NO_ERROR;
566 }
567 
568 
569 /**
570  * @brief Dump Write Single Register request
571  * @param[in] request Pointer to the request PDU
572  * @param[in] length Length of the request PDU, in bytes
573  * @return Error code
574  **/
575 
577  size_t length)
578 {
579  //Malformed request PDU?
580  if(length < sizeof(ModbusWriteSingleRegReq))
581  return ERROR_INVALID_LENGTH;
582 
583  //Dump request PDU
584  TRACE_DEBUG(" Register Address = %" PRIu16 "\r\n", ntohs(request->regAddr));
585  TRACE_DEBUG(" Register Value = %" PRIu16 "\r\n", ntohs(request->regValue));
586 
587  //Successful processing
588  return NO_ERROR;
589 }
590 
591 
592 /**
593  * @brief Dump Write Single Register response
594  * @param[in] response Pointer to the response PDU
595  * @param[in] length Length of the response PDU, in bytes
596  * @return Error code
597  **/
598 
600  size_t length)
601 {
602  //Malformed response PDU?
603  if(length < sizeof(ModbusWriteSingleRegResp))
604  return ERROR_INVALID_LENGTH;
605 
606  //Dump response PDU
607  TRACE_DEBUG(" Register Address = %" PRIu16 "\r\n", ntohs(response->regAddr));
608  TRACE_DEBUG(" Register Value = %" PRIu16 "\r\n", ntohs(response->regValue));
609 
610  //Successful processing
611  return NO_ERROR;
612 }
613 
614 
615 /**
616  * @brief Dump Write Multiple Coils request
617  * @param[in] request Pointer to the request PDU
618  * @param[in] length Length of the request PDU, in bytes
619  * @return Error code
620  **/
621 
623  size_t length)
624 {
625  //Malformed request PDU?
626  if(length < sizeof(ModbusWriteMultipleCoilsReq))
627  return ERROR_INVALID_LENGTH;
628 
629  //Calculate the length of the data field
631 
632  //Dump request PDU
633  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(request->startingAddr));
634  TRACE_DEBUG(" Quantity of Outputs = %" PRIu16 "\r\n", ntohs(request->quantityOfOutputs));
635  TRACE_DEBUG(" Byte Count = %" PRIu16 "\r\n", request->byteCount);
636  TRACE_DEBUG_ARRAY(" Output Value = ", request->outputValue, length);
637 
638  //Successful processing
639  return NO_ERROR;
640 }
641 
642 
643 /**
644  * @brief Dump Write Multiple Coils response
645  * @param[in] response Pointer to the response PDU
646  * @param[in] length Length of the response PDU, in bytes
647  * @return Error code
648  **/
649 
651  size_t length)
652 {
653  //Malformed response PDU?
655  return ERROR_INVALID_LENGTH;
656 
657  //Dump response PDU
658  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(response->startingAddr));
659  TRACE_DEBUG(" Quantity of Outputs = %" PRIu16 "\r\n", ntohs(response->quantityOfOutputs));
660 
661  //Successful processing
662  return NO_ERROR;
663 }
664 
665 
666 /**
667  * @brief Dump Write Multiple Registers request
668  * @param[in] request Pointer to the request PDU
669  * @param[in] length Length of the request PDU, in bytes
670  * @return Error code
671  **/
672 
674  size_t length)
675 {
676  //Malformed request PDU?
677  if(length < sizeof(ModbusWriteMultipleRegsReq))
678  return ERROR_INVALID_LENGTH;
679 
680  //Calculate the length of the data field
682 
683  //Dump request PDU
684  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(request->startingAddr));
685  TRACE_DEBUG(" Quantity of Registers = %" PRIu16 "\r\n", ntohs(request->quantityOfRegs));
686  TRACE_DEBUG(" Byte Count = %" PRIu16 "\r\n", request->byteCount);
687  TRACE_DEBUG_ARRAY(" Register Value = ", (void *) request->regValue, length);
688 
689  //Successful processing
690  return NO_ERROR;
691 }
692 
693 
694 /**
695  * @brief Dump Write Multiple Registers response
696  * @param[in] response Pointer to the response PDU
697  * @param[in] length Length of the response PDU, in bytes
698  * @return Error code
699  **/
700 
702  size_t length)
703 {
704  //Malformed response PDU?
705  if(length < sizeof(ModbusWriteMultipleRegsResp))
706  return ERROR_INVALID_LENGTH;
707 
708  //Dump response PDU
709  TRACE_DEBUG(" Starting Address = %" PRIu16 "\r\n", ntohs(response->startingAddr));
710  TRACE_DEBUG(" Quantity of Registers = %" PRIu16 "\r\n", ntohs(response->quantityOfRegs));
711 
712  //Successful processing
713  return NO_ERROR;
714 }
715 
716 
717 /**
718  * @brief Dump Mask Write Register request
719  * @param[in] request Pointer to the request PDU
720  * @param[in] length Length of the request PDU, in bytes
721  * @return Error code
722  **/
723 
725  size_t length)
726 {
727  //Malformed request PDU?
728  if(length < sizeof(ModbusMaskWriteRegReq))
729  return ERROR_INVALID_LENGTH;
730 
731  //Dump request PDU
732  TRACE_DEBUG(" Reference Address = %" PRIu16 "\r\n", ntohs(request->referenceAddr));
733  TRACE_DEBUG(" And Value = %" PRIu16 "\r\n", ntohs(request->andMask));
734  TRACE_DEBUG(" Or Value = %" PRIu16 "\r\n", ntohs(request->orMask));
735 
736  //Successful processing
737  return NO_ERROR;
738 }
739 
740 
741 /**
742  * @brief Dump Mask Write Register response
743  * @param[in] response Pointer to the response PDU
744  * @param[in] length Length of the response PDU, in bytes
745  * @return Error code
746  **/
747 
749  size_t length)
750 {
751  //Malformed response PDU?
752  if(length < sizeof(ModbusMaskWriteRegResp))
753  return ERROR_INVALID_LENGTH;
754 
755  //Dump response PDU
756  TRACE_DEBUG(" Reference Address = %" PRIu16 "\r\n", ntohs(response->referenceAddr));
757  TRACE_DEBUG(" And Value = %" PRIu16 "\r\n", ntohs(response->andMask));
758  TRACE_DEBUG(" Or Value = %" PRIu16 "\r\n", ntohs(response->orMask));
759 
760  //Successful processing
761  return NO_ERROR;
762 }
763 
764 
765 /**
766  * @brief Dump Read Write Multiple Registers request
767  * @param[in] request Pointer to the request PDU
768  * @param[in] length Length of the request PDU, in bytes
769  * @return Error code
770  **/
771 
773  size_t length)
774 {
775  //Malformed request PDU?
777  return ERROR_INVALID_LENGTH;
778 
779  //Calculate the length of the data field
781 
782  //Dump request PDU
783  TRACE_DEBUG(" Read Starting Address = %" PRIu16 "\r\n", ntohs(request->readStartingAddr));
784  TRACE_DEBUG(" Quantity to Read = %" PRIu16 "\r\n", ntohs(request->quantityToRead));
785  TRACE_DEBUG(" Write Starting Address = %" PRIu16 "\r\n", ntohs(request->writeStartingAddr));
786  TRACE_DEBUG(" Quantity to Write = %" PRIu16 "\r\n", ntohs(request->quantityToWrite));
787  TRACE_DEBUG(" Write Byte Count = %" PRIu16 "\r\n", request->writeByteCount);
788  TRACE_DEBUG_ARRAY(" Write Register Value = ", (void *) request->writeRegValue, length);
789 
790  //Successful processing
791  return NO_ERROR;
792 }
793 
794 
795 /**
796  * @brief Dump Read Write Multiple Registers response
797  * @param[in] response Pointer to the response PDU
798  * @param[in] length Length of the response PDU, in bytes
799  * @return Error code
800  **/
801 
803  size_t length)
804 {
805  //Malformed response PDU?
807  return ERROR_INVALID_LENGTH;
808 
809  //Calculate the length of the data field
811 
812  //Dump response PDU
813  TRACE_DEBUG(" Read Byte Count = %" PRIu16 "\r\n", response->readByteCount);
814  TRACE_DEBUG_ARRAY(" Read Register Value = ", (void *) response->readRegValue, length);
815 
816  //Successful processing
817  return NO_ERROR;
818 }
819 
820 
821 /**
822  * @brief Dump Exception response
823  * @param[in] response Pointer to the response PDU
824  * @param[in] length Length of the response PDU, in bytes
825  * @return Error code
826  **/
827 
829  size_t length)
830 {
831 #if (MODBUS_TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
832  const char_t *label;
833 
834  //Malformed response PDU?
835  if(length < sizeof(ModbusExceptionResp))
836  return ERROR_INVALID_LENGTH;
837 
838  //Get the description of the exception code
839  if(response->exceptionCode < arraysize(modbusExceptionCodeLabel))
840  {
841  label = modbusExceptionCodeLabel[response->exceptionCode];
842  }
843  else
844  {
845  label = "";
846  }
847 
848  //Dump response PDU
849  TRACE_DEBUG(" Function Code = %" PRIu8 " (Exception)\r\n", response->functionCode);
850  TRACE_DEBUG(" Exception Code = %" PRIu16 " (%s)\r\n", response->exceptionCode, label);
851 #endif
852 
853  //Successful processing
854  return NO_ERROR;
855 }
856 
857 #endif
char char_t
Definition: compiler_port.h:48
#define ntohs(value)
Definition: cpu_endian.h:421
Debugging facilities.
#define TRACE_DEBUG_ARRAY(p, a, n)
Definition: debug.h:108
#define TRACE_DEBUG(...)
Definition: debug.h:107
error_t
Error codes.
Definition: error.h:43
@ ERROR_INVALID_FUNCTION_CODE
Definition: error.h:268
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_INVALID_LENGTH
Definition: error.h:111
Modbus/TCP client.
ModbusReadInputRegsReq
ModbusWriteMultipleCoilsResp
ModbusExceptionResp
ModbusReadDiscreteInputsReq
ModbusWriteSingleRegReq
ModbusWriteMultipleRegsResp
@ MODBUS_FUNCTION_WRITE_SINGLE_COIL
Definition: modbus_common.h:80
@ MODBUS_FUNCTION_READ_COILS
Definition: modbus_common.h:76
@ MODBUS_FUNCTION_WRITE_SINGLE_REG
Definition: modbus_common.h:81
@ MODBUS_FUNCTION_READ_WRITE_MULTIPLE_REGS
Definition: modbus_common.h:92
@ MODBUS_FUNCTION_WRITE_MULTIPLE_REGS
Definition: modbus_common.h:87
@ MODBUS_FUNCTION_READ_HOLDING_REGS
Definition: modbus_common.h:78
@ MODBUS_FUNCTION_WRITE_MULTIPLE_COILS
Definition: modbus_common.h:86
@ MODBUS_FUNCTION_READ_INPUT_REGS
Definition: modbus_common.h:79
@ MODBUS_FUNCTION_MASK_WRITE_REG
Definition: modbus_common.h:91
@ MODBUS_FUNCTION_READ_DISCRETE_INPUTS
Definition: modbus_common.h:77
ModbusReadWriteMultipleRegsResp
ModbusWriteSingleCoilReq
ModbusReadHoldingRegsReq
ModbusReadDiscreteInputsResp
ModbusReadCoilsResp
ModbusWriteMultipleCoilsReq
ModbusWriteSingleCoilResp
ModbusReadWriteMultipleRegsReq
ModbusWriteSingleRegResp
#define MODBUS_EXCEPTION_MASK
Definition: modbus_common.h:55
uint8_t pdu[]
ModbusMaskWriteRegResp
ModbusReadInputRegsResp
ModbusReadHoldingRegsResp
ModbusReadCoilsReq
ModbusMaskWriteRegReq
ModbusWriteMultipleRegsReq
error_t modbusDumpWriteSingleRegResp(const ModbusWriteSingleRegResp *response, size_t length)
Dump Write Single Register response.
Definition: modbus_debug.c:599
error_t modbusDumpWriteMultipleRegsResp(const ModbusWriteMultipleRegsResp *response, size_t length)
Dump Write Multiple Registers response.
Definition: modbus_debug.c:701
error_t modbusDumpReadCoilsResp(const ModbusReadCoilsResp *response, size_t length)
Dump Read Coils response.
Definition: modbus_debug.c:357
error_t modbusDumpReadWriteMultipleRegsResp(const ModbusReadWriteMultipleRegsResp *response, size_t length)
Dump Read Write Multiple Registers response.
Definition: modbus_debug.c:802
error_t modbusDumpWriteMultipleCoilsResp(const ModbusWriteMultipleCoilsResp *response, size_t length)
Dump Write Multiple Coils response.
Definition: modbus_debug.c:650
error_t modbusDumpReadHoldingRegsReq(const ModbusReadHoldingRegsReq *request, size_t length)
Dump Read Holding Registers request.
Definition: modbus_debug.c:432
error_t modbusDumpResponsePdu(const void *pdu, size_t length)
Dump Modbus response PDU for debugging purpose.
Definition: modbus_debug.c:212
error_t modbusDumpWriteSingleCoilReq(const ModbusWriteSingleCoilReq *request, size_t length)
Dump Write Single Coil request.
Definition: modbus_debug.c:530
error_t modbusDumpReadHoldingRegsResp(const ModbusReadHoldingRegsResp *response, size_t length)
Dump Read Holding Registers response.
Definition: modbus_debug.c:455
error_t modbusDumpMaskWriteRegReq(const ModbusMaskWriteRegReq *request, size_t length)
Dump Mask Write Register request.
Definition: modbus_debug.c:724
error_t modbusDumpReadDiscreteInputsReq(const ModbusReadDiscreteInputsReq *request, size_t length)
Dump Read Discrete Inputs request.
Definition: modbus_debug.c:383
error_t modbusDumpMaskWriteRegResp(const ModbusMaskWriteRegResp *response, size_t length)
Dump Mask Write Register response.
Definition: modbus_debug.c:748
error_t modbusDumpExceptionResp(const ModbusExceptionResp *response, size_t length)
Dump Exception response.
Definition: modbus_debug.c:828
error_t modbusDumpReadInputRegsResp(const ModbusReadInputRegsResp *response, size_t length)
Dump Read Input Registers response.
Definition: modbus_debug.c:504
error_t modbusDumpReadDiscreteInputsResp(const ModbusReadDiscreteInputsResp *response, size_t length)
Dump Read Discrete Inputs response.
Definition: modbus_debug.c:406
const char_t *const modbusExceptionCodeLabel[]
Definition: modbus_debug.c:75
error_t modbusDumpRequestPdu(const void *pdu, size_t length)
Dump Modbus request PDU for debugging purpose.
Definition: modbus_debug.c:99
error_t modbusDumpWriteSingleRegReq(const ModbusWriteSingleRegReq *request, size_t length)
Dump Write Single Register request.
Definition: modbus_debug.c:576
error_t modbusDumpReadInputRegsReq(const ModbusReadInputRegsReq *request, size_t length)
Dump Read Input Registers request.
Definition: modbus_debug.c:481
error_t modbusDumpWriteMultipleCoilsReq(const ModbusWriteMultipleCoilsReq *request, size_t length)
Dump Write Multiple Coils request.
Definition: modbus_debug.c:622
error_t modbusDumpWriteMultipleRegsReq(const ModbusWriteMultipleRegsReq *request, size_t length)
Dump Write Multiple Registers request.
Definition: modbus_debug.c:673
error_t modbusDumpReadWriteMultipleRegsReq(const ModbusReadWriteMultipleRegsReq *request, size_t length)
Dump Read Write Multiple Registers request.
Definition: modbus_debug.c:772
const char_t *const modbusFunctionCodeLabel[]
Definition: modbus_debug.c:45
error_t modbusDumpWriteSingleCoilResp(const ModbusWriteSingleCoilResp *response, size_t length)
Dump Write Single Coil response.
Definition: modbus_debug.c:553
error_t modbusDumpReadCoilsReq(const ModbusReadCoilsReq *request, size_t length)
Dump Read Coils request.
Definition: modbus_debug.c:334
Data logging functions for debugging purpose (Modbus/TCP)
Modbus/TCP server.
TCP/IP stack core.
#define arraysize(a)
Definition: os_port.h:71
uint8_t length
Definition: tcp.h:368