libserialport  0.1.0
cross-platform library for accessing serial ports
 All Data Structures Files Functions Variables Enumerations Enumerator Groups Pages
Functions
Opening, closing and querying ports

Functions

enum sp_return sp_open (struct sp_port *port, enum sp_mode flags)
 Open the specified serial port. More...
 
enum sp_return sp_close (struct sp_port *port)
 Close the specified serial port. More...
 
char * sp_get_port_name (const struct sp_port *port)
 Get the name of a port. More...
 
enum sp_return sp_get_port_handle (const struct sp_port *port, void *result_ptr)
 Get the operating system handle for a port. More...
 

Detailed Description

Function Documentation

enum sp_return sp_close ( struct sp_port port)

Close the specified serial port.

Returns
SP_OK upon success, a negative error code otherwise.
Since
0.1.0
enum sp_return sp_get_port_handle ( const struct sp_port port,
void *  result_ptr 
)

Get the operating system handle for a port.

The type of the handle depends on the operating system. On Unix based systems, the handle is a file descriptor of type "int". On Windows, the handle is of type "HANDLE". The user should allocate a variable of the appropriate type and pass a pointer to this to receive the result.

To obtain a valid handle, 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 handle may no longer be valid.

Warning
This feature is provided so that programs may make use of OS-specific functionality where desired. Doing so obviously comes at a cost in portability. It also cannot be guaranteed that direct usage of the OS handle will not conflict with the library's own usage of the port. Be careful.
Returns
SP_OK upon success, a negative error code otherwise.
Since
0.1.0
char* sp_get_port_name ( const struct sp_port port)

Get the name of a port.

The name returned is whatever is normally used to refer to a port on the current operating system; e.g. for Windows it will usually be a "COMn" device name, and for Unix it will be a device path beginning with "/dev/".

Parameters
portPointer to port structure.
Returns
The port name, or NULL if an invalid port is passed. The name string is part of the port structure and may not be used after the port structure has been freed.
Since
0.1.0
enum sp_return sp_open ( struct sp_port port,
enum sp_mode  flags 
)

Open the specified serial port.

Parameters
portPointer to port structure.
flagsFlags to use when opening the serial port.
Returns
SP_OK upon success, a negative error code otherwise.
Since
0.1.0