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