+ * @return The number of bytes written on success, or a negative error code.
+ * The number of bytes returned may be any number from zero to the
+ * maximum that was requested.
+ */
+enum sp_return sp_nonblocking_write(struct sp_port *port, const void *buf, size_t count);
+
+/**
+ * Gets the number of bytes waiting in the input buffer.
+ *
+ * @param port Pointer to port structure.
+ *
+ * @return Number of bytes waiting on success, a negative error code otherwise.
+ */
+enum sp_return sp_input_waiting(struct sp_port *port);
+
+/**
+ * Gets the number of bytes waiting in the output buffer.
+ *
+ * @param port Pointer to port structure.
+ *
+ * @return Number of bytes waiting on success, a negative error code otherwise.
+ */
+enum sp_return sp_output_waiting(struct sp_port *port);
+
+/**
+ * Flush serial port buffers. Data in the selected buffer(s) is discarded.
+ *
+ * @param port Pointer to port structure.
+ * @param buffers Which buffer(s) to flush.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ */
+enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers);
+
+/**
+ * Wait for buffered data to be transmitted.
+ *
+ * @warning If your program runs on Unix, defines its own signal handlers, and
+ * needs to abort draining the output buffer when when these are
+ * called, then you should not use this function. It repeats system
+ * calls that return with EINTR. To be able to abort a drain from a
+ * signal handler, you would need to implement your own blocking
+ * drain by polling the result of sp_output_waiting().
+ *
+ * @param port Pointer to port structure.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ */
+enum sp_return sp_drain(struct sp_port *port);
+
+/**
+ * @}
+ * @defgroup Waiting Waiting for events
+ * @{
+ */
+
+/**
+ * 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().
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ */
+enum sp_return sp_new_event_set(struct sp_event_set **result_ptr);
+
+/**
+ * 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.
+ *
+ * @param event_set Event set to update.
+ * @param port Pointer to port structure.
+ * @param mask Bitmask of events to be waited for.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ */
+enum sp_return sp_add_port_events(struct sp_event_set *event_set,
+ const struct sp_port *port, enum sp_event mask);
+
+/**
+ * Wait for any of a set of events to occur.
+ *
+ * @param event_set Event set to wait on.
+ * @param timeout Timeout in milliseconds, or zero to wait indefinitely.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ */
+enum sp_return sp_wait(struct sp_event_set *event_set, unsigned int timeout);
+
+/**
+ * Free a structure allocated by sp_new_event_set().
+ */
+void sp_free_event_set(struct sp_event_set *event_set);
+
+/**
+ * @}
+ * @defgroup Signals Port signalling operations
+ * @{
+ */
+
+/**
+ * Gets the status of the control signals for the specified port.
+ *
+ * The user should allocate a variable of type "enum sp_signal" and pass a
+ * pointer to this variable to receive the result. The result is a bitmask
+ * in which individual signals can be checked by bitwise OR with values of
+ * the sp_signal enum.
+ *
+ * @param port Pointer to port structure.
+ * @param signals Pointer to variable to receive result.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.
+ */
+enum sp_return sp_get_signals(struct sp_port *port, enum sp_signal *signals);
+
+/**
+ * Put the port transmit line into the break state.
+ *
+ * @param port Pointer to port structure.
+ *
+ * @return SP_OK upon success, a negative error code otherwise.