modbus_debug.c File Reference

Data logging functions for debugging purpose (Modbus/TCP) More...

#include "core/net.h"
#include "modbus/modbus_client.h"
#include "modbus/modbus_server.h"
#include "modbus/modbus_debug.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   MODBUS_TRACE_LEVEL
 

Functions

error_t modbusDumpRequestPdu (const void *pdu, size_t length)
 Dump Modbus request PDU for debugging purpose. More...
 
error_t modbusDumpResponsePdu (const void *pdu, size_t length)
 Dump Modbus response PDU for debugging purpose. More...
 
error_t modbusDumpReadCoilsReq (const ModbusReadCoilsReq *request, size_t length)
 Dump Read Coils request. More...
 
error_t modbusDumpReadCoilsResp (const ModbusReadCoilsResp *response, size_t length)
 Dump Read Coils response. More...
 
error_t modbusDumpReadDiscreteInputsReq (const ModbusReadDiscreteInputsReq *request, size_t length)
 Dump Read Discrete Inputs request. More...
 
error_t modbusDumpReadDiscreteInputsResp (const ModbusReadDiscreteInputsResp *response, size_t length)
 Dump Read Discrete Inputs response. More...
 
error_t modbusDumpReadHoldingRegsReq (const ModbusReadHoldingRegsReq *request, size_t length)
 Dump Read Holding Registers request. More...
 
error_t modbusDumpReadHoldingRegsResp (const ModbusReadHoldingRegsResp *response, size_t length)
 Dump Read Holding Registers response. More...
 
error_t modbusDumpReadInputRegsReq (const ModbusReadInputRegsReq *request, size_t length)
 Dump Read Input Registers request. More...
 
error_t modbusDumpReadInputRegsResp (const ModbusReadInputRegsResp *response, size_t length)
 Dump Read Input Registers response. More...
 
error_t modbusDumpWriteSingleCoilReq (const ModbusWriteSingleCoilReq *request, size_t length)
 Dump Write Single Coil request. More...
 
error_t modbusDumpWriteSingleCoilResp (const ModbusWriteSingleCoilResp *response, size_t length)
 Dump Write Single Coil response. More...
 
error_t modbusDumpWriteSingleRegReq (const ModbusWriteSingleRegReq *request, size_t length)
 Dump Write Single Register request. More...
 
error_t modbusDumpWriteSingleRegResp (const ModbusWriteSingleRegResp *response, size_t length)
 Dump Write Single Register response. More...
 
error_t modbusDumpWriteMultipleCoilsReq (const ModbusWriteMultipleCoilsReq *request, size_t length)
 Dump Write Multiple Coils request. More...
 
error_t modbusDumpWriteMultipleCoilsResp (const ModbusWriteMultipleCoilsResp *response, size_t length)
 Dump Write Multiple Coils response. More...
 
error_t modbusDumpWriteMultipleRegsReq (const ModbusWriteMultipleRegsReq *request, size_t length)
 Dump Write Multiple Registers request. More...
 
error_t modbusDumpWriteMultipleRegsResp (const ModbusWriteMultipleRegsResp *response, size_t length)
 Dump Write Multiple Registers response. More...
 
error_t modbusDumpMaskWriteRegReq (const ModbusMaskWriteRegReq *request, size_t length)
 Dump Mask Write Register request. More...
 
error_t modbusDumpMaskWriteRegResp (const ModbusMaskWriteRegResp *response, size_t length)
 Dump Mask Write Register response. More...
 
error_t modbusDumpReadWriteMultipleRegsReq (const ModbusReadWriteMultipleRegsReq *request, size_t length)
 Dump Read Write Multiple Registers request. More...
 
error_t modbusDumpReadWriteMultipleRegsResp (const ModbusReadWriteMultipleRegsResp *response, size_t length)
 Dump Read Write Multiple Registers response. More...
 
