00001
00024 #ifndef __GPHOTO2_PORT_H__
00025 #define __GPHOTO2_PORT_H__
00026
00027 #include <gphoto2/gphoto2-port-info-list.h>
00028
00029
00030 #include <gphoto2/gphoto2-port-portability.h>
00031 #ifdef OS2
00032 #include <gphoto2/gphoto2-port-portability-os2.h>
00033 #include <os2.h>
00034 #endif
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00040 #ifndef TRUE
00041 #define TRUE (0==0)
00042 #endif
00043
00044 #ifndef FALSE
00045 #define FALSE (1==0)
00046 #endif
00047
00053 typedef enum _GPPortSerialParity
00054 {
00055 GP_PORT_SERIAL_PARITY_OFF = 0,
00056 GP_PORT_SERIAL_PARITY_EVEN,
00057 GP_PORT_SERIAL_PARITY_ODD
00058 } GPPortSerialParity;
00059
00061 #define GP_PORT_MAX_BUF_LEN 4096
00062
00066 typedef struct _GPPortSettingsSerial {
00067 char port[128];
00068 int speed;
00069 int bits;
00070 GPPortSerialParity parity;
00072 int stopbits;
00073 } GPPortSettingsSerial;
00074
00078 typedef struct _GPPortSettingsUSB {
00079 int inep;
00080 int outep;
00081 int intep;
00082 int config;
00083 int interface;
00084 int altsetting;
00086 int maxpacketsize;
00088
00089
00090
00091 char port[64];
00092 } GPPortSettingsUSB;
00093
00097 typedef struct _GPPortSettingsDisk {
00098 char mountpoint[128];
00099 } GPPortSettingsDisk;
00100
00104 typedef struct _GPPortSettingsUsbDiskDirect {
00105 char path[128];
00106 } GPPortSettingsUsbDiskDirect;
00107
00111 typedef struct _GPPortSettingsUsbScsi {
00112 char path[128];
00113 } GPPortSettingsUsbScsi;
00114
00121 typedef union _GPPortSettings {
00122 GPPortSettingsSerial serial;
00123 GPPortSettingsUSB usb;
00124 GPPortSettingsDisk disk;
00125 GPPortSettingsUsbDiskDirect usbdiskdirect;
00126 GPPortSettingsUsbScsi usbscsi;
00127 } GPPortSettings;
00128
00129 enum {
00130 GP_PORT_USB_ENDPOINT_IN,
00131 GP_PORT_USB_ENDPOINT_OUT,
00132 GP_PORT_USB_ENDPOINT_INT
00133 };
00134
00135 typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
00136 typedef struct _GPPortPrivateCore GPPortPrivateCore;
00137
00151 typedef struct _GPPort {
00152
00153 GPPortType type;
00155 GPPortSettings settings;
00156 GPPortSettings settings_pending;
00158 int timeout;
00160 GPPortPrivateLibrary *pl;
00161 GPPortPrivateCore *pc;
00162 } GPPort;
00163
00164 int gp_port_new (GPPort **port);
00165 int gp_port_free (GPPort *port);
00166
00167 int gp_port_set_info (GPPort *port, GPPortInfo info);
00168 int gp_port_get_info (GPPort *port, GPPortInfo *info);
00169
00170 int gp_port_open (GPPort *port);
00171 int gp_port_close (GPPort *port);
00172
00173 int gp_port_write (GPPort *port, const char *data, int size);
00174 int gp_port_read (GPPort *port, char *data, int size);
00175 int gp_port_check_int (GPPort *port, char *data, int size);
00176 int gp_port_check_int_fast (GPPort *port, char *data, int size);
00177
00178 int gp_port_get_timeout (GPPort *port, int *timeout);
00179 int gp_port_set_timeout (GPPort *port, int timeout);
00180
00181 int gp_port_set_settings (GPPort *port, GPPortSettings settings);
00182 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
00183
00190 typedef enum _GPPin {
00191 GP_PIN_RTS,
00192 GP_PIN_DTR,
00193 GP_PIN_CTS,
00194 GP_PIN_DSR,
00195 GP_PIN_CD,
00196 GP_PIN_RING
00197 } GPPin;
00198
00204 typedef enum _GPLevel {
00205 GP_LEVEL_LOW = 0,
00206 GP_LEVEL_HIGH = 1
00207 } GPLevel;
00208
00209 int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level);
00210 int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level);
00211
00212 int gp_port_send_break (GPPort *port, int duration);
00213 int gp_port_flush (GPPort *port, int direction);
00214
00215 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
00216 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
00217 int gp_port_usb_clear_halt (GPPort *port, int ep);
00218 int gp_port_usb_msg_write (GPPort *port, int request, int value,
00219 int index, char *bytes, int size);
00220 int gp_port_usb_msg_read (GPPort *port, int request, int value,
00221 int index, char *bytes, int size);
00222 int gp_port_usb_msg_interface_write (GPPort *port, int request,
00223 int value, int index, char *bytes, int size);
00224 int gp_port_usb_msg_interface_read (GPPort *port, int request,
00225 int value, int index, char *bytes, int size);
00226 int gp_port_usb_msg_class_write (GPPort *port, int request,
00227 int value, int index, char *bytes, int size);
00228 int gp_port_usb_msg_class_read (GPPort *port, int request,
00229 int value, int index, char *bytes, int size);
00230
00231 int gp_port_seek (GPPort *port, int offset, int whence);
00232
00233 int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
00234 char *cmd, int cmd_size,
00235 char *sense, int sense_size,
00236 char *data, int data_size);
00237
00238
00239 int gp_port_set_error (GPPort *port, const char *format, ...)
00240 #ifdef __GNUC__
00241 __attribute__((__format__(printf,2,3)))
00242 #endif
00243 ;
00244 const char *gp_port_get_error (GPPort *port);
00245
00246
00248 typedef GPPort gp_port;
00250 typedef GPPortSettings gp_port_settings;
00252 #define PIN_CTS GP_PIN_CTS
00253
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257
00258 #endif
00259
00260