Details
struct GPPortPrivateLibrary
struct GPPortPrivateLibrary; |
struct GPPortPrivateCore
struct GPPortPrivateCore; |
This structure contains private data.
struct GPPortSettingsSerial
struct GPPortSettingsSerial {
char port[128];
int speed;
int bits, parity, stopbits;
}; |
struct GPPortSettingsUSB
struct GPPortSettingsUSB {
int inep, outep;
int config;
int interface;
int altsetting;
}; |
union GPPortSettings
union GPPortSettings {
GPPortSettingsSerial serial;
GPPortSettingsUSB usb;
}; |
struct GPPort
struct GPPort {
/* For your convenience */
GPPortType type;
GPPortSettings settings;
GPPortSettings settings_pending;
int timeout; /* in milliseconds */
GPPortPrivateLibrary *pl;
GPPortPrivateCore *pc;
}; |
gp_port_new ()
int gp_port_new (GPPort **port); |
Allocates the memory for a new GPPort. After you called this function,
you probably want to call gp_port_set_info in order to make the newly
created port functional.
gp_port_free ()
int gp_port_free (GPPort *port); |
Closes the port and frees the memory.
gp_port_set_info ()
Makes a port functional. After calling this function, you can
access the port using for example gp_port_open.
gp_port_get_info ()
Retreives info about the port.
gp_port_close ()
int gp_port_close (GPPort *port); |
Closes a port temporarily. It can afterwards be reopened using
gp_port_open.
gp_port_read ()
int gp_port_read (GPPort *port,
char *data,
int size); |
Reads a specified number of bytes from the port into the supplied buffer.
gp_port_write ()
int gp_port_write (GPPort *port,
const char *data,
int size); |
Writes a specified amount of data to a port.
gp_port_get_settings ()
Retreives the current settings of a port.
gp_port_get_timeout ()
int gp_port_get_timeout (GPPort *port,
int *timeout); |
Retreives the current timeout of the port.
gp_port_set_timeout ()
int gp_port_set_timeout (GPPort *port,
int timeout); |
Sets the timeout of a port. gp_port_read will wait timeout milliseconds
for data. If no data will be received in that period, GP_ERROR_TIMEOUT
will be returned.
gp_port_get_pin ()
int gp_port_get_pin (GPPort *port,
GPPin pin,
GPLevel *level); |
gp_port_set_pin ()
int gp_port_set_pin (GPPort *port,
GPPin pin,
GPLevel level); |
gp_port_get_error ()
const char* gp_port_get_error (GPPort *port); |
Retrieves an error message from a port. If you want to make sure that
you get correct error messages, you need to call gp_port_set_error with
an error message of NULL each time before calling another port-related
function of which you want to check the return value.
gp_port_set_error ()
int gp_port_set_error (GPPort *port,
const char *format,
...); |
Sets an error message that can later be retrieved using gp_port_get_error.