#include "config.h"#include <stdarg.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <ltdl.h>#include <gphoto2/gphoto2-port-result.h>#include <gphoto2/gphoto2-port-library.h>#include <gphoto2/gphoto2-port-log.h>Include dependency graph for gphoto2-port.c:

Data Structures | |
| struct | _GPPortPrivateCore |
| Internal private libgphoto2_port data. This structure contains private data. More... | |
Defines | |
| #define | _(String) (String) |
| #define | N_(String) (String) |
| #define | CHECK_RESULT(result) {int r=(result); if (r<0) return (r);} |
| #define | CHECK_NULL(m) {if (!(m)) return (GP_ERROR_BAD_PARAMETERS);} |
| #define | CHECK_SUPP(p, t, o) {if (!(o)) {gp_port_set_error ((p), _("The operation '%s' is not supported by this device"), (t)); return (GP_ERROR_NOT_SUPPORTED);}} |
| #define | CHECK_INIT(p) {if (!(p)->pc->ops) {gp_port_set_error ((p), _("The port has not yet been initialized")); return (GP_ERROR_BAD_PARAMETERS);}} |
| #define | FAST_TIMEOUT 50 |
Functions | |
| int | gp_port_new (GPPort **port) |
| Create new GPPort. | |
| int | gp_port_set_info (GPPort *port, GPPortInfo info) |
| Configure a port. | |
| int | gp_port_get_info (GPPort *port, GPPortInfo *info) |
| Retreives information about the port. | |
| int | gp_port_open (GPPort *port) |
| Open a port. | |
| int | gp_port_close (GPPort *port) |
| Close a port. | |
| int | gp_port_free (GPPort *port) |
| Free the port structure. | |
| int | gp_port_write (GPPort *port, const char *data, int size) |
| Writes a specified amount of data to a port. | |
| int | gp_port_read (GPPort *port, char *data, int size) |
| Read data from port. | |
| int | gp_port_check_int (GPPort *port, char *data, int size) |
| Check for intterupt. | |
| int | gp_port_check_int_fast (GPPort *port, char *data, int size) |
| Check for interrupt without wait. | |
| int | gp_port_set_timeout (GPPort *port, int timeout) |
| Set timeout of port. | |
| int | gp_port_timeout_set (GPPort *, int) |
| int | gp_port_timeout_get (GPPort *, int *) |
| int | gp_port_get_timeout (GPPort *port, int *timeout) |
| Get the current port timeout. | |
| int | gp_port_set_settings (GPPort *port, GPPortSettings settings) |
| Set port settings. | |
| int | gp_port_settings_get (GPPort *, GPPortSettings *) |
| int | gp_port_settings_set (GPPort *, GPPortSettings) |
| int | gp_port_get_settings (GPPort *port, GPPortSettings *settings) |
| Get the current port settings. | |
| int | gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level) |
| Get setting of specific serial PIN. | |
| int | gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level) |
| Set specified serial PIN to value. | |
| int | gp_port_send_break (GPPort *port, int duration) |
| Send a break over a serial port. | |
| int | gp_port_flush (GPPort *port, int direction) |
| Flush data on serial port. | |
| int | gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct) |
| Find USB device by vendor/product. | |
| int | gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol) |
| Find USB device by interface class. | |
| int | gp_port_usb_clear_halt (GPPort *port, int ep) |
| Clear USB endpoint HALT condition. | |
| int | gp_port_usb_msg_write (GPPort *port, int request, int value, int index, char *bytes, int size) |
| Send a USB control message with output data. | |
| int | gp_port_usb_msg_read (GPPort *port, int request, int value, int index, char *bytes, int size) |
| Send a USB control message with input data. | |
| int | gp_port_usb_msg_interface_write (GPPort *port, int request, int value, int index, char *bytes, int size) |
| Send a USB interface control message with output data. | |
| int | gp_port_usb_msg_interface_read (GPPort *port, int request, int value, int index, char *bytes, int size) |
| Send a USB interface control message with input data. | |
| int | gp_port_usb_msg_class_write (GPPort *port, int request, int value, int index, char *bytes, int size) |
| Send a USB class control message with output data. | |
| int | gp_port_usb_msg_class_read (GPPort *port, int request, int value, int index, char *bytes, int size) |
| Send a USB class control message with input data. | |
| int | gp_port_set_error (GPPort *port, const char *format,...) |
| Set verbose port error message. | |
| const char * | gp_port_get_error (GPPort *port) |
| Get verbose port error message. | |
| #define FAST_TIMEOUT 50 |
The timeout in milliseconds for fast interrupt reads.
| int gp_port_check_int | ( | GPPort * | port, | |
| char * | data, | |||
| int | size | |||
| ) |
Check for intterupt.
| port | a GPPort | |
| data | a pointer to an allocated buffer | |
| size | the number of bytes that should be read |
| int gp_port_check_int_fast | ( | GPPort * | port, | |
| char * | data, | |||
| int | size | |||
| ) |
Check for interrupt without wait.
| port | a GPPort | |
| data | a pointer to an allocated buffer | |
| size | the number of bytes that should be read |
| int gp_port_close | ( | GPPort * | port | ) |
Close a port.
| port | a GPPort |
| int gp_port_flush | ( | GPPort * | port, | |
| int | direction | |||
| ) |
Flush data on serial port.
| port | a GPPort | |
| direction | the direction of the flush |
| int gp_port_free | ( | GPPort * | port | ) |
Free the port structure.
| port | a GPPort |
| const char* gp_port_get_error | ( | GPPort * | port | ) |
Get verbose port error message.
| port | a GPPort |
| int gp_port_get_info | ( | GPPort * | port, | |
| GPPortInfo * | info | |||
| ) |
Retreives information about the port.
Retrieves the informations set by gp_port_set_info().
| port | a GPPort | |
| info | GPPortInfo |
Get setting of specific serial PIN.
| port | a GPPort | |
| pin | the serial pin to be retrieved | |
| level | the setting of the pin |
| int gp_port_get_settings | ( | GPPort * | port, | |
| GPPortSettings * | settings | |||
| ) |
Get the current port settings.
| port | a GPPort | |
| settings | pointer to the retrieved settings |
| int gp_port_get_timeout | ( | GPPort * | port, | |
| int * | timeout | |||
| ) |
Get the current port timeout.
| port | a GPPort | |
| timeout | pointer to timeout |
| int gp_port_new | ( | GPPort ** | port | ) |
Create new GPPort.
Allocate and initialize 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 | Pointer the GPPort* pointer |
| int gp_port_open | ( | GPPort * | port | ) |
Open a port.
| port | a GPPort |
| int gp_port_read | ( | GPPort * | port, | |
| char * | data, | |||
| int | size | |||
| ) |
Read data from port.
| port | a GPPort | |
| data | a pointer to an allocated buffer | |
| size | the number of bytes that should be read |
| int gp_port_send_break | ( | GPPort * | port, | |
| int | duration | |||
| ) |
Send a break over a serial port.
| port | a GPPort | |
| duration | duration of break in milliseconds |
| int gp_port_set_error | ( | GPPort * | port, | |
| const char * | format, | |||
| ... | ||||
| ) |
Set verbose port error message.
| port | a GPPort | |
| format | printf style format string | |
| ... | variable arguments depending on format string |
| int gp_port_set_info | ( | GPPort * | port, | |
| GPPortInfo | info | |||
| ) |
Configure a port.
Makes a port functional by passing in the necessary path information (from the serial:/dev/ttyS0 or similar variables). After calling this function, you can access the port using for example gp_port_open().
| port | a GPPort | |
| info | the GPPortInfo to set |
Set specified serial PIN to value.
| port | a GPPort | |
| pin | the serial pin to be retrieved | |
| level | the setting of the pin |
| int gp_port_set_settings | ( | GPPort * | port, | |
| GPPortSettings | settings | |||
| ) |
Set port settings.
| port | a GPPort | |
| settings | the GPPortSettings to be set |
| int gp_port_set_timeout | ( | GPPort * | port, | |
| int | timeout | |||
| ) |
Set timeout of port.
| port | a GPPort | |
| timeout | the timeout |
| int gp_port_settings_get | ( | GPPort * | , | |
| GPPortSettings * | ||||
| ) |
Deprecated
| int gp_port_settings_set | ( | GPPort * | , | |
| GPPortSettings | ||||
| ) |
Deprecated
| int gp_port_timeout_get | ( | GPPort * | , | |
| int * | ||||
| ) |
Deprecated
| int gp_port_timeout_set | ( | GPPort * | , | |
| int | ||||
| ) |
Deprecated
| int gp_port_usb_clear_halt | ( | GPPort * | port, | |
| int | ep | |||
| ) |
Clear USB endpoint HALT condition.
| port | a GPPort | |
| ep | endpoint to clear HALT |
| int gp_port_usb_find_device | ( | GPPort * | port, | |
| int | idvendor, | |||
| int | idproduct | |||
| ) |
Find USB device by vendor/product.
| port | a GPPort | |
| idvendor | USB vendor id | |
| idproduct | USB product id |
| int gp_port_usb_find_device_by_class | ( | GPPort * | port, | |
| int | mainclass, | |||
| int | subclass, | |||
| int | protocol | |||
| ) |
Find USB device by interface class.
| port | a GPPort | |
| mainclass | the USB interface class | |
| subclass | the USB interface subclass | |
| protocol | the USB interface protocol |
| int gp_port_usb_msg_class_read | ( | GPPort * | port, | |
| int | request, | |||
| int | value, | |||
| int | index, | |||
| char * | bytes, | |||
| int | size | |||
| ) |
Send a USB class control message with input data.
| port | a GPPort | |
| request | control request code | |
| value | control value | |
| index | control index | |
| bytes | pointer to data | |
| size | size of the data |
| int gp_port_usb_msg_class_write | ( | GPPort * | port, | |
| int | request, | |||
| int | value, | |||
| int | index, | |||
| char * | bytes, | |||
| int | size | |||
| ) |
Send a USB class control message with output data.
| port | a GPPort | |
| request | control request code | |
| value | control value | |
| index | control index | |
| bytes | pointer to data | |
| size | size of the data |
| int gp_port_usb_msg_interface_read | ( | GPPort * | port, | |
| int | request, | |||
| int | value, | |||
| int | index, | |||
| char * | bytes, | |||
| int | size | |||
| ) |
Send a USB interface control message with input data.
| port | a GPPort | |
| request | control request code | |
| value | control value | |
| index | control index | |
| bytes | pointer to data | |
| size | size of the data |
| int gp_port_usb_msg_interface_write | ( | GPPort * | port, | |
| int | request, | |||
| int | value, | |||
| int | index, | |||
| char * | bytes, | |||
| int | size | |||
| ) |
Send a USB interface control message with output data.
| port | a GPPort | |
| request | control request code | |
| value | control value | |
| index | control index | |
| bytes | pointer to data | |
| size | size of the data |
| int gp_port_usb_msg_read | ( | GPPort * | port, | |
| int | request, | |||
| int | value, | |||
| int | index, | |||
| char * | bytes, | |||
| int | size | |||
| ) |
Send a USB control message with input data.
| port | a GPPort | |
| request | control request code | |
| value | control value | |
| index | control index | |
| bytes | pointer to data | |
| size | size of the data |
| int gp_port_usb_msg_write | ( | GPPort * | port, | |
| int | request, | |||
| int | value, | |||
| int | index, | |||
| char * | bytes, | |||
| int | size | |||
| ) |
Send a USB control message with output data.
| port | a GPPort | |
| request | control request code | |
| value | control value | |
| index | control index | |
| bytes | pointer to data | |
| size | size of the data |
| 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 |
1.5.1