libgphoto2 photo camera library (libgphoto2) API  2.5.8
gphoto2-port.h
Go to the documentation of this file.
1 
24 #ifndef __GPHOTO2_PORT_H__
25 #define __GPHOTO2_PORT_H__
26 
28 
29 /* For portability */
30 #include <gphoto2/gphoto2-port-portability.h>
31 #ifdef OS2
32 #include <gphoto2/gphoto2-port-portability-os2.h>
33 #include <os2.h>
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
40 #ifndef TRUE
41 #define TRUE (0==0)
42 #endif
43 
44 #ifndef FALSE
45 #define FALSE (1==0)
46 #endif
47 
53 typedef enum _GPPortSerialParity
54 {
59 
61 #define GP_PORT_MAX_BUF_LEN 4096
62 
66 typedef struct _GPPortSettingsSerial {
67  char port[128];
68  int speed;
69  int bits;
72  int stopbits;
74 
78 typedef struct _GPPortSettingsUSB {
79  int inep;
80  int outep;
81  int intep;
82  int config;
83  int interface;
84  int altsetting;
88  /* must be last to avoid binary incompatibility.
89  * luckily we just need to make sure this struct does not
90  * get larger than _GPPortSettingsSerial. */
91  char port[64];
93 
98  char path[128];
100 
104 typedef struct _GPPortSettingsUsbScsi {
105  char path[128];
107 
114 typedef union _GPPortSettings {
120 
121 enum {
125 };
126 
127 typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
129 
143 typedef struct _GPPort {
144  /* For your convenience */
150  int timeout;
152  GPPortPrivateLibrary *pl;
154 } GPPort;
155 
156 int gp_port_new (GPPort **port);
157 int gp_port_free (GPPort *port);
158 
159 int gp_port_set_info (GPPort *port, GPPortInfo info);
160 int gp_port_get_info (GPPort *port, GPPortInfo *info);
161 
162 int gp_port_open (GPPort *port);
163 int gp_port_close (GPPort *port);
164 
165 int gp_port_reset (GPPort *port);
166 
167 int gp_port_write (GPPort *port, const char *data, int size);
168 int gp_port_read (GPPort *port, char *data, int size);
169 int gp_port_check_int (GPPort *port, char *data, int size);
170 int gp_port_check_int_fast (GPPort *port, char *data, int size);
171 
172 int gp_port_get_timeout (GPPort *port, int *timeout);
173 int gp_port_set_timeout (GPPort *port, int timeout);
174 
175 int gp_port_set_settings (GPPort *port, GPPortSettings settings);
176 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
177 
184 typedef enum _GPPin {
191 } GPPin;
192 
198 typedef enum _GPLevel {
201 } GPLevel;
202 
203 int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level);
204 int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level);
205 
206 int gp_port_send_break (GPPort *port, int duration);
207 int gp_port_flush (GPPort *port, int direction);
208 
209 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
210 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
211 int gp_port_usb_clear_halt (GPPort *port, int ep);
212 int gp_port_usb_msg_write (GPPort *port, int request, int value,
213  int index, char *bytes, int size);
214 int gp_port_usb_msg_read (GPPort *port, int request, int value,
215  int index, char *bytes, int size);
216 int gp_port_usb_msg_interface_write (GPPort *port, int request,
217  int value, int index, char *bytes, int size);
218 int gp_port_usb_msg_interface_read (GPPort *port, int request,
219  int value, int index, char *bytes, int size);
220 int gp_port_usb_msg_class_write (GPPort *port, int request,
221  int value, int index, char *bytes, int size);
222 int gp_port_usb_msg_class_read (GPPort *port, int request,
223  int value, int index, char *bytes, int size);
224 
225 int gp_port_seek (GPPort *port, int offset, int whence);
226 
227 int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
228  char *cmd, int cmd_size,
229  char *sense, int sense_size,
230  char *data, int data_size);
231 
232 /* Error reporting */
233 int gp_port_set_error (GPPort *port, const char *format, ...)
234 #ifdef __GNUC__
235  __attribute__((__format__(printf,2,3)))
236 #endif
237 ;
238 const char *gp_port_get_error (GPPort *port);
239 
240 /* DEPRECATED */
242 typedef GPPort gp_port;
246 #define PIN_CTS GP_PIN_CTS
247 
248 #ifdef __cplusplus
249 }
250 #endif /* __cplusplus */
251 
252 #endif /* __GPHOTO2_PORT_H__ */