error_t modbusDumpExceptionResp (const ModbusExceptionResp *response, size_t length)
 Dump Exception response. More...
 

Variables

const char_tmodbusFunctionCodeLabel []
 
const char_tmodbusExceptionCodeLabel []
 

Detailed Description

Data logging functions for debugging purpose (Modbus/TCP)

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file modbus_debug.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   MODBUS_TRACE_LEVEL

Definition at line 30 of file modbus_debug.c.

Function Documentation

◆ modbusDumpExceptionResp()

error_t modbusDumpExceptionResp ( const ModbusExceptionResp response,
size_t  length 
)

Dump Exception response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 798 of file modbus_debug.c.

◆ modbusDumpMaskWriteRegReq()

error_t modbusDumpMaskWriteRegReq ( const ModbusMaskWriteRegReq request,
size_t  length 
)

Dump Mask Write Register request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 694 of file modbus_debug.c.

◆ modbusDumpMaskWriteRegResp()

error_t modbusDumpMaskWriteRegResp ( const ModbusMaskWriteRegResp response,
size_t  length 
)

Dump Mask Write Register response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 718 of file modbus_debug.c.

◆ modbusDumpReadCoilsReq()

error_t modbusDumpReadCoilsReq ( const ModbusReadCoilsReq request,
size_t  length 
)

Dump Read Coils request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 304 of file modbus_debug.c.

◆ modbusDumpReadCoilsResp()

error_t modbusDumpReadCoilsResp ( const ModbusReadCoilsResp response,
size_t  length 
)

Dump Read Coils response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 327 of file modbus_debug.c.

◆ modbusDumpReadDiscreteInputsReq()

error_t modbusDumpReadDiscreteInputsReq ( const ModbusReadDiscreteInputsReq request,
size_t  length 
)

Dump Read Discrete Inputs request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 353 of file modbus_debug.c.

◆ modbusDumpReadDiscreteInputsResp()

error_t modbusDumpReadDiscreteInputsResp ( const ModbusReadDiscreteInputsResp response,
size_t  length 
)

Dump Read Discrete Inputs response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 376 of file modbus_debug.c.

◆ modbusDumpReadHoldingRegsReq()

error_t modbusDumpReadHoldingRegsReq ( const ModbusReadHoldingRegsReq request,
size_t  length 
)

Dump Read Holding Registers request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 402 of file modbus_debug.c.

◆ modbusDumpReadHoldingRegsResp()

error_t modbusDumpReadHoldingRegsResp ( const ModbusReadHoldingRegsResp response,
size_t  length 
)

Dump Read Holding Registers response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 425 of file modbus_debug.c.

◆ modbusDumpReadInputRegsReq()

error_t modbusDumpReadInputRegsReq ( const ModbusReadInputRegsReq request,
size_t  length 
)

Dump Read Input Registers request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 451 of file modbus_debug.c.

◆ modbusDumpReadInputRegsResp()

error_t modbusDumpReadInputRegsResp ( const ModbusReadInputRegsResp response,
size_t  length 
)

Dump Read Input Registers response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 474 of file modbus_debug.c.

◆ modbusDumpReadWriteMultipleRegsReq()

error_t modbusDumpReadWriteMultipleRegsReq ( const ModbusReadWriteMultipleRegsReq request,
size_t  length 
)

Dump Read Write Multiple Registers request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 742 of file modbus_debug.c.

◆ modbusDumpReadWriteMultipleRegsResp()

error_t modbusDumpReadWriteMultipleRegsResp ( const ModbusReadWriteMultipleRegsResp response,
size_t  length 
)

Dump Read Write Multiple Registers response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 772 of file modbus_debug.c.

◆ modbusDumpRequestPdu()

error_t modbusDumpRequestPdu ( const void *  pdu,
size_t  length 
)

Dump Modbus request PDU for debugging purpose.

