Helper functions for Modbus/TCP server. More...
#include "modbus/modbus_server.h"
#include "modbus/modbus_server_pdu.h"
#include "modbus/modbus_server_security.h"
#include "modbus/modbus_server_transport.h"
#include "modbus/modbus_server_misc.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL MODBUS_TRACE_LEVEL |
Detailed Description
Helper functions for Modbus/TCP server.
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_misc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL MODBUS_TRACE_LEVEL |
Definition at line 32 of file modbus_server_misc.c.
Function Documentation
◆ modbusServerFormatMbapHeader()
error_t modbusServerFormatMbapHeader | ( | ModbusClientConnection * | connection, |
size_t | length | ||
) |
Format response MBAP header.
- Parameters
-
[in] connection Pointer to the client connection [in] length Length of the PDU, in bytes
- Returns
- Error code
Definition at line 410 of file modbus_server_misc.c.
◆ modbusServerGetRequestPdu()
void* modbusServerGetRequestPdu | ( | ModbusClientConnection * | connection, |
size_t * | length | ||
) |
Retrieve request PDU.
- Parameters
-
[in] connection Pointer to the client connection [out] length Length request the request PDU, in bytes
- Returns
- Pointer to the request PDU
Definition at line 461 of file modbus_server_misc.c.
◆ modbusServerGetResponsePdu()
void* modbusServerGetResponsePdu | ( | ModbusClientConnection * | connection | ) |
Retrieve response PDU.
- Parameters
-
[in] connection Pointer to the client connection
- Returns
- Pointer to the response PDU
Definition at line 490 of file modbus_server_misc.c.
◆ modbusServerLock()
void modbusServerLock | ( | ModbusClientConnection * | connection | ) |
Lock Modbus table.
- Parameters
-
[in] connection Pointer to the client connection
Definition at line 502 of file modbus_server_misc.c.
◆ modbusServerParseMbapHeader()
error_t modbusServerParseMbapHeader | ( | ModbusClientConnection * | connection | ) |
Parse request MBAP header.
- Parameters
-
[in] connection Pointer to the client connection
- Returns
- Error code
Definition at line 352 of file modbus_server_misc.c.
◆ modbusServerProcessConnectionEvents()
void modbusServerProcessConnectionEvents | ( | ModbusClientConnection * | connection | ) |
Connection event handler.
- Parameters
-
[in] connection Pointer to the client connection
Definition at line 174 of file modbus_server_misc.c.
◆ modbusServerReadCoil()
error_t modbusServerReadCoil | ( | ModbusClientConnection * | connection, |
uint16_t | address, | ||
bool_t * | state | ||
) |
Read a single coil.
- Parameters
-
[in] connection Pointer to the client connection [in] address Address of the coil [out] state Current state of the coil
- Returns
- Error code
Definition at line 547 of file modbus_server_misc.c.
◆ modbusServerReadDiscreteInput()
error_t modbusServerReadDiscreteInput | ( | ModbusClientConnection * | connection, |
uint16_t | address, | ||
bool_t * | state | ||
) |
Read a single discrete input.
- Parameters
-
[in] connection Pointer to the client connection [in] address Address of the discrete input [out] state Current state of the discrete input
- Returns
- Error code
Definition at line 582 of file modbus_server_misc.c.
◆ modbusServerReadHoldingReg()
error_t modbusServerReadHoldingReg | ( | ModbusClientConnection * | connection, |
uint16_t | address, | ||
uint16_t * | value | ||
) |
Read a single holding register.
- Parameters
-
[in] connection Pointer to the client connection [in] address Address of the holding register [out] value Current value of the holding register
- Returns
- Error code
Definition at line 660 of file modbus_server_misc.c.
◆ modbusServerReadInputReg()
error_t modbusServerReadInputReg | ( | ModbusClientConnection * | connection, |
uint16_t | address, | ||
uint16_t * | value | ||
) |
Read a single input register.
- Parameters
-
[in] connection Pointer to the client connection [in] address Address of the input register [out] value Current value of the input register
- Returns
- Error code
Definition at line 701 of file modbus_server_misc.c.
◆ modbusServerRegisterConnectionEvents()
void modbusServerRegisterConnectionEvents | ( | ModbusClientConnection * | connection, |
SocketEventDesc * | eventDesc | ||
) |
Register connection events.
- Parameters
-
[in] connection Pointer to the client connection [in] eventDesc Socket events to be registered
Definition at line 103 of file modbus_server_misc.c.
◆ modbusServerTick()
void modbusServerTick | ( | ModbusServerContext * | context | ) |
Handle periodic operations.
- Parameters
-
[in] context Pointer to the Modbus/TCP server context
Definition at line 51 of file modbus_server_misc.c.
◆ modbusServerTranslateExceptionCode()
ModbusExceptionCode modbusServerTranslateExceptionCode | ( | error_t | status | ) |
Translate exception code.
- Parameters
-
[in] status Status code
- Returns
- Exception code
Definition at line 777 of file modbus_server_misc.c.
◆ modbusServerUnlock()
void modbusServerUnlock | ( | ModbusClientConnection * | connection | ) |
Unlock Modbus table.
- Parameters
-
[in] connection Pointer to the client connection
Definition at line 523 of file modbus_server_misc.c.
◆ modbusServerWriteCoil()
error_t modbusServerWriteCoil | ( | ModbusClientConnection * | connection, |
uint16_t | address, | ||
bool_t | state, | ||
bool_t | commit | ||
) |
Write a single coil.
- Parameters
-
[in] connection Pointer to the client connection [in] address Address of the coil [in] state Desired state of the coil [in] commit This flag indicates the current phase (validation phase or write phase if the validation was successful)
- Returns
- Error code
Definition at line 625 of file modbus_server_misc.c.
◆ modbusServerWriteReg()
error_t modbusServerWriteReg | ( | ModbusClientConnection * | connection, |
uint16_t | address, | ||
uint16_t | value, | ||
bool_t | commit | ||
) |
Write a single register.
- Parameters
-
[in] connection Pointer to the client connection [in] address Address of the register [in] value Desired value of the register [in] commit This flag indicates the current phase (validation phase or write phase if the validation was successful)
- Returns
- Error code
Definition at line 744 of file modbus_server_misc.c.