|
OpenSRX 0.1.0
C++ library for interfacing with Keyence SR series barcode readers
|
Templated base class for Asio-based communication interfaces. More...
#include <AsioInterface.hpp>
Public Member Functions | |
| ~AsioInterface () override=default | |
| std::string | sendCommand (const std::string &command) override |
| Sends a command over the Asio stream and reads the response. | |
| std::string | sendCommandUnlocked (const std::string &command) override |
| Sends a command without acquiring the communication mutex. | |
Public Member Functions inherited from OpenSRX::ICommInterface | |
| virtual | ~ICommInterface ()=default |
| virtual std::string | describe () const =0 |
| Return a human-readable description of this interface. | |
| void | setCommFormat (CommFormat format) |
| Set the communication framing format. | |
| CommFormat | getCommFormat () |
| Get the current communication framing format. | |
Protected Member Functions | |
| template<typename... Args> | |
| AsioInterface (Args &&... args) | |
| Construct an AsioInterface, forwarding arguments to the stream. | |
Protected Attributes | |
| asio::io_context | ioContext |
| StreamT | stream |
Protected Attributes inherited from OpenSRX::ICommInterface | |
| std::mutex | commMutex |
| Mutex to ensure thread-safe access to the communixcation interface. | |
Templated base class for Asio-based communication interfaces.
Provides the shared sendCommand implementation for any Asio stream type (e.g. asio::ip::tcp::socket, asio::serial_port). Subclasses only need to construct the stream and implement describe().
| StreamT | An Asio SyncReadStream & SyncWriteStream type. |
|
overridedefault |
|
inlineexplicitprotected |
Construct an AsioInterface, forwarding arguments to the stream.
| Args | Argument types forwarded to the StreamT constructor. |
| args | Arguments forwarded to the StreamT constructor. |
|
overridevirtual |
Sends a command over the Asio stream and reads the response.
This method acquires the communication mutex before sending, so it can be safely called from multiple threads. For blocking commands, sendCommandUnlocked() can be used to allow concurrent cancellation commands from another thread.
| command | The command string to send (without header/terminator). |
Implements OpenSRX::ICommInterface.
|
overridevirtual |
Sends a command without acquiring the communication mutex.
| command | The command string to send (without header/terminator). |
Implements OpenSRX::ICommInterface.
|
protected |
|
protected |