![]() | ![]() | ![]() | GPhoto2-Port API Reference Manual | ![]() |
---|
GPPortPrivateLibrary; GPPortPrivateCore; GPPortSettingsSerial; GPPortSettingsUSB; union GPPortSettings; 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); int gp_port_set_error (GPPort *port, const char *format);
typedef struct _GPPortPrivateCore GPPortPrivateCore;
This structure contains private data.
typedef struct { 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. */ } GPPortSettingsSerial;
typedef struct { int inep, outep, intep; int config; int interface; int altsetting; /* must be last to avoid binary incompatibility. * luckily we just need to make sure this struct does not * get larger than _GPPortSettingsSerial. */ char port[64]; } GPPortSettingsUSB;
typedef struct { /* For your convenience */ GPPortType type; GPPortSettings settings; GPPortSettings settings_pending; int timeout; /* in milliseconds */ GPPortPrivateLibrary *pl; GPPortPrivateCore *pc; } GPPort;
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 : |
|
<<< GPhoto2-Port-Info-List | GPhoto2-Port-Library >>> |