- Sets serial parameters for the specified serial port.
-
- Parameters:
-
- port: Pointer to port structure.
- baudrate: Baud rate to set.
- bits: Number of data bits to use.
- parity: Parity setting to use
- (SP_PARITY_NONE, SP_PARITY_EVEN or SP_PARITY_ODD)
- stopbits: Number of stop bits to use (1 or 2).
- flowcontrol: Flow control setting to use
- (SP_FLOW_NONE, SP_FLOW_HARDWARE or SP_FLOW_SOFTWARE)
-
- Returns: SP_OK on success, SP_ERR_FAIL on failure, or SP_ERR_ARG
- for invalid arguments.
-
-Reading, writing and flushing data
-----------------------------------
-
-int sp_read(struct sp_port *port, const void *buf, size_t count)
-
- Reads a number of bytes from the specified serial port.
-
- Parameters:
-
- port: Pointer to port structure.
- buf: Buffer in which to store the bytes read.
- count: Number of bytes to read.
-
- Returns: The number of bytes read, SP_ERR_FAIL on failure,
- or SP_ERR_ARG for invalid arguments.
-
-int sp_write(struct sp_port *port, const void *buf, size_t count)
-
- Writes a number of bytes to the specified serial port.
-
- Parameters:
-
- port: Pointer to port structure.
- buf: Buffer containing the bytes to write.
- count: Number of bytes to write.
-
- Returns: The number of bytes written, SP_ERR_FAIL on failure,
- or SP_ERR_ARG for invalid arguments.
-
-int sp_flush(struct sp_port *port);
-
- Flushes serial port buffers.
-
- Returns: SP_OK on success, SP_ERR_FAIL on failure, or SP_ERR_ARG
- if an invalid port is passed.
-
-Error handling
---------------
-
-int sp_last_error_code();
-
- Gets the error code for a failed operation.
-
- In order to obtain the correct result, this function should be called
- straight after the failure, before executing any other system operations.
-
- Returns: The system's numeric code for the error that caused the last
- operation to fail.