Modbus PDU formatting and parsing. More...
#include "modbus/modbus_client.h"
#include "modbus/modbus_client_pdu.h"
#include "modbus/modbus_client_misc.h"
#include "modbus/modbus_debug.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL MODBUS_TRACE_LEVEL |
Detailed Description
Modbus PDU formatting and parsing.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 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.
- Version
- 2.4.4
Definition in file modbus_client_pdu.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL MODBUS_TRACE_LEVEL |
Definition at line 32 of file modbus_client_pdu.c.
Function Documentation
◆ modbusClientFormatMaskWriteRegReq()
error_t modbusClientFormatMaskWriteRegReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint16_t | andMask, | ||
uint16_t | orMask | ||
) |
Format Mask Write Register request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the holding register [in] andMask AND bitmask [in] orMask OR bitmask
- Returns
- Error code
Definition at line 366 of file modbus_client_pdu.c.
◆ modbusClientFormatReadCoilsReq()
error_t modbusClientFormatReadCoilsReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity | ||
) |
Format Read Coils request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the first coil [in] quantity Number of coils
- Returns
- Error code
Definition at line 53 of file modbus_client_pdu.c.
◆ modbusClientFormatReadDiscreteInputsReq()
error_t modbusClientFormatReadDiscreteInputsReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity | ||
) |
Format Read Discrete Inputs request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the first coil [in] quantity Number of inputs
- Returns
- Error code
Definition at line 88 of file modbus_client_pdu.c.
◆ modbusClientFormatReadHoldingRegsReq()
error_t modbusClientFormatReadHoldingRegsReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity | ||
) |
Format Read Holding Registers request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Starting register address [in] quantity Number of registers
- Returns
- Error code
Definition at line 123 of file modbus_client_pdu.c.
◆ modbusClientFormatReadInputRegsReq()
error_t modbusClientFormatReadInputRegsReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity | ||
) |
Format Read Input Registers request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Starting register address [in] quantity Number of registers
- Returns
- Error code
Definition at line 158 of file modbus_client_pdu.c.
◆ modbusClientFormatReadWriteMultipleRegsReq()
error_t modbusClientFormatReadWriteMultipleRegsReq | ( | ModbusClientContext * | context, |
uint16_t | readAddress, | ||
uint16_t | readQuantity, | ||
uint16_t | writeAddress, | ||
uint16_t | writeQuantity, | ||
const uint16_t * | writeValue | ||
) |
Format Read/Write Multiple Registers request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] readAddress Address of the first holding registers to be read [in] readQuantity Number of holding registers to be read [in] writeAddress Address of the first holding registers to be written [in] writeQuantity Number of holding registers to be written [in] writeValue Value of the holding registers (write operation)
- Returns
- Error code
Definition at line 405 of file modbus_client_pdu.c.
◆ modbusClientFormatWriteMultipleCoilsReq()
error_t modbusClientFormatWriteMultipleCoilsReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity, | ||
const uint8_t * | value | ||
) |
Format Write Multiple Coils request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the first coil to be forced [in] quantity Number of coils [in] value Value of the discrete outputs
- Returns
- Error code
Definition at line 274 of file modbus_client_pdu.c.
◆ modbusClientFormatWriteMultipleRegsReq()
error_t modbusClientFormatWriteMultipleRegsReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity, | ||
const uint16_t * | value | ||
) |
Format Write Multiple Registers request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Starting register address [in] quantity Number of registers [in] value Value of the holding registers
- Returns
- Error code
Definition at line 322 of file modbus_client_pdu.c.
◆ modbusClientFormatWriteSingleCoilReq()
error_t modbusClientFormatWriteSingleCoilReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
bool_t | value | ||
) |
Format Write Single Coil request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the coil to be forced [in] value Value of the discrete output
- Returns
- Error code
Definition at line 193 of file modbus_client_pdu.c.
◆ modbusClientFormatWriteSingleRegReq()
error_t modbusClientFormatWriteSingleRegReq | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint16_t | value | ||
) |
Format Write Single Register request.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the register to be written [in] value Register value
- Returns
- Error code
Definition at line 238 of file modbus_client_pdu.c.
◆ modbusClientParseExceptionResp()
error_t modbusClientParseExceptionResp | ( | ModbusClientContext * | context | ) |
Parse Exception response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context
- Returns
- Error code
Definition at line 869 of file modbus_client_pdu.c.
◆ modbusClientParseMaskWriteRegResp()
error_t modbusClientParseMaskWriteRegResp | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint16_t | andMask, | ||
uint16_t | orMask | ||
) |
Parse Mask Write Register response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the holding register [in] andMask AND bitmask [in] orMask OR bitmask
- Returns
- Error code
Definition at line 785 of file modbus_client_pdu.c.
◆ modbusClientParseReadCoilsResp()
error_t modbusClientParseReadCoilsResp | ( | ModbusClientContext * | context, |
uint_t | quantity, | ||
uint8_t * | value | ||
) |
Parse Read Coils response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] quantity Number of coils [out] value Value of the discrete outputs
- Returns
- Error code
Definition at line 451 of file modbus_client_pdu.c.
◆ modbusClientParseReadDiscreteInputsResp()
error_t modbusClientParseReadDiscreteInputsResp | ( | ModbusClientContext * | context, |
uint_t | quantity, | ||
uint8_t * | value | ||
) |
Parse Discrete Inputs response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] quantity Number of inputs [out] value Value of the discrete inputs
- Returns
- Error code
Definition at line 492 of file modbus_client_pdu.c.
◆ modbusClientParseReadHoldingRegsResp()
error_t modbusClientParseReadHoldingRegsResp | ( | ModbusClientContext * | context, |
uint_t | quantity, | ||
uint16_t * | value | ||
) |
Parse Read Holding Registers response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] quantity Number of registers [out] value Value of the holding registers
- Returns
- Error code
Definition at line 533 of file modbus_client_pdu.c.
◆ modbusClientParseReadInputRegsResp()
error_t modbusClientParseReadInputRegsResp | ( | ModbusClientContext * | context, |
uint_t | quantity, | ||
uint16_t * | value | ||
) |
Parse Read Input Registers response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] quantity Number of registers [out] value Value of the input registers
- Returns
- Error code
Definition at line 581 of file modbus_client_pdu.c.
◆ modbusClientParseReadWriteMultipleRegsResp()
error_t modbusClientParseReadWriteMultipleRegsResp | ( | ModbusClientContext * | context, |
uint_t | readQuantity, | ||
uint16_t * | readValue | ||
) |
Parse Read/Write Multiple Registers response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] readQuantity Number of holding registers to be read [out] readValue Value of the holding registers
- Returns
- Error code
Definition at line 823 of file modbus_client_pdu.c.
◆ modbusClientParseWriteMultipleCoilsResp()
error_t modbusClientParseWriteMultipleCoilsResp | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity | ||
) |
Parse Write Multiple Coils response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the first coil to be forced [in] quantity Number of coils
- Returns
- Error code
Definition at line 708 of file modbus_client_pdu.c.
◆ modbusClientParseWriteMultipleRegsResp()
error_t modbusClientParseWriteMultipleRegsResp | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint_t | quantity | ||
) |
Parse Write Multiple Registers response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Starting register address [in] quantity Number of registers
- Returns
- Error code
Definition at line 746 of file modbus_client_pdu.c.
◆ modbusClientParseWriteSingleCoilResp()
error_t modbusClientParseWriteSingleCoilResp | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
bool_t | value | ||
) |
Parse Write Single Coil response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the coil to be forced [in] value Value of the discrete output
- Returns
- Error code
Definition at line 629 of file modbus_client_pdu.c.
◆ modbusClientParseWriteSingleRegResp()
error_t modbusClientParseWriteSingleRegResp | ( | ModbusClientContext * | context, |
uint16_t | address, | ||
uint16_t | value | ||
) |
Parse Write Single Register response.
- Parameters
-
[in] context Pointer to the Modbus/TCP client context [in] address Address of the register to be written [in] value Register value
- Returns
- Error code
Definition at line 671 of file modbus_client_pdu.c.