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-2019 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 1.9.6
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  ModbusClientConnection *connection);
48 
50 
52  size_t length);
53 
55  size_t *length);
56 
58 
61 
63  uint16_t address, bool_t *state);
64 
66  uint16_t address, bool_t *state);
67 
69  uint16_t address, bool_t state, bool_t commit);
70 
72  uint16_t address, uint16_t *value);
73 
75  uint16_t address, uint16_t *value);
76 
78  uint16_t address, uint16_t value, bool_t commit);
79 
81 
82 //C++ guard
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif
uint8_t length
Definition: dtls_misc.h:149
error_t modbusServerWriteCoil(ModbusClientConnection *connection, uint16_t address, bool_t state, bool_t commit)
Set coil state.
int bool_t
Definition: compiler_port.h:49
error_t modbusServerReadInputReg(ModbusClientConnection *connection, uint16_t address, uint16_t *value)
Get input register value.
error_t modbusServerReadDiscreteInput(ModbusClientConnection *connection, uint16_t address, bool_t *state)
Get discrete input state.
void modbusServerLock(ModbusClientConnection *connection)
Lock Modbus table.
void * modbusServerGetRequestPdu(ModbusClientConnection *connection, size_t *length)
Retrieve request PDU.
#define ModbusClientConnection
error_t modbusServerWriteReg(ModbusClientConnection *connection, uint16_t address, uint16_t value, bool_t commit)
Set register value.
error_t
Error codes.
Definition: error.h:42
Modbus/TCP server.
error_t modbusServerFormatMbapHeader(ModbusClientConnection *connection, size_t length)
Format response MBAP header.
void modbusServerProcessConnectionEvents(ModbusServerContext *context, ModbusClientConnection *connection)
Connection event handler.
error_t modbusServerParseMbapHeader(ModbusClientConnection *connection)
Parse request MBAP header.
error_t modbusServerReadCoil(ModbusClientConnection *connection, uint16_t address, bool_t *state)
Get coil state.
ModbusExceptionCode modbusServerTranslateExceptionCode(error_t status)
Translate exception code.
Ipv6Addr address
uint8_t value[]
Definition: dtls_misc.h:150
error_t modbusServerReadHoldingReg(ModbusClientConnection *connection, uint16_t address, uint16_t *value)
Get holding register value.
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 modbusServerUnlock(ModbusClientConnection *connection)
Unlock Modbus table.