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.4
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
error_t modbusServerWriteCoil(ModbusClientConnection *connection, uint16_t address, bool_t state, bool_t commit)
Write a single coil.
int bool_t
Definition: compiler_port.h:53
void modbusServerRegisterConnectionEvents(ModbusClientConnection *connection, SocketEventDesc *eventDesc)
Register connection events.
error_t modbusServerReadInputReg(ModbusClientConnection *connection, uint16_t address, uint16_t *value)
Read a single input register.
error_t modbusServerReadDiscreteInput(ModbusClientConnection *connection, uint16_t address, bool_t *state)
Read a single discrete input.
void modbusServerLock(ModbusClientConnection *connection)
Lock Modbus table.
void * modbusServerGetRequestPdu(ModbusClientConnection *connection, size_t *length)
Retrieve request PDU.
Structure describing socket events.
Definition: socket.h:426
#define ModbusClientConnection
error_t modbusServerWriteReg(ModbusClientConnection *connection, uint16_t address, uint16_t value, bool_t commit)
Write a single register.
error_t
Error codes.
Definition: error.h:43
Modbus/TCP server.
error_t modbusServerFormatMbapHeader(ModbusClientConnection *connection, size_t length)
Format response MBAP header.
uint8_t length
Definition: tcp.h:368
error_t modbusServerParseMbapHeader(ModbusClientConnection *connection)
Parse request MBAP header.
Ipv6Addr address[]
Definition: ipv6.h:325
uint8_t value[]
Definition: tcp.h:369
error_t modbusServerReadCoil(ModbusClientConnection *connection, uint16_t address, bool_t *state)
Read a single coil.
ModbusExceptionCode modbusServerTranslateExceptionCode(error_t status)
Translate exception code.
error_t modbusServerReadHoldingReg(ModbusClientConnection *connection, uint16_t address, uint16_t *value)
Read a single holding register.
TCP/IP stack core.
ModbusExceptionCode
Modbus exception codes.
#define ModbusServerContext
void modbusServerTick(ModbusServerContext *context)
Handle periodic operations.
void * modbusServerGetResponsePdu(ModbusClientConnection *connection)
Retrieve response PDU.
void modbusServerProcessConnectionEvents(ModbusClientConnection *connection)
Connection event handler.
void modbusServerUnlock(ModbusClientConnection *connection)
Unlock Modbus table.