171 friend class CppDecodeLevelFriend;
208 friend class CppBitValueFriend;
231 friend class CppRegisterValueFriend;
254 friend class CppRuntimeConfigFriend;
281 friend class CppRuntimeFriend;
285 Runtime(
void* self): self(self) {}
385 friend class CppAddressRangeFriend;
406 friend class CppRequestParamFriend;
438 friend class CppBitValueIteratorFriend;
483 friend class CppRegisterValueIteratorFriend;
606 friend class CppSerialPortSettingsFriend;
689 friend class CppRetryStrategyFriend;
769 friend class CppLoggingConfigFriend;
824namespace functional {
831 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
843 lambda(level, message);
852std::unique_ptr<Logger>
logger(
const T& lambda)
854 return std::make_unique<LoggerLambda<T>>(lambda); ;
881 friend class CppTlsClientConfigFriend;
974namespace functional {
981 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
1004 return std::make_unique<ClientStateListenerLambda<T>>(lambda); ;
1042namespace functional {
1049 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
1072 return std::make_unique<PortStateListenerLambda<T>>(lambda); ;
1142 friend class CppClientChannelFriend;
1307 friend class CppDatabaseFriend;
1311 Database(
void* self): self(self) {}
1447namespace functional {
1454 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
1490 friend class CppWriteResultFriend;
1589 friend class CppDeviceMapFriend;
1626 friend class CppTlsServerConfigFriend;
1764 friend class CppAddressFilterFriend;
1802 void add(
const std::string& address);
1814 friend class CppServerFriend;
1818 Server(
void* self): self(self) {}
1829 Server(
Server&& other) noexcept : self(other.self) { other.self =
nullptr; }
Filter used to restrict which IP addresses may communicate with a server.
Definition: rodbus.hpp:1763
AddressFilter(AddressFilter &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:1779
static AddressFilter any()
Create an address filter that accepts any IP address.
AddressFilter(const std::string &address)
Create an address filter that matches one or more IP addresses. Ipv4 or IPv6 addresses are allowed.
~AddressFilter()
Destroy an address filter.
void add(const std::string &address)
Add an allowed IP address to the filter.
User implemented interface defines which request and roles are allowed for different functions when i...
Definition: rodbus.hpp:1690
virtual Authorization read_coils(uint8_t unit_id, const AddressRange &range, const char *role)=0
Authorize a Read Coils request.
virtual Authorization write_multiple_coils(uint8_t unit_id, const AddressRange &range, const char *role)=0
Authorize a Write Multiple Coils request.
virtual Authorization read_discrete_inputs(uint8_t unit_id, const AddressRange &range, const char *role)=0
Authorize a Read Discrete Inputs request.
virtual Authorization read_holding_registers(uint8_t unit_id, const AddressRange &range, const char *role)=0
Authorize a Read Holding Registers request.
virtual Authorization write_multiple_registers(uint8_t unit_id, const AddressRange &range, const char *role)=0
Authorize a Write Multiple Registers request.
virtual Authorization write_single_register(uint8_t unit_id, uint16_t index, const char *role)=0
Authorize a Write Single Register request.
virtual Authorization write_single_coil(uint8_t unit_id, uint16_t index, const char *role)=0
Authorize a Write Single Coil request.
virtual Authorization read_input_registers(uint8_t unit_id, const AddressRange &range, const char *role)=0
Authorize a Read Input Registers request.
Callbacks received when reading coils or discrete inputs.
Definition: rodbus.hpp:1082
virtual void on_complete(BitValueIterator &result)=0
Invoked when the asynchronous operation completes successfully.
virtual void on_failure(RequestError error)=0
Invoked when the asynchronous operation fails.
Iterator over BitValue instances.
Definition: rodbus.hpp:436
BitValueIterator(BitValueIterator &&)=default
move constructor for the iterator
BitValue get()
retrieve the current value
bool next()
move the iterator to the next value
Abstract representation of a client communication channel.
Definition: rodbus.hpp:1141
static ClientChannel create_tls(Runtime &runtime, const std::string &host, uint16_t port, uint16_t max_queued_requests, const RetryStrategy &retry_strategy, const TlsClientConfig &tls_config, const DecodeLevel &decode_level, std::unique_ptr< ClientStateListener > listener)
Create a new TLS channel instance.
static ClientChannel create_rtu(Runtime &runtime, const std::string &path, const SerialPortSettings &serial_params, uint16_t max_queued_requests, const RetryStrategy &retry_strategy, const DecodeLevel &decode_level, std::unique_ptr< PortStateListener > listener)
Create a new RTU channel instance.
static ClientChannel create_tcp(Runtime &runtime, const std::string &host, uint16_t port, uint16_t max_queued_requests, const RetryStrategy &retry_strategy, const DecodeLevel &decode_level, std::unique_ptr< ClientStateListener > listener)
Create a new TCP channel instance.
void read_input_registers(const RequestParam ¶m, const AddressRange &range, std::unique_ptr< RegisterReadCallback > callback)
Start an asynchronous request to read input registers.
void set_decode_level(const DecodeLevel &level)
Set the decoding level for the channel.
void enable()
Enable channel communications.
void write_multiple_registers(const RequestParam ¶m, uint16_t start, const std::vector< uint16_t > &items, std::unique_ptr< WriteCallback > callback)
Write multiple registers.
void read_discrete_inputs(const RequestParam ¶m, const AddressRange &range, std::unique_ptr< BitReadCallback > callback)
Start an asynchronous request to read discrete inputs.
void read_coils(const RequestParam ¶m, const AddressRange &range, std::unique_ptr< BitReadCallback > callback)
Start an asynchronous request to read coils.
void disable()
Disable channel communications.
void write_single_register(const RequestParam ¶m, const RegisterValue &value, std::unique_ptr< WriteCallback > callback)
Write a single register.
void read_holding_registers(const RequestParam ¶m, const AddressRange &range, std::unique_ptr< RegisterReadCallback > callback)
Start an asynchronous request to read holding registers.
void write_single_coil(const RequestParam ¶m, const BitValue &value, std::unique_ptr< WriteCallback > callback)
Write a single coil.
~ClientChannel()
Shutdown a ClientChannel and release all resources.
ClientChannel(ClientChannel &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:1157
void write_multiple_coils(const RequestParam ¶m, uint16_t start, const std::vector< bool > &items, std::unique_ptr< WriteCallback > callback)
Write multiple coils.
Callback for monitoring the state of a TCP/TLS connection state.
Definition: rodbus.hpp:963
virtual void on_change(ClientState state)=0
Called when the client state changed.
Callback used to access the internal database while it is locked.
Definition: rodbus.hpp:1436
virtual void callback(Database &database)=0
callback function
Class used to add, remove, update, and retrieve values.
Definition: rodbus.hpp:1306
uint16_t get_input_register(uint16_t index)
Get the current input register value of the database.
uint16_t get_holding_register(uint16_t index)
Get the current holding register value of the database.
bool update_input_register(uint16_t index, uint16_t value)
Update the current value of a input register in the database.
bool add_coil(uint16_t index, bool value)
Add a new coil to the database.
bool add_input_register(uint16_t index, uint16_t value)
Add a new input register to the database.
bool get_discrete_input(uint16_t index)
Get the current discrete input value of the database.
bool update_coil(uint16_t index, bool value)
Update the current value of a coil in the database.
bool delete_discrete_input(uint16_t index)
Remove a discrete input address from the database.
bool update_discrete_input(uint16_t index, bool value)
Update the current value of a discrete input in the database.
bool add_holding_register(uint16_t index, uint16_t value)
Add a new holding register to the database.
Database(Database &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:1322
bool delete_input_register(uint16_t index)
Remove a input register address from the database.
bool add_discrete_input(uint16_t index, bool value)
Add a new discrete input to the database.
bool delete_holding_register(uint16_t index)
Remove a holding register address from the database.
bool delete_coil(uint16_t index)
Remove a coil address from the database.
bool update_holding_register(uint16_t index, uint16_t value)
Update the current value of a holding register in the database.
bool get_coil(uint16_t index)
Get the current coil value of the database.
Maps endpoint handlers to Modbus address.
Definition: rodbus.hpp:1588
bool add_endpoint(uint8_t unit_id, std::unique_ptr< WriteHandler > handler, DatabaseCallback &configure)
Add an endpoint to the map.
DeviceMap()
Create a device map that will be used to bind devices to a server endpoint.
DeviceMap(DeviceMap &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:1604
~DeviceMap()
Destroy a previously created device map.
Logging interface that receives the log messages and writes them somewhere.
Definition: rodbus.hpp:811
virtual void on_message(LogLevel level, const char *message)=0
Called when a log message was received and should be logged.
Provides a static method for configuring logging.
Definition: rodbus.hpp:860
static void configure(const LoggingConfig &config, std::unique_ptr< Logger > logger)
Set the callback that will receive all the log messages.
Exception type corresponding to the underlying error enum ParamError.
Definition: rodbus.hpp:95
ParamException(ParamError error)
construct the exception with an instance of the enum
Definition: rodbus.hpp:100
ParamError error
underlying error enum
Definition: rodbus.hpp:98
Callback interface for receiving updates about the state of a serial port.
Definition: rodbus.hpp:1031
virtual void on_change(PortState state)=0
Invoked when the serial port changes state.
Callbacks received when reading holding or input registers.
Definition: rodbus.hpp:1103
virtual void on_complete(RegisterValueIterator &result)=0
Invoked when the asynchronous operation completes successfully.
virtual void on_failure(RequestError error)=0
Invoked when the asynchronous operation fails.
Iterator over RegisterValue instances.
Definition: rodbus.hpp:481
bool next()
move the iterator to the next value
RegisterValue get()
retrieve the current value
RegisterValueIterator(RegisterValueIterator &&)=default
move constructor for the iterator
Exception type corresponding to the underlying error enum RequestError.
Definition: rodbus.hpp:373
RequestError error
underlying error enum
Definition: rodbus.hpp:376
RequestException(RequestError error)
construct the exception with an instance of the enum
Definition: rodbus.hpp:378
Handle to the underlying runtime.
Definition: rodbus.hpp:280
~Runtime()
Destroy a runtime.
void set_shutdown_timeout(std::chrono::steady_clock::duration timeout)
By default, when the runtime shuts down, it does so without a timeout and waits indefinitely for all ...
Runtime(const RuntimeConfig &config)
Creates a new runtime for running the protocol stack.
Runtime(Runtime &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:296
Handle to the running server. The server runs on a background task until this class is destroyed.
Definition: rodbus.hpp:1813
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 an...
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.
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.
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.
~Server()
Shutdown and release all resources of a running server.
void set_decode_level(const DecodeLevel &level)
Set the decoding level for the server.
Server(Server &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:1829
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.
Callback methods received from asynchronous write operations.
Definition: rodbus.hpp:1122
virtual void on_complete(Nothing result)=0
Invoked when the asynchronous operation completes successfully.
virtual void on_failure(RequestError error)=0
Invoked when the asynchronous operation fails.
Interface used to handle write requests received from the client.
Definition: rodbus.hpp:1547
virtual WriteResult write_multiple_registers(uint16_t start, RegisterValueIterator &it, Database &database)=0
Write multiple registers received from the client.
virtual WriteResult write_single_register(uint16_t index, uint16_t value, Database &database)=0
write a single register received from the client
virtual WriteResult write_single_coil(uint16_t index, bool value, Database &database)=0
Write a single coil received from the client.
virtual WriteResult write_multiple_coils(uint16_t start, BitValueIterator &it, Database &database)=0
Write multiple coils received from the client.
class that implements ClientStateListener in terms of a lambda expression
Definition: rodbus.hpp:980
ClientStateListenerLambda(const T &lambda)
constructor
Definition: rodbus.hpp:988
void on_change(ClientState state) override
implement virtual method from base class
Definition: rodbus.hpp:991
class that implements DatabaseCallback in terms of a lambda expression
Definition: rodbus.hpp:1453
void callback(Database &database) override
implement virtual method from base class
Definition: rodbus.hpp:1464
DatabaseCallbackLambda(const T &lambda)
constructor
Definition: rodbus.hpp:1461
class that implements Logger in terms of a lambda expression
Definition: rodbus.hpp:830
void on_message(LogLevel level, const char *message) override
implement virtual method from base class
Definition: rodbus.hpp:841
LoggerLambda(const T &lambda)
constructor
Definition: rodbus.hpp:838
class that implements PortStateListener in terms of a lambda expression
Definition: rodbus.hpp:1048
void on_change(PortState state) override
implement virtual method from base class
Definition: rodbus.hpp:1059
PortStateListenerLambda(const T &lambda)
constructor
Definition: rodbus.hpp:1056
std::unique_ptr< ClientStateListener > client_state_listener(const T &lambda)
construct an implementation of ClientStateListener based on a lambda expression
Definition: rodbus.hpp:1002
DatabaseCallbackLambda< T > database_callback(const T &lambda)
construct an implementation of DatabaseCallback based on a lambda expression
Definition: rodbus.hpp:1475
std::unique_ptr< PortStateListener > port_state_listener(const T &lambda)
construct an implementation of PortStateListener based on a lambda expression
Definition: rodbus.hpp:1070
std::unique_ptr< Logger > logger(const T &lambda)
construct an implementation of Logger based on a lambda expression
Definition: rodbus.hpp:852
main namespace for the rodbus library
Definition: rodbus.hpp:31
Parity
Parity checking modes.
Definition: rodbus.hpp:575
@ odd
Parity bit sets odd number of 1 bits.
@ even
Parity bit sets even number of 1 bits.
RequestError
Error information returned from asynchronous functions calls.
Definition: rodbus.hpp:324
@ modbus_exception_gateway_path_unavailable
Specialized use in conjunction with gateways, indicates that the gateway was unable to allocate an in...
@ modbus_exception_server_device_busy
Specialized use in conjunction with programming commands. The server is engaged in processing a long-...
@ no_connection
The channel had no connection (or open serial port) for the request: it was disabled,...
@ modbus_exception_server_device_failure
An unrecoverable error occurred while the server was attempting to perform the requested action.
@ bad_request
The request was invalid.
@ modbus_exception_illegal_data_value
A value contained in the request is not an allowable value for server.
@ internal_error
An unspecified internal error occurred while performing the request.
@ response_timeout
No valid response was received before the timeout.
@ bad_framing
A framing error was detected while performing the request.
@ modbus_exception_memory_parity_error
Specialized use in conjunction with function codes 20 and 21 and reference type 6,...
@ modbus_exception_unknown
The status code is not defined in the Modbus specification, refer to the raw exception code to see wh...
@ modbus_exception_illegal_data_address
The data address received in the query is not an allowable address for the server.
@ bad_response
The response from the server was received but was improperly formatted.
@ bad_argument
An invalid argument was supplied and the request could not be performed.
@ modbus_exception_gateway_target_device_failed_to_respond
Specialized use in conjunction with gateways, indicates that no response was obtained from the target...
@ modbus_exception_acknowledge
Specialized use in conjunction with programming commands. The server has accepted the request and is ...
@ io_error
An I/O error occurred on the underlying stream while performing the request.
@ modbus_exception_illegal_function
The data address received in the query is not an allowable address for the server.
ParamError
Error type that indicates a bad parameter or bad programmer logic.
Definition: rodbus.hpp:44
@ bad_tls_config
Bad TLS configuration.
@ invalid_local_certificate
Invalid local certificate file.
@ no_support
The FFI library was compiled without support for this feature.
@ server_bind_error
Server failed to bind to the specified port.
@ ok
Success, i.e. no error occurred.
@ shutdown
The task has been shutdown.
@ invalid_dns_name
Invalid DNS name.
@ invalid_ip_address
Invalid IP address.
@ invalid_range
Invalid Modbus address range.
@ invalid_unit_id
The specified unit id is not associated to this server.
@ invalid_request
Invalid Modbus request.
@ null_parameter
Null parameter.
@ too_many_requests
Number of requests exceeds configured limit.
@ invalid_peer_certificate
Invalid peer certificate file.
@ invalid_private_key
Invalid private key file.
@ invalid_utf8
String argument was not valid UTF-8.
@ runtime_cannot_block_within_async
Runtime cannot execute blocking call within asynchronous context.
@ runtime_creation_failure
Failed to create Tokio runtime.
@ invalid_index
Invalid index.
@ runtime_destroyed
Runtime was already disposed of.
@ logging_already_configured
Logging can only be configured once.
ClientState
State of the client connection.
Definition: rodbus.hpp:940
@ connected
Client is connected to the remote device.
@ disabled
Client is disabled and idle until enabled.
@ wait_after_failed_connect
Failed to establish a connection, waiting before retrying.
@ connecting
Client is trying to establish a connection to the remote device.
@ wait_after_disconnect
Client was disconnected, waiting before retrying.
CertificateMode
Determines how the certificate(s) presented by the peer are validated.
Definition: rodbus.hpp:665
@ authority_based
Validates the peer certificate against one or more configured trust anchors.
@ self_signed
Validates that the peer presents a single certificate which is a byte-for-byte match against the conf...
AppDecodeLevel
Controls how transmitted and received message at the application layer are decoded at the INFO log le...
Definition: rodbus.hpp:117
@ function_code
Decode the function code only.
@ data_values
Decode the function code, the general description of the data and the actual data values.
@ data_headers
Decode the function code and the general description of the data.
LogLevel
Log level.
Definition: rodbus.hpp:719
@ debug
Debugging log level.
@ info
Information log level.
MinTlsVersion
Minimum TLS version to allow.
Definition: rodbus.hpp:648
@ v12
Allow TLS 1.2 and TLS 1.3.
Authorization
Authorization result used by AuthorizationHandler.
Definition: rodbus.hpp:1675
@ deny
Client is NOT authorized to perform the operation.
@ allow
Client is authorized to perform the operation.
constexpr uint64_t rodbus_version_major
major version number
Definition: rodbus.hpp:34
constexpr uint64_t rodbus_version_minor
minor version number
Definition: rodbus.hpp:36
PortState
State of the serial port.
Definition: rodbus.hpp:1012
@ wait
Waiting to perform an open retry.
Nothing
A single value enum which is used as a placeholder for futures that don't return a value.
Definition: rodbus.hpp:104
@ nothing
the only value this enum has
constexpr char const * rodbus_version_string
version number as the string major.minor.patch
Definition: rodbus.hpp:40
FlowControl
Flow control modes.
Definition: rodbus.hpp:560
@ hardware
Flow control using RTS/CTS signals.
@ software
Flow control using XON/XOFF bytes.
const char * to_string(ParamError value)
convert an instance of enum ParamError into a C-style string
DataBits
Number of bits per character.
Definition: rodbus.hpp:543
@ eight
8 bits per character
@ five
5 bits per character
@ seven
7 bits per character
@ six
6 bits per character
LogOutputFormat
Describes how each log event is formatted.
Definition: rodbus.hpp:740
@ text
A simple text-based format.
@ json
Output formatted as JSON.
ModbusException
Error information returned during asynchronous API calls.
Definition: rodbus.hpp:514
@ server_device_failure
An unrecoverable error occurred while the server was attempting to perform the requested action.
@ gateway_target_device_failed_to_respond
Specialized use in conjunction with gateways, indicates that no response was obtained from the target...
@ illegal_data_address
The data address received in the query is not an allowable address for the server.
@ server_device_busy
Specialized use in conjunction with programming commands. The server is engaged in processing a long-...
@ gateway_path_unavailable
Specialized use in conjunction with gateways, indicates that the gateway was unable to allocate an in...
@ acknowledge
Specialized use in conjunction with programming commands. The server has accepted the request and is ...
@ illegal_function
The data address received in the query is not an allowable address for the server.
@ unknown
The status code is not defined in the Modbus specification, refer to the raw exception code to see wh...
@ memory_parity_error
Specialized use in conjunction with function codes 20 and 21 and reference type 6,...
@ illegal_data_value
A value contained in the request is not an allowable value for server.
FrameDecodeLevel
Controls how the transmitted and received frames are decoded at the INFO log level.
Definition: rodbus.hpp:138
@ header
Decode the header.
@ payload
Decode the header and the raw payload as hexadecimal.
PhysDecodeLevel
Controls how data transmitted at the physical layer (TCP, serial, etc) is logged.
Definition: rodbus.hpp:153
@ length
Log only the length of data that is sent and received.
@ data
Log the length and the actual data that is sent and received.
constexpr uint64_t rodbus_version_patch
patch version number
Definition: rodbus.hpp:38
StopBits
Number of stop bits.
Definition: rodbus.hpp:590
TimeFormat
Describes if and how the time will be formatted in log messages.
Definition: rodbus.hpp:753
@ system
Format the time in a human readable format e.g. 'Jun 25 14:27:12.955'.
@ rfc_3339
Format the time using RFC 3339.
Range of 16-bit addresses sent in a request from the client to the server.
Definition: rodbus.hpp:384
AddressRange(uint16_t start, uint16_t count)
Fully construct AddressRange specifying the value of each field.
uint16_t count
Number of addresses in the range.
Definition: rodbus.hpp:399
uint16_t start
Starting address of the range.
Definition: rodbus.hpp:397
Bit value and its address.
Definition: rodbus.hpp:207
BitValue(uint16_t index, bool value)
Fully construct BitValue specifying the value of each field.
bool value
Value of the bit.
Definition: rodbus.hpp:222
uint16_t index
Address of the bit.
Definition: rodbus.hpp:220
Controls the decoding of transmitted and received data at the application, frame, and physical layer.
Definition: rodbus.hpp:170
PhysDecodeLevel physical
Controls the logging of physical layer read/write.
Definition: rodbus.hpp:199
AppDecodeLevel app
Controls decoding of the application layer (PDU)
Definition: rodbus.hpp:195
static DecodeLevel nothing()
Initialize log levels to defaults which is to decode nothing.
DecodeLevel(AppDecodeLevel app, FrameDecodeLevel frame, PhysDecodeLevel physical)
Fully construct DecodeLevel specifying the value of each field.
FrameDecodeLevel frame
Controls decoding of frames (MBAP / Serial PDU)
Definition: rodbus.hpp:197
Logging configuration options.
Definition: rodbus.hpp:768
bool print_level
optionally print the log level as part to the message string
Definition: rodbus.hpp:803
LogLevel level
logging level
Definition: rodbus.hpp:797
LoggingConfig()
Initialize the configuration to default values.
LogOutputFormat output_format
output formatting options
Definition: rodbus.hpp:799
TimeFormat time_format
optional time format
Definition: rodbus.hpp:801
bool print_module_info
optionally print the underlying Rust module information to the message string
Definition: rodbus.hpp:805
Register value and its address.
Definition: rodbus.hpp:230
uint16_t value
Value of the register.
Definition: rodbus.hpp:245
uint16_t index
Address of the register.
Definition: rodbus.hpp:243
RegisterValue(uint16_t index, uint16_t value)
Fully construct RegisterValue specifying the value of each field.
Address and timeout parameters for requests.
Definition: rodbus.hpp:405
RequestParam(uint8_t unit_id, std::chrono::steady_clock::duration timeout)
Fully construct RequestParam specifying the value of each field.
uint8_t unit_id
Modbus address for the request.
Definition: rodbus.hpp:418
std::chrono::steady_clock::duration timeout
Response timeout for the request. It covers sending the request and receiving the response....
Definition: rodbus.hpp:420
Retry strategy configuration.
Definition: rodbus.hpp:688
std::chrono::steady_clock::duration max_delay
Maximum delay between two retries.
Definition: rodbus.hpp:713
RetryStrategy()
Initialize a retry strategy to defaults.
std::chrono::steady_clock::duration min_delay
Minimum delay between two retries.
Definition: rodbus.hpp:711
Runtime configuration.
Definition: rodbus.hpp:253
RuntimeConfig()
Initialize the configuration to default values.
uint16_t num_core_threads
Number of runtime threads to spawn. For a guess of the number of CPU cores, use 0.
Definition: rodbus.hpp:276
Serial port settings.
Definition: rodbus.hpp:605
DataBits data_bits
Number of bits used to represent a character sent on the line.
Definition: rodbus.hpp:638
uint32_t baud_rate
Baud rate (in symbols-per-second)
Definition: rodbus.hpp:636
SerialPortSettings()
Initialize a serial port configuration.
FlowControl flow_control
Type of signalling to use for controlling data transfer.
Definition: rodbus.hpp:640
StopBits stop_bits
Number of bits to use to signal the end of a character.
Definition: rodbus.hpp:644
Parity parity
Type of parity to use for error checking.
Definition: rodbus.hpp:642
TLS client configuration.
Definition: rodbus.hpp:880
TlsClientConfig(const std::string &dns_name, const std::string &peer_cert_path, const std::string &local_cert_path, const std::string &private_key_path, const std::string &password)
Initialize a TLS client configuration.
std::string private_key_path
Path to the PEM-encoded private key.
Definition: rodbus.hpp:922
std::string peer_cert_path
Path to the PEM-encoded trusted CA certificate(s) in CertificateMode::authority_based mode,...
Definition: rodbus.hpp:918
CertificateMode certificate_mode
Certificate validation mode.
Definition: rodbus.hpp:932
std::string dns_name
Name expected to be in the presented certificate (only in CertificateMode::authority_based)
Definition: rodbus.hpp:916
MinTlsVersion min_tls_version
Minimum TLS version allowed.
Definition: rodbus.hpp:930
bool allow_server_name_wildcard
If set to true, a '*' may be used for TlsClientConfig::dns_name to bypass server name validation.
Definition: rodbus.hpp:934
std::string password
Optional password if the private key file is encrypted.
Definition: rodbus.hpp:928
std::string local_cert_path
Path to the PEM-encoded local certificate.
Definition: rodbus.hpp:920
TLS server configuration.
Definition: rodbus.hpp:1625
std::string peer_cert_path
Path to the PEM-encoded trusted CA certificate(s) in CertificateMode::authority_based mode,...
Definition: rodbus.hpp:1657
CertificateMode certificate_mode
Certificate validation mode.
Definition: rodbus.hpp:1671
std::string local_cert_path
Path to the PEM-encoded local certificate.
Definition: rodbus.hpp:1659
TlsServerConfig(const std::string &peer_cert_path, const std::string &local_cert_path, const std::string &private_key_path, const std::string &password)
Initialize a TLS server configuration.
std::string private_key_path
Path to the PEM-encoded private key.
Definition: rodbus.hpp:1661
MinTlsVersion min_tls_version
Minimum TLS version allowed.
Definition: rodbus.hpp:1669
std::string password
Optional password if the private key file is encrypted.
Definition: rodbus.hpp:1667
Describes to the server if a write operation was successful or not.
Definition: rodbus.hpp:1489
static WriteResult raw_exception_init(uint8_t raw_exception)
Initialize a WriteResult to indicate a non-standard Modbus exception.
static WriteResult success_init()
Initialize a WriteResult to indicate a successful write operation.
ModbusException exception
Exception enumeration. If ModbusException::unknown, look at the raw value.
Definition: rodbus.hpp:1539
uint8_t raw_exception
Raw exception value when WriteResult::exception field is ModbusException::unknown
Definition: rodbus.hpp:1541
bool success
true if the operation was successful, false otherwise. Error details found in the exception field.
Definition: rodbus.hpp:1537
static WriteResult exception_init(ModbusException exception)
Initialize a WriteResult to indicate a standard Modbus exception.