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 _GPPortSettingsDisk {
00098         char mountpoint[128];   
00099 } GPPortSettingsDisk;
00100 
00107 typedef union _GPPortSettings {
00108         GPPortSettingsSerial serial;    
00109         GPPortSettingsUSB usb;          
00110         GPPortSettingsDisk disk;        
00111 } GPPortSettings;
00112 
00113 enum {
00114         GP_PORT_USB_ENDPOINT_IN,        
00115         GP_PORT_USB_ENDPOINT_OUT,       
00116         GP_PORT_USB_ENDPOINT_INT        
00117 };
00118 
00119 typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
00120 typedef struct _GPPortPrivateCore    GPPortPrivateCore;
00121 
00135 typedef struct _GPPort {
00136         /* For your convenience */
00137         GPPortType type;                
00139         GPPortSettings settings;        
00140         GPPortSettings settings_pending;
00142         int timeout;                    
00144         GPPortPrivateLibrary *pl;       
00145         GPPortPrivateCore    *pc;       
00146 } GPPort;
00147 
00148 int gp_port_new         (GPPort **port);
00149 int gp_port_free        (GPPort *port);
00150 
00151 int gp_port_set_info    (GPPort *port, GPPortInfo  info);
00152 int gp_port_get_info    (GPPort *port, GPPortInfo *info);
00153 
00154 int gp_port_open        (GPPort *port);
00155 int gp_port_close       (GPPort *port);
00156 
00157 int gp_port_write       (GPPort *port, const char *data, int size);
00158 int gp_port_read        (GPPort *port,       char *data, int size);
00159 int gp_port_check_int   (GPPort *port,       char *data, int size);
00160 int gp_port_check_int_fast (GPPort *port,    char *data, int size);
00161 
00162 int gp_port_get_timeout  (GPPort *port, int *timeout);
00163 int gp_port_set_timeout  (GPPort *port, int  timeout);
00164 
00165 int gp_port_set_settings (GPPort *port, GPPortSettings  settings);
00166 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
00167 
00174 typedef enum _GPPin {
00175         GP_PIN_RTS,     
00176         GP_PIN_DTR,     
00177         GP_PIN_CTS,     
00178         GP_PIN_DSR,     
00179         GP_PIN_CD,      
00180         GP_PIN_RING     
00181 } GPPin;
00182 
00188 typedef enum _GPLevel {
00189         GP_LEVEL_LOW  = 0,      
00190         GP_LEVEL_HIGH = 1       
00191 } GPLevel;
00192 
00193 int gp_port_get_pin   (GPPort *port, GPPin pin, GPLevel *level);
00194 int gp_port_set_pin   (GPPort *port, GPPin pin, GPLevel level);
00195 
00196 int gp_port_send_break (GPPort *port, int duration);
00197 int gp_port_flush      (GPPort *port, int direction);
00198 
00199 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
00200 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
00201 int gp_port_usb_clear_halt  (GPPort *port, int ep);
00202 int gp_port_usb_msg_write   (GPPort *port, int request, int value,
00203                              int index, char *bytes, int size);
00204 int gp_port_usb_msg_read    (GPPort *port, int request, int value,
00205                              int index, char *bytes, int size);
00206 int gp_port_usb_msg_interface_write    (GPPort *port, int request, 
00207                             int value, int index, char *bytes, int size);
00208 int gp_port_usb_msg_interface_read    (GPPort *port, int request, 
00209                             int value, int index, char *bytes, int size);
00210 int gp_port_usb_msg_class_write    (GPPort *port, int request, 
00211                             int value, int index, char *bytes, int size);
00212 int gp_port_usb_msg_class_read    (GPPort *port, int request, 
00213                             int value, int index, char *bytes, int size);
00214 
00215 /* Error reporting */
00216 int         gp_port_set_error (GPPort *port, const char *format, ...)
00217 #ifdef __GNUC__
00218         __attribute__((__format__(printf,2,3)))
00219 #endif
00220 ;
00221 const char *gp_port_get_error (GPPort *port);
00222 
00223 /* DEPRECATED */
00225 typedef GPPort gp_port;
00227 typedef GPPortSettings gp_port_settings;
00229 #define PIN_CTS GP_PIN_CTS
00230 
00231 #ifdef __cplusplus
00232 }
00233 #endif /* __cplusplus */
00234 
00235 #endif /* __GPHOTO2_PORT_H__ */
00236 
00237 

Generated on Sun Jul 22 19:29:31 2007 for libgphoto2 photo camera library (libgphoto2) by  doxygen 1.5.0