modbus_server_misc.h
Go to the documentation of this file.
1 /**
2  * @file modbus_server_misc.h
3  * @brief Helper functions for Modbus/TCP server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _MODBUS_SERVER_MISC_H
32 #define _MODBUS_SERVER_MISC_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "modbus/modbus_server.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //Modbus/TCP server related functions
45 
47  SocketEventDesc *eventDesc);
48 
50 
52 
54  size_t length);
55 
57  size_t *length);
58 
60 
63 
65  uint16_t address, bool_t *state);
66 
68  uint16_t address, bool_t *state);
69 
71  uint16_t address, bool_t state, bool_t commit);
72 
74  uint16_t address, uint16_t *value);
75 
77  uint16_t address, uint16_t *value);
78 
80  uint16_t address, uint16_t value, bool_t commit);
81 
83 
84 //C++ guard
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
Ipv6Addr address[]
Definition: ipv6.h:316
ModbusExceptionCode
Modbus exception codes.
Modbus/TCP server.
#define ModbusServerContext
#define ModbusClientConnection
void modbusServerRegisterConnectionEvents(ModbusClientConnection *connection, SocketEventDesc *eventDesc)
Register connection events.
error_t modbusServerWriteReg(ModbusClientConnection *connection, uint16_t address, uint16_t value, bool_t commit)
Write a single register.
error_t modbusServerFormatMbapHeader(ModbusClientConnection *connection, size_t length)
Format response MBAP header.
ModbusExceptionCode modbusServerTranslateExceptionCode(error_t status)
Translate exception code.
error_t modbusServerWriteCoil(ModbusClientConnection *connection, uint16_t address, bool_t state, bool_t commit)
Write a single coil.
error_t modbusServerParseMbapHeader(ModbusClientConnection *connection)
Parse request MBAP header.
void * modbusServerGetResponsePdu(ModbusClientConnection *connection)
Retrieve response PDU.
error_t modbusServerReadDiscreteInput(ModbusClientConnection *connection, uint16_t address, bool_t *state)
Read a single discrete input.
void modbusServerTick(ModbusServerContext *context)
Handle periodic operations.
error_t modbusServerReadInputReg(ModbusClientConnection *connection, uint16_t address, uint16_t *value)
Read a single input register.
error_t modbusServerReadHoldingReg(ModbusClientConnection *connection, uint16_t address, uint16_t *value)
Read a single holding register.
void modbusServerUnlock(ModbusClientConnection *connection)
Unlock Modbus table.
error_t modbusServerReadCoil(ModbusClientConnection *connection, uint16_t address, bool_t *state)
Read a single coil.
void * modbusServerGetRequestPdu(ModbusClientConnection *connection, size_t *length)
Retrieve request PDU.
void modbusServerProcessConnectionEvents(ModbusClientConnection *connection)
Connection event handler.
void modbusServerLock(ModbusClientConnection *connection)
Lock Modbus table.
TCP/IP stack core.
Structure describing socket events.
Definition: socket.h:398
uint8_t length
Definition: tcp.h:368
uint8_t value[]
Definition: tcp.h:369