rodbus (.NET API) 1.3.1
Loading...
Searching...
No Matches
rodbus.Server Class Reference

Handle to the running server. The server runs on a background task until this class is destroyed. More...

Public Member Functions

void Shutdown ()
 Shutdown and release all resources of a running server More...
 
void UpdateDatabase (byte unitId, Action< Database > transaction)
 Update the database associated with a particular unit id. If the unit id exists, lock the database and call user code to perform the transaction More...
 
void SetDecodeLevel (DecodeLevel level)
 Set the decoding level for the server More...
 

Static Public Member Functions

static Server CreateTcp (Runtime runtime, string address, ushort port, AddressFilter filter, ushort maxSessions, DeviceMap endpoints, DecodeLevel decodeLevel)
 Launch a TCP server. More...
 
static Server CreateRtu (Runtime runtime, string path, SerialPortSettings serialParams, RetryStrategy retry, DeviceMap endpoints, DecodeLevel decodeLevel)
 Launch a RTU server. More...
 
static Server CreateTlsWithAuthz (Runtime runtime, string address, ushort port, AddressFilter filter, ushort maxSessions, DeviceMap endpoints, TlsServerConfig tlsConfig, IAuthorizationHandler authorizationHandler, DecodeLevel decodeLevel)
 Create a Modbus Security (TLS) server. More...
 
static Server CreateTls (Runtime runtime, string address, ushort port, AddressFilter filter, ushort maxSessions, DeviceMap endpoints, TlsServerConfig tlsConfig, DecodeLevel decodeLevel)
 Create a TLS server that does NOT require the client role extension More...
 

Detailed Description

Handle to the running server. The server runs on a background task until this class is destroyed.

Member Function Documentation

◆ CreateRtu()

static Server rodbus.Server.CreateRtu ( Runtime  runtime,
string  path,
SerialPortSettings  serialParams,
RetryStrategy  retry,
DeviceMap  endpoints,
DecodeLevel  decodeLevel 
)
inlinestatic

Launch a RTU server.

Parameters
runtimeruntime on which to spawn the server
pathPath to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows.
serialParamsSerial port settings
retryParameters that control How long to wait before re-opening the serial port
endpointsmap of endpoints which is emptied upon passing to this function
decodeLevelDecode levels for this server
Returns
RTU server instance
Exceptions
ParamException

◆ CreateTcp()

static Server rodbus.Server.CreateTcp ( Runtime  runtime,
string  address,
ushort  port,
AddressFilter  filter,
ushort  maxSessions,
DeviceMap  endpoints,
DecodeLevel  decodeLevel 
)
inlinestatic

Launch a TCP server.

Recommended port for Modbus is 502.

When the maximum number of concurrent sessions is reached, the oldest session is closed.

Parameters
runtimeruntime on which to spawn the server
addressLocal IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter
portPort on which to listen
filterFilter used to limit which IP address(es) can connect
maxSessionsMaximum number of concurrent sessions
endpointsMap of endpoints which is emptied upon passing to this function
decodeLevelDecode levels for this server
Returns
TCP server instance
Exceptions
ParamException

◆ CreateTls()

static Server rodbus.Server.CreateTls ( Runtime  runtime,
string  address,
ushort  port,
AddressFilter  filter,
ushort  maxSessions,
DeviceMap  endpoints,
TlsServerConfig  tlsConfig,
DecodeLevel  decodeLevel 
)
inlinestatic

Create a TLS server that does NOT require the client role extension

This functionality is not standardized by Modbus.org, but nevertheless is commonly implemented

When the maximum number of concurrent sessions is reached, the oldest session is closed.

Parameters
runtimeruntime on which to spawn the server
addressLocal IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter
portPort on which to listen
filterFilter used to limit which IP address(es) can connect
maxSessionsMaximum number of concurrent sessions
endpointsmap of endpoints which is emptied upon passing to this function
tlsConfigTLS server configuration
decodeLevelDecode levels for this server
Returns
Modbus Security (TLS) server instance
Exceptions
ParamException

◆ CreateTlsWithAuthz()

static Server rodbus.Server.CreateTlsWithAuthz ( Runtime  runtime,
string  address,
ushort  port,
AddressFilter  filter,
ushort  maxSessions,
DeviceMap  endpoints,
TlsServerConfig  tlsConfig,
IAuthorizationHandler  authorizationHandler,
DecodeLevel  decodeLevel 
)
inlinestatic

Create a Modbus Security (TLS) server.

This server requires that the client certificate contains the role extension and authorizes each request against the supplied handler.

Recommended port for Modbus Security is 802.

When the maximum number of concurrent sessions is reached, the oldest session is closed.

Parameters
runtimeruntime on which to spawn the server
addressLocal IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter
portPort on which to listen
filterFilter used to limit which IP address(es) can connect
maxSessionsMaximum number of concurrent sessions
endpointsmap of endpoints which is emptied upon passing to this function
tlsConfigTLS server configuration
authorizationHandlerAuthorization handler
decodeLevelDecode levels for this server
Returns
Modbus Security (TLS) server instance
Exceptions
ParamException

◆ SetDecodeLevel()

void rodbus.Server.SetDecodeLevel ( DecodeLevel  level)
inline

Set the decoding level for the server

Parameters
levelDecoding level
Exceptions
ParamException

◆ Shutdown()

void rodbus.Server.Shutdown ( )
inline

Shutdown and release all resources of a running server

◆ UpdateDatabase()

void rodbus.Server.UpdateDatabase ( byte  unitId,
Action< Database transaction 
)
inline

Update the database associated with a particular unit id. If the unit id exists, lock the database and call user code to perform the transaction

Parameters
unitIdUnit id of the database to update
transactionCallback invoked when a lock has been acquired
Exceptions
ParamException

The documentation for this class was generated from the following file: