libserialport  unreleased development snapshot
cross-platform library for accessing serial ports
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
Functions
Waiting

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...
 

Detailed Description

Waiting for events and timeout handling.

Function Documentation

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.

Parameters
[in,out]event_setEvent set to update. Must not be NULL.
[in]portPointer to a port structure. Must not be NULL.
[in]maskBitmask of events to be waited for.
Returns
SP_OK upon success, a negative error code otherwise.
Since
0.1.0
void sp_free_event_set ( struct sp_event_set event_set)

Free a structure allocated by sp_new_event_set().

Parameters
[in]event_setEvent set to free. Must not be NULL.
Since
0.1.0
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().

Parameters
[out]result_ptrIf 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.
Returns
SP_OK upon success, a negative error code otherwise.
Since
0.1.0
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.

Parameters
[in]event_setEvent set to wait on. Must not be NULL.
[in]timeout_msTimeout in milliseconds, or zero to wait indefinitely.
Returns
SP_OK upon success, a negative error code otherwise.
Since
0.1.0