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)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
| Name | Description |
|---|---|
context | The PdcommSecs1Io::context value. |
buffer | Bytes to write. |
capacity | Number of bytes at buffer; at least 1. |
count | Receives 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
capacityfaults 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.