pdcomm::Secs1IoAdapter
Class
Owns a typed serial port and exposes it to a Secs1Endpoint through exception-safe callbacks.
template <typename Port> class Secs1IoAdapterThe adapter constructs a Port in place and installs noexcept C ABI trampolines that call its read() and write() members. Every exception from Port::read/write is converted into an IO_OTHER result: the trampoline reports PDCOMM_SECS1_IO_OTHER with a count of 0, which faults the endpoint with PDCOMM_SECS1_FAULT_IO and detail PDCOMM_SECS1_IO_OTHER.
Port must provide these members, which return a PDCOMM_SECS1_IO_* result and must not block (see PdcommSecs1Read and PdcommSecs1Write for the full contract):
uint32_t read(uint8_t *buffer, size_t capacity, size_t *count);uint32_t write(const uint8_t *buffer, size_t capacity, size_t *count);
The endpoint calls them only inside Secs1Endpoint::poll(), on the endpoint's thread. They must not call endpoint members.
Parameters
| Name | Description |
|---|---|
Port | Nonblocking serial port type with the read() and write() members above. |
Notes
- Neither copyable nor movable, because the callback context is the adapter's own address. The adapter must outlive every Secs1Endpoint constructed from it.
Members
Secs1IoAdapter
Constructor
Constructs the port in place and fills the callback table.
template <typename... Arguments> explicit Secs1IoAdapter(Arguments &&...arguments)Exceptions thrown by the Port constructor propagate to the caller.
Parameters
| Name | Description |
|---|---|
Arguments | Types of the Port constructor arguments. |
arguments | Arguments forwarded to the Port constructor; pass none to default-construct the port. |
Secs1IoAdapter
Constructor
Moving is disabled; the callback context is this adapter's address.
Secs1IoAdapter(Secs1IoAdapter &&) = deleteSecs1IoAdapter
Constructor
Copying is disabled; the callback context is this adapter's address.
Secs1IoAdapter(const Secs1IoAdapter &) = deletenative
Method
Returns the callback table that Secs1Endpoint passes to pdcomm_secs1_create().
const PdcommSecs1Io &native() const noexceptReturns
The table; its context is this adapter. Valid as long as the adapter lives.
operator=
Method
Move assignment is disabled; the callback context is this adapter's address.
Secs1IoAdapter &operator=(Secs1IoAdapter &&) = deleteoperator=
Method
Copy assignment is disabled; the callback context is this adapter's address.
Secs1IoAdapter &operator=(const Secs1IoAdapter &) = deleteport
Method
Returns the owned port.
Port &port() noexceptDo not use the port concurrently with Secs1Endpoint::poll(), which calls it.
Returns
The port; valid as long as the adapter lives.
port
Method
Returns the owned port for read-only access.
const Port &port() const noexceptReturns
The port; valid as long as the adapter lives.