Parameters
[in]pduPointer to the Modbus request PDU
[in]lengthLength of the PDU, in bytes
Returns
Error code

Definition at line 97 of file modbus_debug.c.

◆ modbusDumpResponsePdu()

error_t modbusDumpResponsePdu ( const void *  pdu,
size_t  length 
)

Dump Modbus response PDU for debugging purpose.

Parameters
[in]pduPointer to the Modbus response PDU
[in]lengthLength of the PDU, in bytes
Returns
Error code

Definition at line 196 of file modbus_debug.c.

◆ modbusDumpWriteMultipleCoilsReq()

error_t modbusDumpWriteMultipleCoilsReq ( const ModbusWriteMultipleCoilsReq request,
size_t  length 
)

Dump Write Multiple Coils request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 592 of file modbus_debug.c.

◆ modbusDumpWriteMultipleCoilsResp()

error_t modbusDumpWriteMultipleCoilsResp ( const ModbusWriteMultipleCoilsResp response,
size_t  length 
)

Dump Write Multiple Coils response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 620 of file modbus_debug.c.

◆ modbusDumpWriteMultipleRegsReq()

error_t modbusDumpWriteMultipleRegsReq ( const ModbusWriteMultipleRegsReq request,
size_t  length 
)

Dump Write Multiple Registers request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 643 of file modbus_debug.c.

◆ modbusDumpWriteMultipleRegsResp()

error_t modbusDumpWriteMultipleRegsResp ( const ModbusWriteMultipleRegsResp response,
size_t  length 
)

Dump Write Multiple Registers response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 671 of file modbus_debug.c.

◆ modbusDumpWriteSingleCoilReq()

error_t modbusDumpWriteSingleCoilReq ( const ModbusWriteSingleCoilReq request,
size_t  length 
)

Dump Write Single Coil request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 500 of file modbus_debug.c.

◆ modbusDumpWriteSingleCoilResp()

error_t modbusDumpWriteSingleCoilResp ( const ModbusWriteSingleCoilResp response,
size_t  length 
)

Dump Write Single Coil response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 523 of file modbus_debug.c.

◆ modbusDumpWriteSingleRegReq()

error_t modbusDumpWriteSingleRegReq ( const ModbusWriteSingleRegReq request,
size_t  length 
)

Dump Write Single Register request.

Parameters
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 546 of file modbus_debug.c.

◆ modbusDumpWriteSingleRegResp()

error_t modbusDumpWriteSingleRegResp ( const ModbusWriteSingleRegResp response,
size_t  length 
)

Dump Write Single Register response.

Parameters
[in]responsePointer to the response PDU
[in]lengthLength of the response PDU, in bytes
Returns
Error code

Definition at line 569 of file modbus_debug.c.

Variable Documentation

◆ modbusExceptionCodeLabel

const char_t* modbusExceptionCodeLabel[]
Initial value:
=
{
"",
"Illegal Function",
"Illegal Data Address",
"Illegal Data Value",
"Slave Device Failure",
"Acknowledge",
"Slave Device Busy",
"",
"Memory Parity Error",
"",
"Gateway Path Unavailable",
"Gateway Target Device Failed To Respond"
}

Definition at line 73 of file modbus_debug.c.

◆ modbusFunctionCodeLabel

const char_t* modbusFunctionCodeLabel[]
Initial value:
=
{
"",
"Read Coils",
"Read Discrete Inputs",
"Read Holding Registers",
"Read Input Registers",
"Write Single Coil",
"Write Single Register",
"Read Exception Status",
"Diagnostics",
"",
"",
"Get Comm Event Counter",
"Get Comm Event Log",
"",
"",
"Write Multiple Coils",
"Write Multiple Registers",
"Report Slave ID",
"",
"",
"Read File Record",
"Write File Record",
"Mask Write Register",
"Read/Write Multiple Registers",
"Read FIFO Queue"
}

Definition at line 43 of file modbus_debug.c.