rodbus (C++ API) 1.3.1
|
Handle to the running server. The server runs on a background task until this class is destroyed. More...
#include <rodbus.hpp>
Public Member Functions | |
Server (Server &&other) noexcept | |
Transfer ownership of the underlying C-type to this instance and invalidate the other instance. More... | |
~Server () | |
Shutdown and release all resources of a running server. More... | |
void | update_database (uint8_t unit_id, DatabaseCallback &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 | set_decode_level (const DecodeLevel &level) |
Set the decoding level for the server. More... | |
Static Public Member Functions | |
static Server | create_tcp (Runtime &runtime, const std::string &address, uint16_t port, AddressFilter &filter, uint16_t max_sessions, DeviceMap &endpoints, const DecodeLevel &decode_level) |
Launch a TCP server. More... | |
static Server | create_rtu (Runtime &runtime, const std::string &path, const SerialPortSettings &serial_params, const RetryStrategy &retry, DeviceMap &endpoints, const DecodeLevel &decode_level) |
Launch a RTU server. More... | |
static Server | create_tls_with_authz (Runtime &runtime, const std::string &address, uint16_t port, AddressFilter &filter, uint16_t max_sessions, DeviceMap &endpoints, const TlsServerConfig &tls_config, std::unique_ptr< AuthorizationHandler > authorization_handler, const DecodeLevel &decode_level) |
Create a Modbus Security (TLS) server. More... | |
static Server | create_tls (Runtime &runtime, const std::string &address, uint16_t port, AddressFilter &filter, uint16_t max_sessions, DeviceMap &endpoints, const TlsServerConfig &tls_config, const DecodeLevel &decode_level) |
Create a TLS server that does NOT require the client role extension. More... | |
Friends | |
class | CppServerFriend |
Handle to the running server. The server runs on a background task until this class is destroyed.
|
inlinenoexcept |
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
other | Class from which ownership will be transfer to this instance |
rodbus::Server::~Server | ( | ) |
Shutdown and release all resources of a running server.
|
static |
Launch a RTU server.
runtime | runtime on which to spawn the server |
path | Path to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows. |
serial_params | Serial port settings |
retry | Parameters that control How long to wait before re-opening the serial port |
endpoints | map of endpoints which is emptied upon passing to this function |
decode_level | Decode levels for this server |
ParamException |
|
static |
Launch a TCP server.
Recommended port for Modbus is 502.
When the maximum number of concurrent sessions is reached, the oldest session is closed.
runtime | runtime on which to spawn the server |
address | Local IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter |
port | Port on which to listen |
filter | Filter used to limit which IP address(es) can connect |
max_sessions | Maximum number of concurrent sessions |
endpoints | Map of endpoints which is emptied upon passing to this function |
decode_level | Decode levels for this server |
ParamException |
|
static |
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.
runtime | runtime on which to spawn the server |
address | Local IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter |
port | Port on which to listen |
filter | Filter used to limit which IP address(es) can connect |
max_sessions | Maximum number of concurrent sessions |
endpoints | map of endpoints which is emptied upon passing to this function |
tls_config | TLS server configuration |
decode_level | Decode levels for this server |
ParamException |
|
static |
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.
runtime | runtime on which to spawn the server |
address | Local IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter |
port | Port on which to listen |
filter | Filter used to limit which IP address(es) can connect |
max_sessions | Maximum number of concurrent sessions |
endpoints | map of endpoints which is emptied upon passing to this function |
tls_config | TLS server configuration |
authorization_handler | Authorization handler |
decode_level | Decode levels for this server |
ParamException |
void rodbus::Server::set_decode_level | ( | const DecodeLevel & | level | ) |
void rodbus::Server::update_database | ( | uint8_t | unit_id, |
DatabaseCallback & | 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.
unit_id | Unit id of the database to update |
transaction | Callback invoked when a lock has been acquired |
ParamException |