Skip to content
Start free evaluation

pdcomm::Secs1IoAdapter

Class

Owns a typed serial port and exposes it to a Secs1Endpoint through exception-safe callbacks.

template <typename Port> class Secs1IoAdapter

Declared in: #include <pdcomm_secs1.hpp>

The 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

NameDescription
PortNonblocking 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)

Declared in: #include <pdcomm_secs1.hpp>

Exceptions thrown by the Port constructor propagate to the caller.

Parameters

NameDescription
ArgumentsTypes of the Port constructor arguments.
argumentsArguments 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 &&) = delete

Declared in: #include <pdcomm_secs1.hpp>

Secs1IoAdapter

Constructor

Copying is disabled; the callback context is this adapter's address.

Secs1IoAdapter(const Secs1IoAdapter &) = delete

Declared in: #include <pdcomm_secs1.hpp>

native

Method

Returns the callback table that Secs1Endpoint passes to pdcomm_secs1_create().

const PdcommSecs1Io &native() const noexcept

Declared in: #include <pdcomm_secs1.hpp>

Returns

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 &&) = delete

Declared in: #include <pdcomm_secs1.hpp>

operator=

Method

Copy assignment is disabled; the callback context is this adapter's address.

Secs1IoAdapter &operator=(const Secs1IoAdapter &) = delete

Declared in: #include <pdcomm_secs1.hpp>

port

Method

Returns the owned port.

Port &port() noexcept

Declared in: #include <pdcomm_secs1.hpp>

Do 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 noexcept

Declared in: #include <pdcomm_secs1.hpp>

Returns

The port; valid as long as the adapter lives.