177 friend class CppDecodeLevelFriend;
212 friend class CppBitValueFriend;
233 friend class CppRegisterValueFriend;
256 friend class CppRuntimeConfigFriend;
283 friend class CppRuntimeFriend;
287 Runtime(
void* self): self(self) {}
387 friend class CppAddressRangeFriend;
408 friend class CppRequestParamFriend;
440 friend class CppBitValueIteratorFriend;
485 friend class CppRegisterValueIteratorFriend;
608 friend class CppSerialPortSettingsFriend;
687 friend class CppRetryStrategyFriend;
767 friend class CppLoggingConfigFriend;
822namespace functional {
829 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
841 lambda(level, message);
850std::unique_ptr<Logger>
logger(
const T& lambda)
852 return std::make_unique<LoggerLambda<T>>(lambda); ;
879 friend class CppTlsClientConfigFriend;
972namespace functional {
979 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
1002 return std::make_unique<ClientStateListenerLambda<T>>(lambda); ;
1040namespace functional {
1047 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
1070 return std::make_unique<PortStateListenerLambda<T>>(lambda); ;
1136 friend class CppClientChannelFriend;
1295 friend class CppDatabaseFriend;
1299 Database(
void* self): self(self) {}
1435namespace functional {
1442 static_assert(std::is_copy_constructible<T>::value,
"Lambda expression must be copy constructible. Does it contain something that is move-only?");
1478 friend class CppWriteResultFriend;
1577 friend class CppDeviceMapFriend;
1614 friend class CppTlsServerConfigFriend;
1752 friend class CppAddressFilterFriend;
1788 void add(
const std::string& address);
1800 friend class CppServerFriend;
1804 Server(
void* self): self(self) {}
1815 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:1751
AddressFilter(AddressFilter &&other) noexcept
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
Definition: rodbus.hpp:1767
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:1678
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:1078
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:438
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:1135
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:1151
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:961
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:1424
virtual void callback(Database &database)=0
callback function
Class used to add, remove, update, and retrieve values.
Definition: rodbus.hpp:1294
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:1310
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:1576
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:1592
~DeviceMap()
Destroy a previously created device map.
Logging interface that receives the log messages and writes them somewhere.
Definition: rodbus.hpp:809
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:858
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:101
ParamException(ParamError error)
construct the exception with an instance of the enum
Definition: rodbus.hpp:106
ParamError error
underlying error enum
Definition: rodbus.hpp:104
Callback interface for receiving updates about the state of a serial port.
Definition: rodbus.hpp:1029
virtual void on_change(PortState state)=0
Invoked when the serial port changes state.
Callbacks received when reading reading holding or input registers.
Definition: rodbus.hpp:1097
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:483
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:375
RequestError error
underlying error enum
Definition: rodbus.hpp:378
RequestException(RequestError error)
construct the exception with an instance of the enum
Definition: rodbus.hpp:380
Handle to the underlying runtime.
Definition: rodbus.hpp:282
~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:298
Handle to the running server. The server runs on a background task until this class is destroyed.
Definition: rodbus.hpp:1799
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:1815
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:1116
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:1535
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 coil 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:978
ClientStateListenerLambda(const T &lambda)
constructor
Definition: rodbus.hpp:986
void on_change(ClientState state) override
implement virtual method from base class
Definition: rodbus.hpp:989
class that implements DatabaseCallback in terms of a lambda expression
Definition: rodbus.hpp:1441
void callback(Database &database) override
implement virtual method from base class
Definition: rodbus.hpp:1452
DatabaseCallbackLambda(const T &lambda)
constructor
Definition: rodbus.hpp:1449
class that implements Logger in terms of a lambda expression
Definition: rodbus.hpp:828
void on_message(LogLevel level, const char *message) override
implement virtual method from base class
Definition: rodbus.hpp:839
LoggerLambda(const T &lambda)
constructor
Definition: rodbus.hpp:836
class that implements PortStateListener in terms of a lambda expression
Definition: rodbus.hpp:1046
void on_change(PortState state) override
implement virtual method from base class
Definition: rodbus.hpp:1057
PortStateListenerLambda(const T &lambda)
constructor
Definition: rodbus.hpp:1054
std::unique_ptr< ClientStateListener > client_state_listener(const T &lambda)
construct an implementation of ClientStateListener based on a lambda expression
Definition: rodbus.hpp:1000
DatabaseCallbackLambda< T > database_callback(const T &lambda)
construct an implementation of DatabaseCallback based on a lambda expression
Definition: rodbus.hpp:1463
std::unique_ptr< PortStateListener > port_state_listener(const T &lambda)
construct an implementation of PortStateListener based on a lambda expression
Definition: rodbus.hpp:1068
std::unique_ptr< Logger > logger(const T &lambda)
construct an implementation of Logger based on a lambda expression
Definition: rodbus.hpp:850
main namespace for the rodbus library
Definition: rodbus.hpp:39
Parity
Parity checking modes.
Definition: rodbus.hpp:577
@ 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:326
@ 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
No connection could be made to the server.
@ 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:52
@ 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.
@ 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:938
@ 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:663
@ 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:123
@ 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:717
@ debug
Debugging log level.
@ info
Information log level.
MinTlsVersion
Minimum TLS version to allow.
Definition: rodbus.hpp:648
Authorization
Authorization result used by AuthorizationHandler.
Definition: rodbus.hpp:1663
@ 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:42
constexpr uint64_t rodbus_version_minor
minor version number
Definition: rodbus.hpp:44
PortState
State of the serial port.
Definition: rodbus.hpp:1010
@ 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:110
@ nothing
the only value this enum has
constexpr char const * rodbus_version_string
version number as the string major.minor.patch
Definition: rodbus.hpp:48
FlowControl
Flow control modes.
Definition: rodbus.hpp:562
@ 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:545
@ 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:738
@ text
A simple text-based format.
@ json
Output formatted as JSON.
ModbusException
Error information returned during asynchronous API calls.
Definition: rodbus.hpp:516
@ 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:144
@ 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:159
@ 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:46
StopBits
Number of stop bits.
Definition: rodbus.hpp:592
TimeFormat
Describes if and how the time will be formatted in log messages.
Definition: rodbus.hpp:751
@ 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:386
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:401
uint16_t start
Starting address of the range.
Definition: rodbus.hpp:399
Index/value tuple of a bit type.
Definition: rodbus.hpp:211
BitValue(uint16_t index, bool value)
Fully construct BitValue specifying the value of each field.
bool value
Value of the bit.
Definition: rodbus.hpp:226
uint16_t index
Index of bit.
Definition: rodbus.hpp:224
Controls the decoding of transmitted and received data at the application, frame, and physical layer.
Definition: rodbus.hpp:176
PhysDecodeLevel physical
Controls the logging of physical layer read/write.
Definition: rodbus.hpp:205
AppDecodeLevel app
Controls decoding of the application layer (PDU)
Definition: rodbus.hpp:201
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:203
Logging configuration options.
Definition: rodbus.hpp:766
bool print_level
optionally print the log level as part to the message string
Definition: rodbus.hpp:801
LogLevel level
logging level
Definition: rodbus.hpp:795
LoggingConfig()
Initialize the configuration to default values.
LogOutputFormat output_format
output formatting options
Definition: rodbus.hpp:797
TimeFormat time_format
optional time format
Definition: rodbus.hpp:799
bool print_module_info
optionally print the underlying Rust module information to the message string
Definition: rodbus.hpp:803
Index/value tuple of a register type.
Definition: rodbus.hpp:232
uint16_t value
Value of the register.
Definition: rodbus.hpp:247
uint16_t index
Index of register.
Definition: rodbus.hpp:245
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:407
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:420
std::chrono::steady_clock::duration timeout
Response timeout for the request.
Definition: rodbus.hpp:422
Retry strategy configuration.
Definition: rodbus.hpp:686
std::chrono::steady_clock::duration max_delay
Maximum delay between two retries.
Definition: rodbus.hpp:711
RetryStrategy()
Initialize a retry strategy to defaults.
std::chrono::steady_clock::duration min_delay
Minimum delay between two retries.
Definition: rodbus.hpp:709
Runtime configuration.
Definition: rodbus.hpp:255
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:278
Serial port settings.
Definition: rodbus.hpp:607
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:878
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 the PEM-encoded private key.
Definition: rodbus.hpp:920
std::string peer_cert_path
Path to the PEM-encoded certificate of the peer.
Definition: rodbus.hpp:916
CertificateMode certificate_mode
Certificate validation mode.
Definition: rodbus.hpp:930
std::string dns_name
Name expected to be in the presented certificate (only in CertificateMode::authority_based)
Definition: rodbus.hpp:914
MinTlsVersion min_tls_version
Minimum TLS version allowed.
Definition: rodbus.hpp:928
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:932
std::string password
Optional password if the private key file is encrypted.
Definition: rodbus.hpp:926
std::string local_cert_path
Path to the PEM-encoded local certificate.
Definition: rodbus.hpp:918
TLS server configuration.
Definition: rodbus.hpp:1613
std::string peer_cert_path
Path to the PEM-encoded certificate of the peer.
Definition: rodbus.hpp:1645
CertificateMode certificate_mode
Certficate validation mode.
Definition: rodbus.hpp:1659
std::string local_cert_path
Path to the PEM-encoded local certificate.
Definition: rodbus.hpp:1647
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 client configuration.
std::string private_key_path
Path to the the PEM-encoded private key.
Definition: rodbus.hpp:1649
MinTlsVersion min_tls_version
Minimum TLS version allowed.
Definition: rodbus.hpp:1657
std::string password
Optional password if the private key file is encrypted.
Definition: rodbus.hpp:1655
Describes to the server if a write operation was successful or not.
Definition: rodbus.hpp:1477
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:1527
uint8_t raw_exception
Raw exception value when WriteResult::exception field is ModbusException::unknown
Definition: rodbus.hpp:1529
bool success
true if the operation was successful, false otherwise. Error details found in the exception field.
Definition: rodbus.hpp:1525
static WriteResult exception_init(ModbusException exception)
Initialize a WriteResult to indicate a standard Modbus exception.