gphoto2-port.h
Go to the documentation of this file.
#ifndef __GPHOTO2_PORT_H__
#define __GPHOTO2_PORT_H__
#include <gphoto2/gphoto2-port-info-list.h>
/* For portability */
#include <gphoto2/gphoto2-port-portability.h>
#ifdef OS2
#include <gphoto2/gphoto2-port-portability-os2.h>
#include <os2.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef TRUE
#define TRUE (0==0)
#endif
#ifndef FALSE
#define FALSE (1==0)
#endif
typedef enum _GPPortSerialParity
{
GP_PORT_SERIAL_PARITY_OFF = 0,
GP_PORT_SERIAL_PARITY_EVEN,
GP_PORT_SERIAL_PARITY_ODD
} GPPortSerialParity;
#define GP_PORT_MAX_BUF_LEN 4096
typedef struct _GPPortSettingsSerial {
char port[128];
int speed;
int bits;
GPPortSerialParity parity;
int stopbits;
} GPPortSettingsSerial;
typedef struct _GPPortSettingsUSB {
int inep;
int outep;
int intep;
int config;
int interface;
int altsetting;
int maxpacketsize;
/* 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 _GPPortSettingsDisk {
char mountpoint[128];
} GPPortSettingsDisk;
typedef struct _GPPortSettingsUsbDiskDirect {
char path[128];
} GPPortSettingsUsbDiskDirect;
typedef struct _GPPortSettingsUsbScsi {
char path[128];
} GPPortSettingsUsbScsi;
typedef union _GPPortSettings {
GPPortSettingsSerial serial;
GPPortSettingsUSB usb;
GPPortSettingsDisk disk;
GPPortSettingsUsbDiskDirect usbdiskdirect;
GPPortSettingsUsbScsi usbscsi;
} GPPortSettings;
enum {
GP_PORT_USB_ENDPOINT_IN,
GP_PORT_USB_ENDPOINT_OUT,
GP_PORT_USB_ENDPOINT_INT
};
typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
typedef struct _GPPortPrivateCore GPPortPrivateCore;
typedef struct _GPPort {
/* For your convenience */
GPPortType type;
GPPortSettings settings;
GPPortSettings settings_pending;
int timeout;
GPPortPrivateLibrary *pl;
GPPortPrivateCore *pc;
} 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_write (GPPort *port, const char *data, int size);
int gp_port_read (GPPort *port, char *data, int size);
int gp_port_check_int (GPPort *port, char *data, int size);
int gp_port_check_int_fast (GPPort *port, char *data, int size);
int gp_port_get_timeout (GPPort *port, int *timeout);
int gp_port_set_timeout (GPPort *port, int timeout);
int gp_port_set_settings (GPPort *port, GPPortSettings settings);
int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
typedef enum _GPPin {
GP_PIN_RTS,
GP_PIN_DTR,
GP_PIN_CTS,
GP_PIN_DSR,
GP_PIN_CD,
GP_PIN_RING
} GPPin;
typedef enum _GPLevel {
GP_LEVEL_LOW = 0,
GP_LEVEL_HIGH = 1
} GPLevel;
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_send_break (GPPort *port, int duration);
int gp_port_flush (GPPort *port, int direction);
int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
int gp_port_usb_clear_halt (GPPort *port, int ep);
int gp_port_usb_msg_write (GPPort *port, int request, int value,
int index, char *bytes, int size);
int gp_port_usb_msg_read (GPPort *port, int request, int value,
int index, char *bytes, int size);
int gp_port_usb_msg_interface_write (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_usb_msg_interface_read (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_usb_msg_class_write (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_usb_msg_class_read (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_seek (GPPort *port, int offset, int whence);
int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
char *cmd, int cmd_size,
char *sense, int sense_size,
char *data, int data_size);
/* Error reporting */
int gp_port_set_error (GPPort *port, const char *format, ...)
#ifdef __GNUC__
__attribute__((__format__(printf,2,3)))
#endif
;
const char *gp_port_get_error (GPPort *port);
/* DEPRECATED */
typedef GPPort gp_port;
typedef GPPortSettings gp_port_settings;
#define PIN_CTS GP_PIN_CTS
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GPHOTO2_PORT_H__ */