libgphoto2 photo camera library (libgphoto2) API  2.5.0
gphoto2-port.h
Go to the documentation of this file.
00001 
00024 #ifndef __GPHOTO2_PORT_H__
00025 #define __GPHOTO2_PORT_H__
00026 
00027 #include <gphoto2/gphoto2-port-info-list.h>
00028 
00029 /* For portability */
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 /* __cplusplus */
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         /* must be last to avoid binary incompatibility.
00089          * luckily we just need to make sure this struct does not 
00090          * get larger than _GPPortSettingsSerial. */
00091         char port[64];          
00092 } GPPortSettingsUSB;
00093 
00097 typedef struct _GPPortSettingsUsbDiskDirect {
00098         char path[128];         
00099 } GPPortSettingsUsbDiskDirect;
00100 
00104 typedef struct _GPPortSettingsUsbScsi {
00105         char path[128];         
00106 } GPPortSettingsUsbScsi;
00107 
00114 typedef union _GPPortSettings {
00115         GPPortSettingsSerial serial;    
00116         GPPortSettingsUSB usb;          
00117         GPPortSettingsUsbDiskDirect usbdiskdirect; 
00118         GPPortSettingsUsbScsi usbscsi;  
00119 } GPPortSettings;
00120 
00121 enum {
00122         GP_PORT_USB_ENDPOINT_IN,        
00123         GP_PORT_USB_ENDPOINT_OUT,       
00124         GP_PORT_USB_ENDPOINT_INT        
00125 };
00126 
00127 typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
00128 typedef struct _GPPortPrivateCore    GPPortPrivateCore;
00129 
00143 typedef struct _GPPort {
00144         /* For your convenience */
00145         GPPortType type;                
00147         GPPortSettings settings;        
00148         GPPortSettings settings_pending;
00150         int timeout;                    
00152         GPPortPrivateLibrary *pl;       
00153         GPPortPrivateCore    *pc;       
00154 } GPPort;
00155 
00156 int gp_port_new         (GPPort **port);
00157 int gp_port_free        (GPPort *port);
00158 
00159 int gp_port_set_info    (GPPort *port, GPPortInfo info);
00160 int gp_port_get_info    (GPPort *port, GPPortInfo *info);
00161 
00162 int gp_port_open        (GPPort *port);
00163 int gp_port_close       (GPPort *port);
00164 
00165 int gp_port_write       (GPPort *port, const char *data, int size);
00166 int gp_port_read        (GPPort *port,       char *data, int size);
00167 int gp_port_check_int   (GPPort *port,       char *data, int size);
00168 int gp_port_check_int_fast (GPPort *port,    char *data, int size);
00169 
00170 int gp_port_get_timeout  (GPPort *port, int *timeout);
00171 int gp_port_set_timeout  (GPPort *port, int  timeout);
00172 
00173 int gp_port_set_settings (GPPort *port, GPPortSettings  settings);
00174 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
00175 
00182 typedef enum _GPPin {
00183         GP_PIN_RTS,     
00184         GP_PIN_DTR,     
00185         GP_PIN_CTS,     
00186         GP_PIN_DSR,     
00187         GP_PIN_CD,      
00188         GP_PIN_RING     
00189 } GPPin;
00190 
00196 typedef enum _GPLevel {
00197         GP_LEVEL_LOW  = 0,      
00198         GP_LEVEL_HIGH = 1       
00199 } GPLevel;
00200 
00201 int gp_port_get_pin   (GPPort *port, GPPin pin, GPLevel *level);
00202 int gp_port_set_pin   (GPPort *port, GPPin pin, GPLevel level);
00203 
00204 int gp_port_send_break (GPPort *port, int duration);
00205 int gp_port_flush      (GPPort *port, int direction);
00206 
00207 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
00208 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
00209 int gp_port_usb_clear_halt  (GPPort *port, int ep);
00210 int gp_port_usb_msg_write   (GPPort *port, int request, int value,
00211                              int index, char *bytes, int size);
00212 int gp_port_usb_msg_read    (GPPort *port, int request, int value,
00213                              int index, char *bytes, int size);
00214 int gp_port_usb_msg_interface_write    (GPPort *port, int request, 
00215                             int value, int index, char *bytes, int size);
00216 int gp_port_usb_msg_interface_read    (GPPort *port, int request, 
00217                             int value, int index, char *bytes, int size);
00218 int gp_port_usb_msg_class_write    (GPPort *port, int request, 
00219                             int value, int index, char *bytes, int size);
00220 int gp_port_usb_msg_class_read    (GPPort *port, int request, 
00221                             int value, int index, char *bytes, int size);
00222 
00223 int gp_port_seek (GPPort *port, int offset, int whence);
00224 
00225 int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
00226                                 char *cmd, int cmd_size,
00227                                 char *sense, int sense_size,
00228                                 char *data, int data_size);
00229 
00230 /* Error reporting */
00231 int         gp_port_set_error (GPPort *port, const char *format, ...)
00232 #ifdef __GNUC__
00233         __attribute__((__format__(printf,2,3)))
00234 #endif
00235 ;
00236 const char *gp_port_get_error (GPPort *port);
00237 
00238 /* DEPRECATED */
00240 typedef GPPort gp_port;
00242 typedef GPPortSettings gp_port_settings;
00244 #define PIN_CTS GP_PIN_CTS
00245 
00246 #ifdef __cplusplus
00247 }
00248 #endif /* __cplusplus */
00249 
00250 #endif /* __GPHOTO2_PORT_H__ */