libgphoto2 photo camera library (libgphoto2) API  2.5.2
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_reset       (GPPort *port);
00166 
00167 int gp_port_write       (GPPort *port, const char *data, int size);
00168 int gp_port_read        (GPPort *port,       char *data, int size);
00169 int gp_port_check_int   (GPPort *port,       char *data, int size);
00170 int gp_port_check_int_fast (GPPort *port,    char *data, int size);
00171 
00172 int gp_port_get_timeout  (GPPort *port, int *timeout);
00173 int gp_port_set_timeout  (GPPort *port, int  timeout);
00174 
00175 int gp_port_set_settings (GPPort *port, GPPortSettings  settings);
00176 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
00177 
00184 typedef enum _GPPin {
00185         GP_PIN_RTS,     
00186         GP_PIN_DTR,     
00187         GP_PIN_CTS,     
00188         GP_PIN_DSR,     
00189         GP_PIN_CD,      
00190         GP_PIN_RING     
00191 } GPPin;
00192 
00198 typedef enum _GPLevel {
00199         GP_LEVEL_LOW  = 0,      
00200         GP_LEVEL_HIGH = 1       
00201 } GPLevel;
00202 
00203 int gp_port_get_pin   (GPPort *port, GPPin pin, GPLevel *level);
00204 int gp_port_set_pin   (GPPort *port, GPPin pin, GPLevel level);
00205 
00206 int gp_port_send_break (GPPort *port, int duration);
00207 int gp_port_flush      (GPPort *port, int direction);
00208 
00209 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
00210 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
00211 int gp_port_usb_clear_halt  (GPPort *port, int ep);
00212 int gp_port_usb_msg_write   (GPPort *port, int request, int value,
00213                              int index, char *bytes, int size);
00214 int gp_port_usb_msg_read    (GPPort *port, int request, int value,
00215                              int index, char *bytes, int size);
00216 int gp_port_usb_msg_interface_write    (GPPort *port, int request, 
00217                             int value, int index, char *bytes, int size);
00218 int gp_port_usb_msg_interface_read    (GPPort *port, int request, 
00219                             int value, int index, char *bytes, int size);
00220 int gp_port_usb_msg_class_write    (GPPort *port, int request, 
00221                             int value, int index, char *bytes, int size);
00222 int gp_port_usb_msg_class_read    (GPPort *port, int request, 
00223                             int value, int index, char *bytes, int size);
00224 
00225 int gp_port_seek (GPPort *port, int offset, int whence);
00226 
00227 int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
00228                                 char *cmd, int cmd_size,
00229                                 char *sense, int sense_size,
00230                                 char *data, int data_size);
00231 
00232 /* Error reporting */
00233 int         gp_port_set_error (GPPort *port, const char *format, ...)
00234 #ifdef __GNUC__
00235         __attribute__((__format__(printf,2,3)))
00236 #endif
00237 ;
00238 const char *gp_port_get_error (GPPort *port);
00239 
00240 /* DEPRECATED */
00242 typedef GPPort gp_port;
00244 typedef GPPortSettings gp_port_settings;
00246 #define PIN_CTS GP_PIN_CTS
00247 
00248 #ifdef __cplusplus
00249 }
00250 #endif /* __cplusplus */
00251 
00252 #endif /* __GPHOTO2_PORT_H__ */