Skip to content
Start free evaluation

PdcommSecs1Write

Typedef

Writes bytes to the serial stream without blocking.

typedef uint32_t (*PdcommSecs1Write)(void *context, const uint8_t *buffer, size_t capacity, size_t *count)

Declared in: #include <pdcomm_secs1.h>

Called only from pdcomm_secs1_poll() on the endpoint's thread with at most PdcommSecs1Options::max_io_chunk bytes. Unwritten bytes are offered again on a later attempt. For every result other than #PDCOMM_SECS1_IO_OK, count is ignored.

Parameters

NameDescription
contextThe PdcommSecs1Io::context value.
bufferBytes to write.
capacityNumber of bytes at buffer; at least 1.
countReceives the number of bytes written. It is 0 on entry and is read only when the callback returns #PDCOMM_SECS1_IO_OK.

Returns

#PDCOMM_SECS1_IO_OK with *count bytes written (0 faults the endpoint with detail #PDCOMM_SECS1_IO_WRITE_ZERO); #PDCOMM_SECS1_IO_WOULD_BLOCK or #PDCOMM_SECS1_IO_INTERRUPTED when nothing was written; any other PDCOMM_SECS1_IO_* value to report a failure, which faults the endpoint.

Notes

  • Do not block and do not call endpoint functions from the callback. A count greater than capacity faults the endpoint with detail #PDCOMM_SECS1_IO_INVALID_DATA.
  • C++ implementations must catch every exception before returning; pdcomm_secs1.hpp provides a safe typed adapter.