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  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _MODBUS_SERVER_MISC_H
30 #define _MODBUS_SERVER_MISC_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "modbus/modbus_server.h"
35 
36 //C++ guard
37 #ifdef __cplusplus
38  extern "C" {
39 #endif
40 
41 //Modbus/TCP server related functions
43 
46 
48  ModbusClientConnection *connection);
49 
51 
53  size_t length);
54 
56  size_t *length);
57 
59 
62 
64  bool_t *state);
65 
67  bool_t state, bool_t commit);
68 
70  uint16_t *value);
71 
73  uint16_t value, bool_t commit);
74 
76 
77 //C++ guard
78 #ifdef __cplusplus
79  }
80 #endif
81 
82 #endif
error_t modbusServerWriteReg(ModbusServerContext *context, uint16_t address, uint16_t value, bool_t commit)
Set register value.
Modbus/TCP server.
error_t modbusServerReadReg(ModbusServerContext *context, uint16_t address, uint16_t *value)
Get register value.
TCP/IP stack core.
error_t modbusServerReadCoil(ModbusServerContext *context, uint16_t address, bool_t *state)
Get coil state.
void modbusServerAcceptConnection(ModbusServerContext *context)
Accept connection request.
void modbusServerCloseConnection(ModbusClientConnection *connection)
Connection event handler.
void * modbusServerGetRequestPdu(ModbusClientConnection *connection, size_t *length)
Retrieve request PDU.
void modbusServerUnlock(ModbusServerContext *context)
Unlock Modbus table.
ModbusExceptionCode modbusServerTranslateExceptionCode(error_t status)
Translate exception code.
void modbusServerTick(ModbusServerContext *context)
Handle periodic operations.
ModbusExceptionCode
Modbus exception codes.
Definition: modbus_common.h:97
Modbus/TCP client connection.
error_t modbusServerFormatMbapHeader(ModbusClientConnection *connection, size_t length)
Format response MBAP header.
void modbusServerLock(ModbusServerContext *context)
Lock Modbus table.
Ipv6Addr address
#define ModbusServerContext
Definition: modbus_server.h:78
error_t modbusServerParseMbapHeader(ModbusClientConnection *connection)
Parse request MBAP header.
error_t
Error codes.
Definition: error.h:40
uint8_t value[]
Definition: dtls_misc.h:141
error_t modbusServerWriteCoil(ModbusServerContext *context, uint16_t address, bool_t state, bool_t commit)
Set coil state.
void modbusServerProcessConnectionEvents(ModbusServerContext *context, ModbusClientConnection *connection)
Connection event handler.
void * modbusServerGetResponsePdu(ModbusClientConnection *connection)
Retrieve response PDU.
uint8_t length
Definition: dtls_misc.h:140
int bool_t
Definition: compiler_port.h:47