libgphoto2 photo camera library (libgphoto2) API  2.4.11
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 */
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 
97 typedef struct _GPPortSettingsDisk {
98  char mountpoint[128];
100 
105  char path[128];
107 
111 typedef struct _GPPortSettingsUsbScsi {
112  char path[128];
114 
121 typedef union _GPPortSettings {
128 
129 enum {
133 };
134 
135 typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
137 
151 typedef struct _GPPort {
152  /* For your convenience */
158  int timeout;
160  GPPortPrivateLibrary *pl;
162 } GPPort;
163 
164 int gp_port_new (GPPort **port);
165 int gp_port_free (GPPort *port);
166 
167 int gp_port_set_info (GPPort *port, GPPortInfo info);
168 int gp_port_get_info (GPPort *port, GPPortInfo *info);
169 
170 int gp_port_open (GPPort *port);
171 int gp_port_close (GPPort *port);
172 
173 int gp_port_write (GPPort *port, const char *data, int size);
174 int gp_port_read (GPPort *port, char *data, int size);
175 int gp_port_check_int (GPPort *port, char *data, int size);
176 int gp_port_check_int_fast (GPPort *port, char *data, int size);
177 
178 int gp_port_get_timeout (GPPort *port, int *timeout);
179 int gp_port_set_timeout (GPPort *port, int timeout);
180 
181 int gp_port_set_settings (GPPort *port, GPPortSettings settings);
182 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
183 
190 typedef enum _GPPin {
197 } GPPin;
198 
204 typedef enum _GPLevel {
207 } GPLevel;
208 
209 int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level);
210 int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level);
211 
212 int gp_port_send_break (GPPort *port, int duration);
213 int gp_port_flush (GPPort *port, int direction);
214 
215 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
216 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
217 int gp_port_usb_clear_halt (GPPort *port, int ep);
218 int gp_port_usb_msg_write (GPPort *port, int request, int value,
219  int index, char *bytes, int size);
220 int gp_port_usb_msg_read (GPPort *port, int request, int value,
221  int index, char *bytes, int size);
222 int gp_port_usb_msg_interface_write (GPPort *port, int request,
223  int value, int index, char *bytes, int size);
224 int gp_port_usb_msg_interface_read (GPPort *port, int request,
225  int value, int index, char *bytes, int size);
226 int gp_port_usb_msg_class_write (GPPort *port, int request,
227  int value, int index, char *bytes, int size);
228 int gp_port_usb_msg_class_read (GPPort *port, int request,
229  int value, int index, char *bytes, int size);
230 
231 int gp_port_seek (GPPort *port, int offset, int whence);
232 
233 int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
234  char *cmd, int cmd_size,
235  char *sense, int sense_size,
236  char *data, int data_size);
237 
238 /* Error reporting */
239 int gp_port_set_error (GPPort *port, const char *format, ...)
240 #ifdef __GNUC__
241  __attribute__((__format__(printf,2,3)))
242 #endif
243 ;
244 const char *gp_port_get_error (GPPort *port);
245 
246 /* DEPRECATED */
248 typedef GPPort gp_port;
252 #define PIN_CTS GP_PIN_CTS
253 
254 #ifdef __cplusplus
255 }
256 #endif /* __cplusplus */
257 
258 #endif /* __GPHOTO2_PORT_H__ */
259 
260 
int bits
Definition: gphoto2-port.h:69
int gp_port_open(GPPort *port)
Open a port.
Definition: gphoto2-port.c:260
Port settings for the local disk (directories) port.
Definition: gphoto2-port.h:97
int maxpacketsize
Maximum USB packetsize of the IN endpoint. (r/o)
Definition: gphoto2-port.h:86
int gp_port_set_settings(GPPort *port, GPPortSettings settings)
Set port settings.
Definition: gphoto2-port.c:575
GPPortSerialParity parity
Definition: gphoto2-port.h:70
GPPortType type
Actual type of this port.
Definition: gphoto2-port.h:153
Pull to high (nV)
Definition: gphoto2-port.h:206
char mountpoint[128]
Path in the UNIX fs which corresponds to gphoto2 /.
Definition: gphoto2-port.h:98
int gp_port_set_info(GPPort *port, GPPortInfo info)
Configure a port.
Definition: gphoto2-port.c:142
struct _GPPortSettingsUsbDiskDirect GPPortSettingsUsbDiskDirect
Port settings for USB mass storage direct IO ports.
int outep
Bulk OUT endpoint used.
Definition: gphoto2-port.h:80
int gp_port_usb_msg_read(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB control message with input data.
Definition: gphoto2-port.c:888
GPPortSettings settings
Current port settings.
Definition: gphoto2-port.h:155
int interface
USB Interface number used.
Definition: gphoto2-port.h:83
GPPortSettings gp_port_settings
Definition: gphoto2-port.h:250
int gp_port_send_scsi_cmd(GPPort *port, int to_dev, char *cmd, int cmd_size, char *sense, int sense_size, char *data, int data_size)
Send a SCSI command to a port (for usb scsi ports)
Definition: gphoto2-port.c:1126
int gp_port_get_settings(GPPort *port, GPPortSettings *settings)
Get the current port settings.
Definition: gphoto2-port.c:617
struct _GPPortSettingsUsbScsi GPPortSettingsUsbScsi
Port settings for USB Mass Storage raw SCSI ports.
GPPort gp_port
Definition: gphoto2-port.h:248
USB Interrupt ep.
Definition: gphoto2-port.h:132
struct _GPPortSettingsSerial GPPortSettingsSerial
Port settings for serial ports.
GPPortSettings settings_pending
Settings to be committed.
Definition: gphoto2-port.h:156
DTR line.
Definition: gphoto2-port.h:192
int gp_port_get_timeout(GPPort *port, int *timeout)
Get the current port timeout.
Definition: gphoto2-port.c:549
Port settings for USB mass storage direct IO ports.
Definition: gphoto2-port.h:104
int gp_port_set_pin(GPPort *port, GPPin pin, GPLevel level)
Set specified serial PIN to value.
Definition: gphoto2-port.c:690
DSR line.
Definition: gphoto2-port.h:194
int gp_port_new(GPPort **port)
Create new GPPort.
Definition: gphoto2-port.c:83
int gp_port_get_info(GPPort *port, GPPortInfo *info)
Retreives information about the port.
Definition: gphoto2-port.c:241
int gp_port_usb_msg_write(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB control message with output data.
Definition: gphoto2-port.c:853
enum _GPPin GPPin
Serial pins.
USB bulk IN ep.
Definition: gphoto2-port.h:130
union _GPPortSettings GPPortSettings
Union of port settings.
int intep
Interrupt endpoint used.
Definition: gphoto2-port.h:81
Parity is odd.
Definition: gphoto2-port.h:57
enum _GPPortSerialParity GPPortSerialParity
Serial parity.
int gp_port_flush(GPPort *port, int direction)
Flush data on serial port.
Definition: gphoto2-port.c:751
Port settings for serial ports.
Definition: gphoto2-port.h:66
_GPPortSerialParity
Serial parity.
Definition: gphoto2-port.h:53
int gp_port_free(GPPort *port)
Free the port structure.
Definition: gphoto2-port.c:307
GPPortSettingsUsbScsi usbscsi
usb scsi port specific settings
Definition: gphoto2-port.h:126
int gp_port_close(GPPort *port)
Close a port.
Definition: gphoto2-port.c:285
The GPhoto port structure.
Definition: gphoto2-port.h:151
int gp_port_check_int(GPPort *port, char *data, int size)
Check for intterupt.
Definition: gphoto2-port.c:425
Parity is off (disabled)
Definition: gphoto2-port.h:55
int gp_port_check_int_fast(GPPort *port, char *data, int size)
Check for interrupt without wait.
Definition: gphoto2-port.c:463
_GPPin
Serial pins.
Definition: gphoto2-port.h:190
Parity is even.
Definition: gphoto2-port.h:56
Internal private libgphoto2_port data. This structure contains private data.
Definition: gphoto2-port.c:62
Port settings for USB ports.
Definition: gphoto2-port.h:78
GPPortSettingsUSB usb
USB specific settings.
Definition: gphoto2-port.h:123
int gp_port_usb_msg_class_write(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB class control message with output data.
Definition: gphoto2-port.c:1016
_GPLevel
Level to pull specific lines.
Definition: gphoto2-port.h:204
const char * gp_port_get_error(GPPort *port)
Get verbose port error message.
Definition: gphoto2-port.c:1200
GPPortSettingsDisk disk
Disk port specific settings.
Definition: gphoto2-port.h:124
int gp_port_read(GPPort *port, char *data, int size)
Read data from port.
Definition: gphoto2-port.c:388
char port[64]
USB Portname. Specific to lowlevel USB.
Definition: gphoto2-port.h:91
Union of port settings.
Definition: gphoto2-port.h:121
int gp_port_usb_clear_halt(GPPort *port, int ep)
Clear USB endpoint HALT condition.
Definition: gphoto2-port.c:825
int gp_port_usb_find_device(GPPort *port, int idvendor, int idproduct)
Find USB device by vendor/product.
Definition: gphoto2-port.c:779
int config
USB bConfigurationValue used.
Definition: gphoto2-port.h:82
int gp_port_usb_msg_class_read(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB class control message with input data.
Definition: gphoto2-port.c:1053
struct _GPPort GPPort
The GPhoto port structure.
int gp_port_set_timeout(GPPort *port, int timeout)
Set timeout of port.
Definition: gphoto2-port.c:513
GPPortSettingsSerial serial
Serial specific settings.
Definition: gphoto2-port.h:122
int gp_port_usb_find_device_by_class(GPPort *port, int mainclass, int subclass, int protocol)
Find USB device by interface class.
Definition: gphoto2-port.c:803
GPPortPrivateCore * pc
Port library private data pointer.
Definition: gphoto2-port.h:161
int inep
Bulk IN endpoint used.
Definition: gphoto2-port.h:79
int timeout
Port timeout in milliseconds.
Definition: gphoto2-port.h:158
GPPortPrivateLibrary * pl
Camera driver private data pointer.
Definition: gphoto2-port.h:160
int gp_port_usb_msg_interface_read(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB interface control message with input data.
Definition: gphoto2-port.c:969
int gp_port_write(GPPort *port, const char *data, int size)
Writes a specified amount of data to a port.
Definition: gphoto2-port.c:352
int gp_port_usb_msg_interface_write(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB interface control message with output data.
Definition: gphoto2-port.c:932
int altsetting
USB Alternative Setting used.
Definition: gphoto2-port.h:84
int gp_port_seek(GPPort *port, int offset, int whence)
Seek on a port (for usb disk direct ports)
Definition: gphoto2-port.c:1091
char path[128]
Definition: gphoto2-port.h:112
Port settings for USB Mass Storage raw SCSI ports.
Definition: gphoto2-port.h:111
USB bulk OUT ep.
Definition: gphoto2-port.h:131
struct _GPPortSettingsDisk GPPortSettingsDisk
Port settings for the local disk (directories) port.
GPPortSettingsUsbDiskDirect usbdiskdirect
usb disk direct port specific settings
Definition: gphoto2-port.h:125
int gp_port_set_error(GPPort *port, const char *format,...)
Set verbose port error message.
Definition: gphoto2-port.c:1169
RTS line.
Definition: gphoto2-port.h:191
Pull to low (0V)
Definition: gphoto2-port.h:205
enum _GPLevel GPLevel
Level to pull specific lines.
int gp_port_send_break(GPPort *port, int duration)
Send a break over a serial port.
Definition: gphoto2-port.c:725
RING (Modem) line.
Definition: gphoto2-port.h:196
char path[128]
Definition: gphoto2-port.h:105
CTS line.
Definition: gphoto2-port.h:193
Information about the current port.
Definition: gphoto2-port-info-list.h:53
struct _GPPortSettingsUSB GPPortSettingsUSB
Port settings for USB ports.
int speed
Definition: gphoto2-port.h:68
char port[128]
Definition: gphoto2-port.h:67
Carrier Detect line.
Definition: gphoto2-port.h:195
int gp_port_get_pin(GPPort *port, GPPin pin, GPLevel *level)
Get setting of specific serial PIN.
Definition: gphoto2-port.c:636
int stopbits
Definition: gphoto2-port.h:72
GPPortType
The gphoto port type.
Definition: gphoto2-port-info-list.h:34