libgphoto2 photo camera library (libgphoto2) API 2.5.27
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
37extern "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
54{
59
61#define GP_PORT_MAX_BUF_LEN 4096
62
66typedef struct _GPPortSettingsSerial {
67 char port[128];
68 int speed;
69 int bits;
74
78typedef struct _GPPortSettingsUSB {
79 int inep;
80 int outep;
81 int intep;
82 int config;
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
105 char path[128];
107
114typedef union _GPPortSettings {
120
121enum {
126
127typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
129
143typedef struct _GPPort {
144 /* For your convenience */
152 GPPortPrivateLibrary *pl;
155
156int gp_port_new (GPPort **port);
157int gp_port_free (GPPort *port);
158
159int gp_port_set_info (GPPort *port, GPPortInfo info);
160int gp_port_get_info (GPPort *port, GPPortInfo *info);
161
162int gp_port_open (GPPort *port);
163int gp_port_close (GPPort *port);
164
165int gp_port_reset (GPPort *port);
166
167int gp_port_write (GPPort *port, const char *data, int size);
168int gp_port_read (GPPort *port, char *data, int size);
169int gp_port_check_int (GPPort *port, char *data, int size);
170int gp_port_check_int_fast (GPPort *port, char *data, int size);
171
172int gp_port_get_timeout (GPPort *port, int *timeout);
173int gp_port_set_timeout (GPPort *port, int timeout);
174
175int gp_port_set_settings (GPPort *port, GPPortSettings settings);
176int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
177
184typedef enum _GPPin {
192
198typedef enum _GPLevel {
200 GP_LEVEL_HIGH = 1
202
203int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level);
204int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level);
205
206int gp_port_send_break (GPPort *port, int duration);
207int gp_port_flush (GPPort *port, int direction);
208
209int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
210int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
211int gp_port_usb_clear_halt (GPPort *port, int ep);
212int gp_port_usb_msg_write (GPPort *port, int request, int value,
213 int index, char *bytes, int size);
214int gp_port_usb_msg_read (GPPort *port, int request, int value,
215 int index, char *bytes, int size);
216int gp_port_usb_msg_interface_write (GPPort *port, int request,
217 int value, int index, char *bytes, int size);
218int gp_port_usb_msg_interface_read (GPPort *port, int request,
219 int value, int index, char *bytes, int size);
220int gp_port_usb_msg_class_write (GPPort *port, int request,
221 int value, int index, char *bytes, int size);
222int gp_port_usb_msg_class_read (GPPort *port, int request,
223 int value, int index, char *bytes, int size);
224
225int gp_port_seek (GPPort *port, int offset, int whence);
226
227int 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 */
233int gp_port_set_error (GPPort *port, const char *format, ...)
234#ifdef __GNUC__
235 __attribute__((__format__(printf,2,3)))
236#endif
237;
238const char *gp_port_get_error (GPPort *port);
239
240/* DEPRECATED */
246#define PIN_CTS GP_PIN_CTS
247
248#ifdef __cplusplus
249}
250#endif /* __cplusplus */
251
252#endif /* __GPHOTO2_PORT_H__ */
GPPortType
The gphoto port type.
Definition: gphoto2-port-info-list.h:34
int gp_port_check_int(GPPort *port, char *data, int size)
Check for intterupt.
Definition: gphoto2-port.c:463
_GPPortSerialParity
Serial parity.
Definition: gphoto2-port.h:54
@ GP_PORT_SERIAL_PARITY_ODD
Parity is odd.
Definition: gphoto2-port.h:57
@ GP_PORT_SERIAL_PARITY_EVEN
Parity is even.
Definition: gphoto2-port.h:56
@ GP_PORT_SERIAL_PARITY_OFF
Parity is off (disabled)
Definition: gphoto2-port.h:55
int gp_port_write(GPPort *port, const char *data, int size)
Writes a specified amount of data to a port.
Definition: gphoto2-port.c:392
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:1050
int gp_port_reset(GPPort *port)
Reset a port.
Definition: gphoto2-port.c:319
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:864
int gp_port_get_info(GPPort *port, GPPortInfo *info)
Retreives information about the port.
Definition: gphoto2-port.c:255
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:1015
int gp_port_get_timeout(GPPort *port, int *timeout)
Get the current port timeout.
Definition: gphoto2-port.c:568
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:897
GPPortSettings gp_port_settings
Definition: gphoto2-port.h:244
int gp_port_set_info(GPPort *port, GPPortInfo info)
Configure a port.
Definition: gphoto2-port.c:149
union _GPPortSettings GPPortSettings
Union of port settings.
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:937
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:1118
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:814
int gp_port_set_timeout(GPPort *port, int timeout)
Set timeout of port.
Definition: gphoto2-port.c:534
int gp_port_get_pin(GPPort *port, GPPin pin, GPLevel *level)
Get setting of specific serial PIN.
Definition: gphoto2-port.c:651
int gp_port_usb_find_device(GPPort *port, int idvendor, int idproduct)
Find USB device by vendor/product.
Definition: gphoto2-port.c:790
int gp_port_new(GPPort **port)
Create new GPPort.
Definition: gphoto2-port.c:94
GPPort gp_port
Definition: gphoto2-port.h:242
struct _GPPortSettingsUSB GPPortSettingsUSB
Port settings for USB ports.
int gp_port_read(GPPort *port, char *data, int size)
Read data from port.
Definition: gphoto2-port.c:427
const char * gp_port_get_error(GPPort *port)
Get verbose port error message.
Definition: gphoto2-port.c:1210
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:972
_GPLevel
Level to pull specific lines.
Definition: gphoto2-port.h:198
@ GP_LEVEL_HIGH
Pull to high (nV)
Definition: gphoto2-port.h:200
@ GP_LEVEL_LOW
Pull to low (0V)
Definition: gphoto2-port.h:199
int gp_port_set_settings(GPPort *port, GPPortSettings settings)
Set port settings.
Definition: gphoto2-port.c:590
int gp_port_open(GPPort *port)
Open a port.
Definition: gphoto2-port.c:273
int gp_port_set_error(GPPort *port, const char *format,...)
Set verbose port error message.
Definition: gphoto2-port.c:1180
struct _GPPortSettingsSerial GPPortSettingsSerial
Port settings for serial ports.
enum _GPPortSerialParity GPPortSerialParity
Serial parity.
int gp_port_check_int_fast(GPPort *port, char *data, int size)
Check for interrupt without wait.
Definition: gphoto2-port.c:496
int gp_port_send_break(GPPort *port, int duration)
Send a break over a serial port.
Definition: gphoto2-port.c:737
_GPPin
Serial pins.
Definition: gphoto2-port.h:184
@ GP_PIN_CD
Carrier Detect line.
Definition: gphoto2-port.h:189
@ GP_PIN_DTR
DTR line.
Definition: gphoto2-port.h:186
@ GP_PIN_CTS
CTS line.
Definition: gphoto2-port.h:187
@ GP_PIN_DSR
DSR line.
Definition: gphoto2-port.h:188
@ GP_PIN_RTS
RTS line.
Definition: gphoto2-port.h:185
@ GP_PIN_RING
RING (Modem) line.
Definition: gphoto2-port.h:190
int gp_port_get_settings(GPPort *port, GPPortSettings *settings)
Get the current port settings.
Definition: gphoto2-port.c:632
int gp_port_free(GPPort *port)
Free the port structure.
Definition: gphoto2-port.c:341
struct _GPPortSettingsUsbScsi GPPortSettingsUsbScsi
Port settings for USB Mass Storage raw SCSI ports.
enum _GPLevel GPLevel
Level to pull specific lines.
struct _GPPort GPPort
The GPhoto port structure.
int gp_port_close(GPPort *port)
Close a port.
Definition: gphoto2-port.c:297
int gp_port_seek(GPPort *port, int offset, int whence)
Seek on a port (for usb disk direct ports)
Definition: gphoto2-port.c:1084
int gp_port_flush(GPPort *port, int direction)
Flush data on serial port.
Definition: gphoto2-port.c:762
@ GP_PORT_USB_ENDPOINT_OUT
USB bulk OUT ep.
Definition: gphoto2-port.h:123
@ GP_PORT_USB_ENDPOINT_INT
USB Interrupt ep.
Definition: gphoto2-port.h:124
@ GP_PORT_USB_ENDPOINT_IN
USB bulk IN ep.
Definition: gphoto2-port.h:122
enum _GPPin GPPin
Serial pins.
struct _GPPortSettingsUsbDiskDirect GPPortSettingsUsbDiskDirect
Port settings for USB mass storage direct IO ports.
int gp_port_usb_clear_halt(GPPort *port, int ep)
Clear USB endpoint HALT condition.
Definition: gphoto2-port.c:836
int gp_port_set_pin(GPPort *port, GPPin pin, GPLevel level)
Set specified serial PIN to value.
Definition: gphoto2-port.c:703
Definition: gphoto2-port-info.h:32
Internal private libgphoto2_port data. This structure contains private data.
Definition: gphoto2-port.c:73
Port settings for serial ports.
Definition: gphoto2-port.h:66
char port[128]
Definition: gphoto2-port.h:67
GPPortSerialParity parity
Definition: gphoto2-port.h:70
int bits
Definition: gphoto2-port.h:69
int speed
Definition: gphoto2-port.h:68
int stopbits
Definition: gphoto2-port.h:72
Port settings for USB ports.
Definition: gphoto2-port.h:78
int outep
Bulk OUT endpoint used.
Definition: gphoto2-port.h:80
int inep
Bulk IN endpoint used.
Definition: gphoto2-port.h:79
int config
USB bConfigurationValue used.
Definition: gphoto2-port.h:82
char port[64]
USB Portname. Specific to lowlevel USB.
Definition: gphoto2-port.h:91
int maxpacketsize
Maximum USB packetsize of the IN endpoint. (r/o)
Definition: gphoto2-port.h:86
int interface
USB Interface number used.
Definition: gphoto2-port.h:83
int intep
Interrupt endpoint used.
Definition: gphoto2-port.h:81
int altsetting
USB Alternative Setting used.
Definition: gphoto2-port.h:84
Port settings for USB mass storage direct IO ports.
Definition: gphoto2-port.h:97
char path[128]
Definition: gphoto2-port.h:98
Port settings for USB Mass Storage raw SCSI ports.
Definition: gphoto2-port.h:104
char path[128]
Definition: gphoto2-port.h:105
The GPhoto port structure.
Definition: gphoto2-port.h:143
GPPortSettings settings_pending
Settings to be committed.
Definition: gphoto2-port.h:148
GPPortPrivateCore * pc
Port library private data pointer.
Definition: gphoto2-port.h:153
int timeout
Port timeout in milliseconds.
Definition: gphoto2-port.h:150
GPPortPrivateLibrary * pl
Camera driver private data pointer.
Definition: gphoto2-port.h:152
GPPortSettings settings
Current port settings.
Definition: gphoto2-port.h:147
GPPortType type
Actual type of this port.
Definition: gphoto2-port.h:145
Union of port settings.
Definition: gphoto2-port.h:114
GPPortSettingsUSB usb
USB specific settings.
Definition: gphoto2-port.h:116
GPPortSettingsUsbScsi usbscsi
usb scsi port specific settings
Definition: gphoto2-port.h:118
GPPortSettingsUsbDiskDirect usbdiskdirect
usb disk direct port specific settings
Definition: gphoto2-port.h:117
GPPortSettingsSerial serial
Serial specific settings.
Definition: gphoto2-port.h:115