GPhoto2-Port API Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
struct GPPortPrivateLibrary; struct GPPortPrivateCore; struct GPPortSettingsSerial; struct GPPortSettingsUSB; union GPPortSettings; struct GPPort; int gp_port_new (GPPort **port); int gp_port_free (GPPort *port); int gp_port_set_info (GPPort *port, GPPortInfo info); int gp_port_get_info (GPPort *port, GPPortInfo *info); int gp_port_open (GPPort *port); int gp_port_close (GPPort *port); int gp_port_read (GPPort *port, char *data, int size); int gp_port_write (GPPort *port, const char *data, int size); int gp_port_get_settings (GPPort *port, GPPortSettings *settings); int gp_port_set_settings (GPPort *port, GPPortSettings settings); int gp_port_get_timeout (GPPort *port, int *timeout); int gp_port_set_timeout (GPPort *port, int timeout); int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level); int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level); const char* gp_port_get_error (GPPort *port); int gp_port_set_error (GPPort *port, const char *format, ...); |
struct GPPortSettingsSerial { char port[128]; /** The portname (/dev/ttyX)*/ int speed; /** The baudrate of the device. */ int bits; /** How many bits data. */ GPPortSerialParity parity; /** parity data, see GP_PORT_SERIAL_PARITY_ defines */ int stopbits; /** How many stop bits are used. */ }; |
struct GPPortSettingsUSB { int inep, outep, intep; int config; int interface; int altsetting; }; |
struct GPPort { /* For your convenience */ GPPortType type; GPPortSettings settings; GPPortSettings settings_pending; int timeout; /* in milliseconds */ GPPortPrivateLibrary *pl; GPPortPrivateCore *pc; }; |
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.
port : | |
Returns : | a gphoto2 error code |
int gp_port_free (GPPort *port); |
Closes the port and frees the memory.
port : | a GPPort |
Returns : | a gphoto2 error code |
int gp_port_set_info (GPPort *port, GPPortInfo info); |
Makes a port functional. After calling this function, you can access the port using for example gp_port_open.
port : | a GPPort |
info : | the GPPortInfo |
Returns : | a gphoto2 error code |
int gp_port_get_info (GPPort *port, GPPortInfo *info); |
Retreives info about the port.
port : | a GPPort |
info : | |
Returns : | a gphoto2 error code |
int gp_port_open (GPPort *port); |
Opens a port which should have been created with gp_port_new and configured with gp_port_set_info and gp_port_set_settings
port : | a GPPort |
Returns : | a gphoto2 error code |
int gp_port_close (GPPort *port); |
Closes a port temporarily. It can afterwards be reopened using gp_port_open.
port : | a GPPort |
Returns : | a gphoto2 error code |
int gp_port_read (GPPort *port, char *data, int size); |
Reads a specified number of bytes from the port into the supplied buffer.
port : | a GPPort |
data : | a pointer to an allocated buffer |
size : | the number of bytes that should be read |
Returns : | a gphoto2 error code |
int gp_port_write (GPPort *port, const char *data, int size); |
Writes a specified amount of data to a port.
port : | a GPPort |
data : | the data to write to the port |
size : | the number of bytes to write to the port |
Returns : | a gphoto2 error code |
int gp_port_get_settings (GPPort *port, GPPortSettings *settings); |
Retreives the current settings of a port.
port : | a GPPort |
settings : | |
Returns : | a gphoto2 error code |
int gp_port_set_settings (GPPort *port, GPPortSettings settings); |
Adjusts the settings of a port. You should always call gp_port_get_settings, adjust the values depending on the type of the port, and then call gp_port_set_settings.
port : | a GPPort |
settings : | the GPPortSettings to be set |
Returns : | a gphoto2 error code |
int gp_port_get_timeout (GPPort *port, int *timeout); |
Retreives the current timeout of the port.
port : | a GPPort |
timeout : | |
Returns : | a gphoto2 error code |
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.
port : | a GPPort |
timeout : | the timeout |
Returns : | a gphoto2 error code |
int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level); |
port : | |
pin : | |
level : | |
Returns : |
|
int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level); |
port : | |
pin : | |
level : | |
Returns : |
|
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.
port : | a GPPort |
Returns : | an error message |