libgphoto2 photo camera library (libgphoto2) API: libgphoto2_port/gphoto2/gphoto2-port.h Source File

libgphoto2 photo camera library (libgphoto2) API 2.5.34

Loading...
Searching...
No Matches
gphoto2-port.h
Go to the documentation of this file.
1
23
24#ifndef LIBGPHOTO2_GPHOTO2_PORT_H
25#define LIBGPHOTO2_GPHOTO2_PORT_H
26
27#include <gphoto2/gphoto2-port-info-list.h>
28
29/* For portability */
30#include <gphoto2/gphoto2-port-portability.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
36#ifndef TRUE
37#define TRUE (0==0)
38#endif
39
40#ifndef FALSE
41#define FALSE (1==0)
42#endif
43
49 typedef enum _GPPortSerialParity
50{
51 GP_PORT_SERIAL_PARITY_OFF = 0,
52 GP_PORT_SERIAL_PARITY_EVEN,
53 GP_PORT_SERIAL_PARITY_ODD
54} GPPortSerialParity;
55
57#define GP_PORT_MAX_BUF_LEN 4096
58
62 typedef struct _GPPortSettingsSerial {
63 char port[128];
64 int speed;
65 int bits;
66 GPPortSerialParity parity;
68 int stopbits;
69} GPPortSettingsSerial;
70
74 typedef struct _GPPortSettingsUSB {
75 int inep;
76 int outep;
77 int intep;
78 int config;
79 int interface;
80 int altsetting;
81
82 int maxpacketsize;
83
84 /* must be last to avoid binary incompatibility.
85 * luckily we just need to make sure this struct does not
86 * get larger than _GPPortSettingsSerial. */
87 char port[64];
88} GPPortSettingsUSB;
89
93 typedef struct _GPPortSettingsUsbDiskDirect {
94 char path[128];
95} GPPortSettingsUsbDiskDirect;
96
100 typedef struct _GPPortSettingsUsbScsi {
101 char path[128];
102} GPPortSettingsUsbScsi;
103
110 typedef union _GPPortSettings {
111 GPPortSettingsSerial serial;
112 GPPortSettingsUSB usb;
113 GPPortSettingsUsbDiskDirect usbdiskdirect;
114 GPPortSettingsUsbScsi usbscsi;
115} GPPortSettings;
116
117enum {
118 GP_PORT_USB_ENDPOINT_IN,
119 GP_PORT_USB_ENDPOINT_OUT,
120 GP_PORT_USB_ENDPOINT_INT
121};
122
123typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
124typedef struct _GPPortPrivateCore GPPortPrivateCore;
125
139 typedef struct _GPPort {
140 /* For your convenience */
141 GPPortType type;
142
143 GPPortSettings settings;
144 GPPortSettings settings_pending;
145
146 int timeout;
147
148 GPPortPrivateLibrary *pl;
149 GPPortPrivateCore *pc;
150} GPPort;
151
152int gp_port_new (GPPort **port);
153int gp_port_free (GPPort *port);
154
155int gp_port_set_info (GPPort *port, GPPortInfo info);
156int gp_port_get_info (GPPort *port, GPPortInfo *info);
157
158int gp_port_open (GPPort *port);
159int gp_port_close (GPPort *port);
160
161int gp_port_reset (GPPort *port);
162
163int gp_port_write (GPPort *port, const char *data, int size);
164int gp_port_read (GPPort *port, char *data, int size);
165int gp_port_check_int (GPPort *port, char *data, int size);
166int gp_port_check_int_fast (GPPort *port, char *data, int size);
167
168int gp_port_get_timeout (GPPort *port, int *timeout);
169int gp_port_set_timeout (GPPort *port, int timeout);
170
171int gp_port_set_settings (GPPort *port, GPPortSettings settings);
172int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
173
180 typedef enum _GPPin {
181 GP_PIN_RTS,
182 GP_PIN_DTR,
183 GP_PIN_CTS,
184 GP_PIN_DSR,
185 GP_PIN_CD,
186 GP_PIN_RING
187} GPPin;
188
194 typedef enum _GPLevel {
195 GP_LEVEL_LOW = 0,
196 GP_LEVEL_HIGH = 1
197} GPLevel;
198
199int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level);
200int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level);
201
202int gp_port_send_break (GPPort *port, int duration);
203int gp_port_flush (GPPort *port, int direction);
204
213int gp_port_usb_set_sys_device(int fd);
214
218int gp_port_usb_get_sys_device(void);
219
220int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
221int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
222int gp_port_usb_clear_halt (GPPort *port, int ep);
223int gp_port_usb_msg_write (GPPort *port, int request, int value,
224 int index, char *bytes, int size);
225int gp_port_usb_msg_read (GPPort *port, int request, int value,
226 int index, char *bytes, int size);
227int gp_port_usb_msg_interface_write (GPPort *port, int request,
228 int value, int index, char *bytes, int size);
229int gp_port_usb_msg_interface_read (GPPort *port, int request,
230 int value, int index, char *bytes, int size);
231int gp_port_usb_msg_class_write (GPPort *port, int request,
232 int value, int index, char *bytes, int size);
233int gp_port_usb_msg_class_read (GPPort *port, int request,
234 int value, int index, char *bytes, int size);
235
236int gp_port_seek (GPPort *port, int offset, int whence);
237
238int gp_port_send_scsi_cmd (GPPort *port, int to_dev,
239 char *cmd, int cmd_size,
240 char *sense, int sense_size,
241 char *data, int data_size);
242
243/* Error reporting */
244int gp_port_set_error (GPPort *port, const char *format, ...)
245#ifdef __GNUC__
246 __attribute__((__format__(printf,2,3)))
247#endif
248;
249const char *gp_port_get_error (GPPort *port);
250
251/* DEPRECATED */
253 typedef GPPort gp_port;
255 typedef GPPortSettings gp_port_settings;
257#define PIN_CTS GP_PIN_CTS
258
259#ifdef __cplusplus
260}
261#endif /* __cplusplus */
262
263#endif /* !defined(LIBGPHOTO2_GPHOTO2_PORT_H) */
gphoto2-port-info-list.h
GPPortType
GPPortType
The gphoto port type.
Definition gphoto2-port-info-list.h:34
gp_port_check_int
int gp_port_check_int(GPPort *port, char *data, int size)
Check for interrupt.
Definition gphoto2-port.c:464
_GPPortSerialParity
_GPPortSerialParity
Serial parity.
Definition gphoto2-port.h:50
GP_PORT_SERIAL_PARITY_ODD
@ GP_PORT_SERIAL_PARITY_ODD
Parity is odd.
Definition gphoto2-port.h:53
GP_PORT_SERIAL_PARITY_EVEN
@ GP_PORT_SERIAL_PARITY_EVEN
Parity is even.
Definition gphoto2-port.h:52
GP_PORT_SERIAL_PARITY_OFF
@ GP_PORT_SERIAL_PARITY_OFF
Parity is off (disabled).
Definition gphoto2-port.h:51
gp_port_write
int gp_port_write(GPPort *port, const char *data, int size)
Writes a specified amount of data to a port.
Definition gphoto2-port.c:393
gp_port_usb_msg_class_read
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:1051
gp_port_reset
int gp_port_reset(GPPort *port)
Reset a port.
Definition gphoto2-port.c:318
gp_port_usb_msg_write
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:865
gp_port_get_info
int gp_port_get_info(GPPort *port, GPPortInfo *info)
Retrieves information about the port.
Definition gphoto2-port.c:254
gp_port_usb_msg_class_write
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
gp_port_get_timeout
int gp_port_get_timeout(GPPort *port, int *timeout)
Get the current port timeout.
Definition gphoto2-port.c:569
gp_port_usb_msg_read
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:898
gp_port_usb_set_sys_device
int gp_port_usb_set_sys_device(int fd)
Allow using file descriptor of USB device without auto-discovery.
Definition gphoto2-port.c:1237
gp_port_settings
GPPortSettings gp_port_settings
Definition gphoto2-port.h:255
gp_port_set_info
int gp_port_set_info(GPPort *port, GPPortInfo info)
Configure a port.
Definition gphoto2-port.c:138
GPPortSettings
union _GPPortSettings GPPortSettings
Union of port settings.
gp_port_usb_msg_interface_write
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:938
gp_port_send_scsi_cmd
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:1119
gp_port_usb_find_device_by_class
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:815
GP_PORT_USB_ENDPOINT_OUT
@ GP_PORT_USB_ENDPOINT_OUT
USB bulk OUT ep.
Definition gphoto2-port.h:119
GP_PORT_USB_ENDPOINT_INT
@ GP_PORT_USB_ENDPOINT_INT
USB Interrupt ep.
Definition gphoto2-port.h:120
GP_PORT_USB_ENDPOINT_IN
@ GP_PORT_USB_ENDPOINT_IN
USB bulk IN ep.
Definition gphoto2-port.h:118
gp_port_set_timeout
int gp_port_set_timeout(GPPort *port, int timeout)
Set timeout of port.
Definition gphoto2-port.c:535
gp_port_get_pin
int gp_port_get_pin(GPPort *port, GPPin pin, GPLevel *level)
Get setting of specific serial PIN.
Definition gphoto2-port.c:652
gp_port_usb_find_device
int gp_port_usb_find_device(GPPort *port, int idvendor, int idproduct)
Find USB device by vendor/product.
Definition gphoto2-port.c:791
gp_port_new
int gp_port_new(GPPort **port)
Create new GPPort.
Definition gphoto2-port.c:83
gp_port
GPPort gp_port
Definition gphoto2-port.h:253
GPPortSettingsUSB
struct _GPPortSettingsUSB GPPortSettingsUSB
Port settings for USB ports.
gp_port_read
int gp_port_read(GPPort *port, char *data, int size)
Read data from port.
Definition gphoto2-port.c:428
gp_port_get_error
const char * gp_port_get_error(GPPort *port)
Get verbose port error message.
Definition gphoto2-port.c:1211
gp_port_usb_msg_interface_read
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:973
_GPLevel
_GPLevel
Level to pull specific lines.
Definition gphoto2-port.h:194
GP_LEVEL_HIGH
@ GP_LEVEL_HIGH
Pull to high (nV).
Definition gphoto2-port.h:196
GP_LEVEL_LOW
@ GP_LEVEL_LOW
Pull to low (0V).
Definition gphoto2-port.h:195
gp_port_set_settings
int gp_port_set_settings(GPPort *port, GPPortSettings settings)
Set port settings.
Definition gphoto2-port.c:591
gp_port_open
int gp_port_open(GPPort *port)
Open a port.
Definition gphoto2-port.c:272
gp_port_set_error
int gp_port_set_error(GPPort *port, const char *format,...)
Set verbose port error message.
Definition gphoto2-port.c:1181
GPPortSettingsSerial
struct _GPPortSettingsSerial GPPortSettingsSerial
Port settings for serial ports.
GPPortSerialParity
enum _GPPortSerialParity GPPortSerialParity
Serial parity.
gp_port_usb_get_sys_device
int gp_port_usb_get_sys_device(void)
Get externally set file descriptor of USB device, return -1 if not set.
Definition gphoto2-port.c:1242
gp_port_check_int_fast
int gp_port_check_int_fast(GPPort *port, char *data, int size)
Check for interrupt without wait.
Definition gphoto2-port.c:497
gp_port_send_break
int gp_port_send_break(GPPort *port, int duration)
Send a break over a serial port.
Definition gphoto2-port.c:738
_GPPin
_GPPin
Serial pins.
Definition gphoto2-port.h:180
GP_PIN_CD
@ GP_PIN_CD
Carrier Detect line.
Definition gphoto2-port.h:185
GP_PIN_DTR
@ GP_PIN_DTR
DTR line.
Definition gphoto2-port.h:182
GP_PIN_CTS
@ GP_PIN_CTS
CTS line.
Definition gphoto2-port.h:183
GP_PIN_DSR
@ GP_PIN_DSR
DSR line.
Definition gphoto2-port.h:184
GP_PIN_RTS
@ GP_PIN_RTS
RTS line.
Definition gphoto2-port.h:181
GP_PIN_RING
@ GP_PIN_RING
RING (Modem) line.
Definition gphoto2-port.h:186
gp_port_get_settings
int gp_port_get_settings(GPPort *port, GPPortSettings *settings)
Get the current port settings.
Definition gphoto2-port.c:633
gp_port_free
int gp_port_free(GPPort *port)
Free the port structure.
Definition gphoto2-port.c:340
GPPortSettingsUsbScsi
struct _GPPortSettingsUsbScsi GPPortSettingsUsbScsi
Port settings for USB Mass Storage raw SCSI ports.
GPLevel
enum _GPLevel GPLevel
Level to pull specific lines.
GPPort
struct _GPPort GPPort
The GPhoto port structure.
gp_port_close
int gp_port_close(GPPort *port)
Close a port.
Definition gphoto2-port.c:296
gp_port_seek
int gp_port_seek(GPPort *port, int offset, int whence)
Seek on a port (for usb disk direct ports).
Definition gphoto2-port.c:1085
gp_port_flush
int gp_port_flush(GPPort *port, int direction)
Flush data on serial port.
Definition gphoto2-port.c:763
GPPin
enum _GPPin GPPin
Serial pins.
GPPortSettingsUsbDiskDirect
struct _GPPortSettingsUsbDiskDirect GPPortSettingsUsbDiskDirect
Port settings for USB mass storage direct IO ports.
gp_port_usb_clear_halt
int gp_port_usb_clear_halt(GPPort *port, int ep)
Clear USB endpoint HALT condition.
Definition gphoto2-port.c:837
gp_port_set_pin
int gp_port_set_pin(GPPort *port, GPPin pin, GPLevel level)
Set specified serial PIN to value.
Definition gphoto2-port.c:704
_GPPortPrivateCore
Internal private libgphoto2_port data. This structure contains private data.
Definition gphoto2-port.c:62
_GPPortSettingsSerial
Port settings for serial ports.
Definition gphoto2-port.h:62
_GPPortSettingsSerial::port
char port[128]
Definition gphoto2-port.h:63
_GPPortSettingsSerial::parity
GPPortSerialParity parity
Definition gphoto2-port.h:66
_GPPortSettingsSerial::bits
int bits
Definition gphoto2-port.h:65
_GPPortSettingsSerial::speed
int speed
Definition gphoto2-port.h:64
_GPPortSettingsSerial::stopbits
int stopbits
Definition gphoto2-port.h:68
_GPPortSettingsUSB
Port settings for USB ports.
Definition gphoto2-port.h:74
_GPPortSettingsUSB::outep
int outep
Bulk OUT endpoint used.
Definition gphoto2-port.h:76
_GPPortSettingsUSB::inep
int inep
Bulk IN endpoint used.
Definition gphoto2-port.h:75
_GPPortSettingsUSB::config
int config
USB bConfigurationValue used.
Definition gphoto2-port.h:78
_GPPortSettingsUSB::port
char port[64]
USB Portname. Specific to lowlevel USB.
Definition gphoto2-port.h:87
_GPPortSettingsUSB::maxpacketsize
int maxpacketsize
Maximum USB packetsize of the IN endpoint. (r/o).
Definition gphoto2-port.h:82
_GPPortSettingsUSB::interface
int interface
USB Interface number used.
Definition gphoto2-port.h:79
_GPPortSettingsUSB::intep
int intep
Interrupt endpoint used.
Definition gphoto2-port.h:77
_GPPortSettingsUSB::altsetting
int altsetting
USB Alternative Setting used.
Definition gphoto2-port.h:80
_GPPortSettingsUsbDiskDirect
Port settings for USB mass storage direct IO ports.
Definition gphoto2-port.h:93
_GPPortSettingsUsbDiskDirect::path
char path[128]
Definition gphoto2-port.h:94
_GPPortSettingsUsbScsi
Port settings for USB Mass Storage raw SCSI ports.
Definition gphoto2-port.h:100
_GPPortSettingsUsbScsi::path
char path[128]
Definition gphoto2-port.h:101
_GPPort
The GPhoto port structure.
Definition gphoto2-port.h:139
_GPPort::settings_pending
GPPortSettings settings_pending
Settings to be committed.
Definition gphoto2-port.h:144
_GPPort::pc
GPPortPrivateCore * pc
Port library private data pointer.
Definition gphoto2-port.h:149
_GPPort::timeout
int timeout
Port timeout in milliseconds.
Definition gphoto2-port.h:146
_GPPort::pl
GPPortPrivateLibrary * pl
Camera driver private data pointer.
Definition gphoto2-port.h:148
_GPPort::settings
GPPortSettings settings
Current port settings.
Definition gphoto2-port.h:143
_GPPort::type
GPPortType type
Actual type of this port.
Definition gphoto2-port.h:141
_GPPortSettings
Union of port settings.
Definition gphoto2-port.h:110
_GPPortSettings::usb
GPPortSettingsUSB usb
USB specific settings.
Definition gphoto2-port.h:112
_GPPortSettings::usbscsi
GPPortSettingsUsbScsi usbscsi
usb scsi port specific settings
Definition gphoto2-port.h:114
_GPPortSettings::usbdiskdirect
GPPortSettingsUsbDiskDirect usbdiskdirect
usb disk direct port specific settings
Definition gphoto2-port.h:113
_GPPortSettings::serial
GPPortSettingsSerial serial
Serial specific settings.
Definition gphoto2-port.h:111