X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=README;h=50cb7b2e730522f8f3ce0d62e8384328d3a6f0cc;hb=e3b2f7a4e3c1315d51d6a91eec7dde44ec0a623b;hp=5958d8925d32e7f56868d1c46df1a1def9690684;hpb=0a16d4def93aa348fdd480222168d8e66afd1784;p=libserialport.git diff --git a/README b/README index 5958d89..50cb7b2 100644 --- a/README +++ b/README @@ -61,13 +61,13 @@ API The API is simple, and designed to be a minimal wrapper around the serial port support in each OS. -Most functions take a pointer to a struct sp_port, which represents an open -port. This structure should be allocated by the user and is populated by -sp_open(). It can be freed safely after sp_close(). +Most functions take a pointer to a struct sp_port, which represents an serial +port. This structure is obtained from the array returned by sp_list_ports(). -All functions can return only two possible error values. SP_ERR_ARG indicates +All functions can return only three possible error values. SP_ERR_ARG indicates the function was called with invalid arguments. SP_ERR_FAIL indicates that the -OS reported a failure. Both these error values are negative. +OS reported a failure. SP_ERR_MEM indicates that a memory allocation failed. +Aoth these error values are negative. When SP_ERR_FAIL is returned, an error code or string description of the error can be obtained by calling sp_last_error_code() or sp_last_error_message(). The @@ -82,27 +82,26 @@ The available functions are as follows: Enumeration ----------- -char **sp_list_ports(); +struct sp_port **sp_list_ports(); Lists the serial ports available on the system. The value returned is an array - of port names as C strings, terminated by a NULL. It should be freed after use - by calling sp_free_port_list(). + of pointers to sp_port structures, terminated by a NULL. It should be freed after + use by calling sp_free_port_list(). -void sp_free_port_list(char **list); +void sp_free_port_list(struct sp_port **list); Frees the data structure returned by sp_list_ports(). Opening and closing ports ------------------------- -int sp_open(struct sp_port *port, char *portname, int flags); +int sp_open(struct sp_port *port, int flags); Opens the specified serial port. Parameters: - port: Pointer to empty port structure, allocated by caller. - portname: Name of port to open. + 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.