modbus_server_pdu.h File Reference

Modbus PDU processing. More...

#include "core/net.h"
#include "modbus/modbus_server.h"

Go to the source code of this file.

Functions

error_t modbusServerProcessRequest (ModbusClientConnection *connection)
 Process Modbus request. More...
 
error_t modbusServerProcessReadCoilsReq (ModbusClientConnection *connection, const ModbusReadCoilsReq *request, size_t length)
 Process Read Coils request. More...
 
error_t modbusServerProcessReadDiscreteInputsReq (ModbusClientConnection *connection, const ModbusReadDiscreteInputsReq *request, size_t length)
 Process Read Discrete Inputs request. More...
 
error_t modbusServerProcessReadHoldingRegsReq (ModbusClientConnection *connection, const ModbusReadHoldingRegsReq *request, size_t length)
 Process Read Holding Registers request. More...
 
error_t modbusServerProcessReadInputRegsReq (ModbusClientConnection *connection, const ModbusReadInputRegsReq *request, size_t length)
 Process Read Input Registers request. More...
 
error_t modbusServerProcessWriteSingleCoilReq (ModbusClientConnection *connection, const ModbusWriteSingleCoilReq *request, size_t length)
 Process Write Single Coil request. More...
 
error_t modbusServerProcessWriteSingleRegReq (ModbusClientConnection *connection, const ModbusWriteSingleRegReq *request, size_t length)
 Process Write Single Register request. More...
 
error_t modbusServerProcessWriteMultipleCoilsReq (ModbusClientConnection *connection, const ModbusWriteMultipleCoilsReq *request, size_t length)
 Process Write Multiple Coils request. More...
 
error_t modbusServerProcessWriteMultipleRegsReq (ModbusClientConnection *connection, const ModbusWriteMultipleRegsReq *request, size_t length)
 Process Write Multiple Registers request. More...
 
error_t modbusServerProcessMaskWriteRegReq (ModbusClientConnection *connection, const ModbusMaskWriteRegReq *request, size_t length)
 Process Mask Write Register request. More...
 
error_t modbusServerProcessReadWriteMultipleRegsReq (ModbusClientConnection *connection, const ModbusReadWriteMultipleRegsReq *request, size_t length)
 Process Read/Write Multiple Registers request. More...
 
error_t modbusServerFormatExceptionResp (ModbusClientConnection *connection, ModbusFunctionCode functionCode, ModbusExceptionCode exceptionCode)
 Format exception response. More...
 

Detailed Description

Modbus PDU processing.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2022 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
2.2.0

Definition in file modbus_server_pdu.h.

Function Documentation

◆ modbusServerFormatExceptionResp()

error_t modbusServerFormatExceptionResp ( ModbusClientConnection connection,
ModbusFunctionCode  functionCode,
ModbusExceptionCode  exceptionCode 
)

Format exception response.

Parameters
[in]connectionPointer to the client connection
[in]functionCodeFunction code of the request
[in]exceptionCodeException code
Returns
Exception code

Definition at line 1110 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 921 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 235 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 333 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 431 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 509 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 999 of file modbus_server_pdu.c.

◆ modbusServerProcessRequest()

error_t modbusServerProcessRequest ( ModbusClientConnection connection)

Process Modbus request.

Parameters
[in]connectionPointer 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 726 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 823 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 587 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]connectionPointer to the client connection
[in]requestPointer to the request PDU
[in]lengthLength of the request PDU, in bytes
Returns
Error code

Definition at line 664 of file modbus_server_pdu.c.