libserialport
unreleased development snapshot
cross-platform library for accessing serial ports
|
Waiting for events and timeout handling. More...
Functions | |
enum sp_return | sp_new_event_set (struct sp_event_set **result_ptr) |
Allocate storage for a set of events. More... | |
enum sp_return | sp_add_port_events (struct sp_event_set *event_set, const struct sp_port *port, enum sp_event mask) |
Add events to a struct sp_event_set for a given port. More... | |
enum sp_return | sp_wait (struct sp_event_set *event_set, unsigned int timeout_ms) |
Wait for any of a set of events to occur. More... | |
void | sp_free_event_set (struct sp_event_set *event_set) |
Free a structure allocated by sp_new_event_set(). More... | |
Waiting for events and timeout handling.
See await_events.c for an example of awaiting events on multiple ports.
enum sp_return sp_add_port_events | ( | struct sp_event_set * | event_set, |
const struct sp_port * | port, | ||
enum sp_event | mask | ||
) |
Add events to a struct sp_event_set for a given port.
The port must first be opened by calling sp_open() using the same port structure.
After the port is closed or the port structure freed, the results may no longer be valid.
[in,out] | event_set | Event set to update. Must not be NULL. |
[in] | port | Pointer to a port structure. Must not be NULL. |
[in] | mask | Bitmask of events to be waited for. |
void sp_free_event_set | ( | struct sp_event_set * | event_set | ) |
Free a structure allocated by sp_new_event_set().
[in] | event_set | Event set to free. Must not be NULL. |
enum sp_return sp_new_event_set | ( | struct sp_event_set ** | result_ptr | ) |
Allocate storage for a set of events.
The user should allocate a variable of type struct sp_event_set *, then pass a pointer to this variable to receive the result.
The result should be freed after use by calling sp_free_event_set().
[out] | result_ptr | If any error is returned, the variable pointed to by result_ptr will be set to NULL. Otherwise, it will be set to point to the event set. Must not be NULL. |
enum sp_return sp_wait | ( | struct sp_event_set * | event_set, |
unsigned int | timeout_ms | ||
) |
Wait for any of a set of events to occur.
[in] | event_set | Event set to wait on. Must not be NULL. |
[in] | timeout_ms | Timeout in milliseconds, or zero to wait indefinitely. |