rodbus (C++ API) 1.3.1
|
Abstract representation of a client communication channel. More...
#include <rodbus.hpp>
Public Member Functions | |
ClientChannel (ClientChannel &&other) noexcept | |
Transfer ownership of the underlying C-type to this instance and invalidate the other instance. More... | |
~ClientChannel () | |
Shutdown a ClientChannel and release all resources. More... | |
void | enable () |
Enable channel communications. More... | |
void | disable () |
Disable channel communications. More... | |
void | set_decode_level (const DecodeLevel &level) |
Set the decoding level for the channel. More... | |
void | read_coils (const RequestParam ¶m, const AddressRange &range, std::unique_ptr< BitReadCallback > callback) |
Start an asynchronous request to read coils. More... | |
void | read_discrete_inputs (const RequestParam ¶m, const AddressRange &range, std::unique_ptr< BitReadCallback > callback) |
Start an asynchronous request to read discrete inputs. More... | |
void | read_holding_registers (const RequestParam ¶m, const AddressRange &range, std::unique_ptr< RegisterReadCallback > callback) |
Start an asynchronous request to read holding registers. More... | |
void | read_input_registers (const RequestParam ¶m, const AddressRange &range, std::unique_ptr< RegisterReadCallback > callback) |
Start an asynchronous request to read input registers. More... | |
void | write_single_coil (const RequestParam ¶m, const BitValue &value, std::unique_ptr< WriteCallback > callback) |
Write a single coil. More... | |
void | write_single_register (const RequestParam ¶m, const RegisterValue &value, std::unique_ptr< WriteCallback > callback) |
Write a single register. More... | |
void | write_multiple_coils (const RequestParam ¶m, uint16_t start, const std::vector< bool > &items, std::unique_ptr< WriteCallback > callback) |
Write multiple coils. More... | |
void | write_multiple_registers (const RequestParam ¶m, uint16_t start, const std::vector< uint16_t > &items, std::unique_ptr< WriteCallback > callback) |
Write multiple registers. More... | |
Static Public Member Functions | |
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. More... | |
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. More... | |
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. More... | |
Friends | |
class | CppClientChannelFriend |
Abstract representation of a client communication channel.
The underlying channel may be TCP, TLS, or serial.
|
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::ClientChannel::~ClientChannel | ( | ) |
Shutdown a ClientChannel and release all resources.
|
static |
Create a new RTU channel instance.
runtime | runtime on which to create the channel |
path | Path to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows. |
serial_params | Serial port settings |
max_queued_requests | Maximum number of requests to queue before failing the next request |
retry_strategy | Strategy which controls how long to wait between attempts to open the serial port after failures |
decode_level | Decode levels for this client |
listener | Listener used to receive updates on the status of the serial port |
ParamException |
|
static |
Create a new TCP channel instance.
runtime | Runtime on which to create the channel |
host | IP (v4/v6) or host name remote endpoint |
port | remote port |
max_queued_requests | Maximum number of requests to queue before failing the next request |
retry_strategy | Reconnection timing strategy |
decode_level | Decode levels for this client |
listener | TCP connection listener used to receive updates on the status of the channel |
ParamException |
|
static |
Create a new TLS channel instance.
runtime | Runtime on which to create the channel |
host | IP (v4/v6) or host name remote endpoint |
port | remote port |
max_queued_requests | Maximum number of requests to queue before failing the next request |
retry_strategy | Reconnection timing strategy |
tls_config | TLS client configuration |
decode_level | Decode levels for this client |
listener | TCP connection listener used to receive updates on the status of the channel |
NULL
if an error occurred ParamException |
void rodbus::ClientChannel::disable | ( | ) |
Disable channel communications.
ParamException |
void rodbus::ClientChannel::enable | ( | ) |
Enable channel communications.
ParamException |
void rodbus::ClientChannel::read_coils | ( | const RequestParam & | param, |
const AddressRange & | range, | ||
std::unique_ptr< BitReadCallback > | callback | ||
) |
Start an asynchronous request to read coils.
param | Parameters for the request |
range | Range of addresses to read |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::read_discrete_inputs | ( | const RequestParam & | param, |
const AddressRange & | range, | ||
std::unique_ptr< BitReadCallback > | callback | ||
) |
Start an asynchronous request to read discrete inputs.
param | Parameters for the request |
range | Range of addresses to read |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::read_holding_registers | ( | const RequestParam & | param, |
const AddressRange & | range, | ||
std::unique_ptr< RegisterReadCallback > | callback | ||
) |
Start an asynchronous request to read holding registers.
param | Parameters for the request |
range | Range of addresses to read |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::read_input_registers | ( | const RequestParam & | param, |
const AddressRange & | range, | ||
std::unique_ptr< RegisterReadCallback > | callback | ||
) |
Start an asynchronous request to read input registers.
param | Parameters for the request |
range | Range of addresses to read |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::set_decode_level | ( | const DecodeLevel & | level | ) |
void rodbus::ClientChannel::write_multiple_coils | ( | const RequestParam & | param, |
uint16_t | start, | ||
const std::vector< bool > & | items, | ||
std::unique_ptr< WriteCallback > | callback | ||
) |
Write multiple coils.
param | Parameters for the request |
start | Starting address |
items | List of items to write |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::write_multiple_registers | ( | const RequestParam & | param, |
uint16_t | start, | ||
const std::vector< uint16_t > & | items, | ||
std::unique_ptr< WriteCallback > | callback | ||
) |
Write multiple registers.
param | Parameters for the request |
start | Starting address |
items | List of items to write |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::write_single_coil | ( | const RequestParam & | param, |
const BitValue & | value, | ||
std::unique_ptr< WriteCallback > | callback | ||
) |
Write a single coil.
param | Parameters for the request |
value | Address and value to write |
callback | callback invoked when the operation completes |
ParamException |
void rodbus::ClientChannel::write_single_register | ( | const RequestParam & | param, |
const RegisterValue & | value, | ||
std::unique_ptr< WriteCallback > | callback | ||
) |
Write a single register.
param | Parameters for the request |
value | Address and value to write |
callback | callback invoked when the operation completes |
ParamException |