- port: Pointer to port structure.
- flags: Flags to use when opening the serial port. Possible
- flags are: SP_MODE_RDWR, SP_MODE_RDONLY, and SP_MODE_NONBLOCK.
-
- Returns: SP_OK on success, SP_ERR_FAIL on failure, SP_ERR_MEM on allocation
- failure, or SP_ERR_ARG if an invalid port is passed.
-
-int sp_close(struct sp_port *port);
-
- Closes the specified serial port.
-
- Returns: SP_OK on success, SP_ERR_FAIL on failure, or SP_ERR_ARG
- if an invalid port is passed.
-
-Setting port parameters
------------------------
-
-int sp_set_params(struct sp_port *port, int baudrate,
- int bits, int parity, int stopbits,
- int flowcontrol, int rts, int dtr);
-
- 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 bytes from the specified serial port. Note that this function may
- return after reading less than the specified number of bytes; it is the
- user's responsibility to iterate as necessary in this case.
-
- Parameters:
-
- port: Pointer to port structure.
- buf: Buffer in which to store the bytes read.
- count: Maximum 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)
-
- Write bytes to the specified serial port. Note that this function may
- return after writing less than the specified number of bytes; it is the
- user's responsibility to iterate as necessary in this case.
-
- Parameters:
-
- port: Pointer to port structure.
- buf: Buffer containing the bytes to write.
- count: Maximum 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.