Modbus PDU processing. More...
#include "modbus/modbus_server.h"
#include "modbus/modbus_server_pdu.h"
#include "modbus/modbus_server_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 processing.
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_server_pdu.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL MODBUS_TRACE_LEVEL |
Definition at line 32 of file modbus_server_pdu.c.
Function Documentation
◆ modbusServerFormatExceptionResp()
error_t modbusServerFormatExceptionResp | ( | ModbusClientConnection * | connection, |
ModbusFunctionCode | functionCode, | ||
ModbusExceptionCode | exceptionCode | ||
) |
Format exception response.
- Parameters
-
[in] connection Pointer to the client connection [in] functionCode Function code of the request [in] exceptionCode Exception code
- Returns
- Exception code
Definition at line 1115 of file modbus_server_pdu.c.
◆ modbusServerProcessMaskWriteRegReq()
error_t modbusServerProcessMaskWriteRegReq | ( | ModbusClientConnection * | connection, |
const ModbusMaskWriteRegReq * | request, | ||
size_t | length | ||
) |
Process Mask Write Register request.
This function code is used to modify the contents of a specified holding register using a combination of an AND mask, an OR mask, and the register's current contents. The function can be used to set or clear individual bits in the register
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 926 of file modbus_server_pdu.c.
◆ modbusServerProcessReadCoilsReq()
error_t modbusServerProcessReadCoilsReq | ( | ModbusClientConnection * | connection, |
const ModbusReadCoilsReq * | request, | ||
size_t | length | ||
) |
Process Read Coils request.
This function code is used to read from 1 to 2000 contiguous status of coils in a remote device. The request specifies the starting address and the number of coils
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 240 of file modbus_server_pdu.c.
◆ modbusServerProcessReadDiscreteInputsReq()
error_t modbusServerProcessReadDiscreteInputsReq | ( | ModbusClientConnection * | connection, |
const ModbusReadDiscreteInputsReq * | request, | ||
size_t | length | ||
) |
Process Read Discrete Inputs request.
This function code is used to read from 1 to 2000 contiguous status of discrete inputs in a remote device. The request specifies the starting address and the number of inputs
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 338 of file modbus_server_pdu.c.
◆ modbusServerProcessReadHoldingRegsReq()
error_t modbusServerProcessReadHoldingRegsReq | ( | ModbusClientConnection * | connection, |
const ModbusReadHoldingRegsReq * | request, | ||
size_t | length | ||
) |
Process Read Holding Registers request.
This function code is used to read the contents of a contiguous block of holding registers in a remote device. The request specifies the starting register address and the number of registers
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 436 of file modbus_server_pdu.c.
◆ modbusServerProcessReadInputRegsReq()
error_t modbusServerProcessReadInputRegsReq | ( | ModbusClientConnection * | connection, |
const ModbusReadInputRegsReq * | request, | ||
size_t | length | ||
) |
Process Read Input Registers request.
This function code is used to read from 1 to 125 contiguous input registers in a remote device. The request specifies the starting register address and the number of registers
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 514 of file modbus_server_pdu.c.
◆ modbusServerProcessReadWriteMultipleRegsReq()
error_t modbusServerProcessReadWriteMultipleRegsReq | ( | ModbusClientConnection * | connection, |
const ModbusReadWriteMultipleRegsReq * | request, | ||
size_t | length | ||
) |
Process Read/Write Multiple Registers request.
This function code performs a combination of one read operation and one write operation in a single Modbus transaction. The write operation is performed before the read
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 1004 of file modbus_server_pdu.c.
◆ modbusServerProcessRequest()
error_t modbusServerProcessRequest | ( | ModbusClientConnection * | connection | ) |
Process Modbus request.
- Parameters
-
[in] connection Pointer to the client connection
- Returns
- Error code
Definition at line 51 of file modbus_server_pdu.c.
◆ modbusServerProcessWriteMultipleCoilsReq()
error_t modbusServerProcessWriteMultipleCoilsReq | ( | ModbusClientConnection * | connection, |
const ModbusWriteMultipleCoilsReq * | request, | ||
size_t | length | ||
) |
Process Write Multiple Coils request.
This function code is used to force each coil in a sequence of coils to either ON or OFF in a remote device. The request specifies the starting address, the number of outputs and the requested ON/OFF states
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 731 of file modbus_server_pdu.c.
◆ modbusServerProcessWriteMultipleRegsReq()
error_t modbusServerProcessWriteMultipleRegsReq | ( | ModbusClientConnection * | connection, |
const ModbusWriteMultipleRegsReq * | request, | ||
size_t | length | ||
) |
Process Write Multiple Registers request.
This function code is used to write a block of contiguous registers (1 to 123 registers) in a remote device. The request specifies the starting address, the number of registers and the requested written values
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 828 of file modbus_server_pdu.c.
◆ modbusServerProcessWriteSingleCoilReq()
error_t modbusServerProcessWriteSingleCoilReq | ( | ModbusClientConnection * | connection, |
const ModbusWriteSingleCoilReq * | request, | ||
size_t | length | ||
) |
Process Write Single Coil request.
This function code is used to write a single output to either ON or OFF in a remote device. The request specifies the address of the coil to be forced and the requested ON/OFF state
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 592 of file modbus_server_pdu.c.
◆ modbusServerProcessWriteSingleRegReq()
error_t modbusServerProcessWriteSingleRegReq | ( | ModbusClientConnection * | connection, |
const ModbusWriteSingleRegReq * | request, | ||
size_t | length | ||
) |
Process Write Single Register request.
This function code is used to write a single holding register in a remote device. The request specifies the address of the register to be written and the register value
- Parameters
-
[in] connection Pointer to the client connection [in] request Pointer to the request PDU [in] length Length of the request PDU, in bytes
- Returns
- Error code
Definition at line 669 of file modbus_server_pdu.c.