modbus_server.h File Reference

Modbus/TCP server. More...

#include "core/net.h"
#include "modbus/modbus_common.h"

Go to the source code of this file.

Data Structures

struct  ModbusServerSettings
 Modbus/TCP server settings. More...
 
struct  ModbusClientConnection
 Modbus/TCP client connection. More...
 
struct  _ModbusServerContext
 Modbus/TCP server context. More...
 

Macros

#define MODBUS_SERVER_SUPPORT   ENABLED
 
#define MODBUS_SERVER_STACK_SIZE   650
 
#define MODBUS_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL
 
#define MODBUS_SERVER_MAX_CONNECTIONS   2
 
#define MODBUS_SERVER_TIMEOUT   60000
 
#define MODBUS_SERVER_TICK_INTERVAL   1000
 
#define ModbusServerContext   struct _ModbusServerContext
 

Typedefs

typedef void(* ModbusServerLockCallback) (void)
 Lock Modbus table callback function. More...
 
typedef void(* ModbusServerUnlockCallback) (void)
 Unlock Modbus table callback function. More...
 
typedef error_t(* ModbusServerReadCoilCallback) (uint16_t address, bool_t *state)
 Get coil state callback function. More...
 
typedef error_t(* ModbusServerWriteCoilCallback) (uint16_t address, bool_t state, bool_t commit)
 Set coil state callback function. More...
 
typedef error_t(* ModbusServerReadRegCallback) (uint16_t address, uint16_t *value)
 Get register value callback function. More...
 
typedef error_t(* ModbusServerWriteRegCallback) (uint16_t address, uint16_t value, bool_t commit)
 Set register value callback function. More...
 
typedef error_t(* ModbusServerProcessPduCallback) (const uint8_t *request, size_t requestLen, uint8_t *response, size_t *responseLen)
 PDU processing callback function. More...
 

Enumerations

enum  ModbusConnectionState { MODBUS_CONNECTION_STATE_CLOSED = 0, MODBUS_CONNECTION_STATE_RECEIVING = 1, MODBUS_CONNECTION_STATE_SENDING = 2 }
 Modbus/TCP connection state. More...
 

Functions

void modbusServerGetDefaultSettings (ModbusServerSettings *settings)
 Initialize settings with default values. More...
 
error_t modbusServerInit (ModbusServerContext *context, const ModbusServerSettings *settings)
 Initialize Modbus/TCP server context. More...
 
error_t modbusServerStart (ModbusServerContext *context)
 Start Modbus/TCP server. More...
 
void modbusServerTask (ModbusServerContext *context)
 Modbus/TCP server task. More...
 

Detailed Description

Modbus/TCP server.

License

Copyright (C) 2010-2018 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file modbus_server.h.

Macro Definition Documentation

◆ MODBUS_SERVER_MAX_CONNECTIONS

#define MODBUS_SERVER_MAX_CONNECTIONS   2

Definition at line 57 of file modbus_server.h.

◆ MODBUS_SERVER_PRIORITY

#define MODBUS_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL

Definition at line 52 of file modbus_server.h.

◆ MODBUS_SERVER_STACK_SIZE

#define MODBUS_SERVER_STACK_SIZE   650

Definition at line 45 of file modbus_server.h.

◆ MODBUS_SERVER_SUPPORT

#define MODBUS_SERVER_SUPPORT   ENABLED

Definition at line 38 of file modbus_server.h.

◆ MODBUS_SERVER_TICK_INTERVAL

#define MODBUS_SERVER_TICK_INTERVAL   1000

Definition at line 71 of file modbus_server.h.

◆ MODBUS_SERVER_TIMEOUT

#define MODBUS_SERVER_TIMEOUT   60000

Definition at line 64 of file modbus_server.h.

◆ ModbusServerContext

#define ModbusServerContext   struct _ModbusServerContext

Definition at line 78 of file modbus_server.h.

Typedef Documentation

◆ ModbusServerLockCallback

typedef void(* ModbusServerLockCallback) (void)

Lock Modbus table callback function.

Definition at line 102 of file modbus_server.h.

◆ ModbusServerProcessPduCallback

typedef error_t(* ModbusServerProcessPduCallback) (const uint8_t *request, size_t requestLen, uint8_t *response, size_t *responseLen)

PDU processing callback function.

Definition at line 148 of file modbus_server.h.

◆ ModbusServerReadCoilCallback

typedef error_t(* ModbusServerReadCoilCallback) (uint16_t address, bool_t *state)

Get coil state callback function.

Definition at line 116 of file modbus_server.h.

◆ ModbusServerReadRegCallback

typedef error_t(* ModbusServerReadRegCallback) (uint16_t address, uint16_t *value)

Get register value callback function.

Definition at line 132 of file modbus_server.h.

◆ ModbusServerUnlockCallback

typedef void(* ModbusServerUnlockCallback) (void)

Unlock Modbus table callback function.

Definition at line 109 of file modbus_server.h.

◆ ModbusServerWriteCoilCallback

typedef error_t(* ModbusServerWriteCoilCallback) (uint16_t address, bool_t state, bool_t commit)

Set coil state callback function.

Definition at line 124 of file modbus_server.h.

◆ ModbusServerWriteRegCallback

typedef error_t(* ModbusServerWriteRegCallback) (uint16_t address, uint16_t value, bool_t commit)

Set register value callback function.

Definition at line 140 of file modbus_server.h.

Enumeration Type Documentation

◆ ModbusConnectionState

Modbus/TCP connection state.

Enumerator
MODBUS_CONNECTION_STATE_CLOSED 
MODBUS_CONNECTION_STATE_RECEIVING 
MODBUS_CONNECTION_STATE_SENDING 

Definition at line 90 of file modbus_server.h.

Function Documentation

◆ modbusServerGetDefaultSettings()

void modbusServerGetDefaultSettings ( ModbusServerSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains Modbus/TCP server settings

Definition at line 46 of file modbus_server.c.

◆ modbusServerInit()

error_t modbusServerInit ( ModbusServerContext context,
const ModbusServerSettings settings 
)

Initialize Modbus/TCP server context.

Parameters
[in]contextPointer to the Modbus/TCP server context
[in]settingsModbus/TCP server specific settings
Returns
Error code

Definition at line 80 of file modbus_server.c.

◆ modbusServerStart()

error_t modbusServerStart ( ModbusServerContext context)

Start Modbus/TCP server.

Parameters
[in]contextPointer to the Modbus/TCP server context
Returns
Error code

Definition at line 160 of file modbus_server.c.

◆ modbusServerTask()

void modbusServerTask ( ModbusServerContext context)

Modbus/TCP server task.

Parameters
[in]contextPointer to the Modbus/TCP server context

Definition at line 189 of file modbus_server.c.