libserialport
unreleased development snapshot
cross-platform library for accessing serial ports
|
Reading, writing, and flushing data. More...
Functions | |
enum sp_return | sp_blocking_read (struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms) |
Read bytes from the specified serial port, blocking until complete. More... | |
enum sp_return | sp_blocking_read_next (struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms) |
Read bytes from the specified serial port, returning as soon as any data is available. More... | |
enum sp_return | sp_nonblocking_read (struct sp_port *port, void *buf, size_t count) |
Read bytes from the specified serial port, without blocking. More... | |
enum sp_return | sp_blocking_write (struct sp_port *port, const void *buf, size_t count, unsigned int timeout_ms) |
Write bytes to the specified serial port, blocking until complete. More... | |
enum sp_return | sp_nonblocking_write (struct sp_port *port, const void *buf, size_t count) |
Write bytes to the specified serial port, without blocking. More... | |
enum sp_return | sp_input_waiting (struct sp_port *port) |
Gets the number of bytes waiting in the input buffer. More... | |
enum sp_return | sp_output_waiting (struct sp_port *port) |
Gets the number of bytes waiting in the output buffer. More... | |
enum sp_return | sp_flush (struct sp_port *port, enum sp_buffer buffers) |
Flush serial port buffers. More... | |
enum sp_return | sp_drain (struct sp_port *port) |
Wait for buffered data to be transmitted. More... | |
Reading, writing, and flushing data.
See send_receive.c for an example of sending and receiving data.
enum sp_return sp_blocking_read | ( | struct sp_port * | port, |
void * | buf, | ||
size_t | count, | ||
unsigned int | timeout_ms | ||
) |
Read bytes from the specified serial port, blocking until complete.
[in] | port | Pointer to a port structure. Must not be NULL. |
[out] | buf | Buffer in which to store the bytes read. Must not be NULL. |
[in] | count | Requested number of bytes to read. |
[in] | timeout_ms | Timeout in milliseconds, or zero to wait indefinitely. |
enum sp_return sp_blocking_read_next | ( | struct sp_port * | port, |
void * | buf, | ||
size_t | count, | ||
unsigned int | timeout_ms | ||
) |
Read bytes from the specified serial port, returning as soon as any data is available.
[in] | port | Pointer to a port structure. Must not be NULL. |
[out] | buf | Buffer in which to store the bytes read. Must not be NULL. |
[in] | count | Maximum number of bytes to read. Must not be zero. |
[in] | timeout_ms | Timeout in milliseconds, or zero to wait indefinitely. |
enum sp_return sp_blocking_write | ( | struct sp_port * | port, |
const void * | buf, | ||
size_t | count, | ||
unsigned int | timeout_ms | ||
) |
Write bytes to the specified serial port, blocking until complete.
Note that this function only ensures that the accepted bytes have been written to the OS; they may be held in driver or hardware buffers and not yet physically transmitted. To check whether all written bytes have actually been transmitted, use the sp_output_waiting() function. To wait until all written bytes have actually been transmitted, use the sp_drain() function.
[in] | port | Pointer to a port structure. Must not be NULL. |
[in] | buf | Buffer containing the bytes to write. Must not be NULL. |
[in] | count | Requested number of bytes to write. |
[in] | timeout_ms | Timeout in milliseconds, or zero to wait indefinitely. |
Wait for buffered data to be transmitted.
[in] | port | Pointer to a port structure. Must not be NULL. |
Flush serial port buffers.
Data in the selected buffer(s) is discarded.
[in] | port | Pointer to a port structure. Must not be NULL. |
[in] | buffers | Which buffer(s) to flush. |
Gets the number of bytes waiting in the input buffer.
[in] | port | Pointer to a port structure. Must not be NULL. |
Read bytes from the specified serial port, without blocking.
[in] | port | Pointer to a port structure. Must not be NULL. |
[out] | buf | Buffer in which to store the bytes read. Must not be NULL. |
[in] | count | Maximum number of bytes to read. |
Write bytes to the specified serial port, without blocking.
Note that this function only ensures that the accepted bytes have been written to the OS; they may be held in driver or hardware buffers and not yet physically transmitted. To check whether all written bytes have actually been transmitted, use the sp_output_waiting() function. To wait until all written bytes have actually been transmitted, use the sp_drain() function.
[in] | port | Pointer to a port structure. Must not be NULL. |
[in] | buf | Buffer containing the bytes to write. Must not be NULL. |
[in] | count | Maximum number of bytes to write. |