gphoto2-port.h
Go to the documentation of this file.
#ifndef __GPHOTO2_PORT_H__
#define __GPHOTO2_PORT_H__
#include <gphoto2/gphoto2-port-info-list.h>
/* For portability */
#include <gphoto2/gphoto2-port-portability.h>
#ifdef OS2
#include <gphoto2/gphoto2-port-portability-os2.h>
#include <os2.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef TRUE
#define TRUE (0==0)
#endif
#ifndef FALSE
#define FALSE (1==0)
#endif
typedef enum _GPPortSerialParity
{
GP_PORT_SERIAL_PARITY_OFF = 0,
GP_PORT_SERIAL_PARITY_EVEN,
GP_PORT_SERIAL_PARITY_ODD
} GPPortSerialParity;
#define GP_PORT_MAX_BUF_LEN 4096
typedef struct _GPPortSettingsSerial {
char port[128];
int speed;
int bits;
GPPortSerialParity parity;
int stopbits;
} GPPortSettingsSerial;
typedef struct _GPPortSettingsUSB {
int inep;
int outep;
int intep;
int config;
int interface;
int altsetting;
int maxpacketsize;
/* must be last to avoid binary incompatibility.
* luckily we just need to make sure this struct does not
* get larger than _GPPortSettingsSerial. */
char port[64];
} GPPortSettingsUSB;
typedef struct _GPPortSettingsUsbDiskDirect {
char path[128];
} GPPortSettingsUsbDiskDirect;
typedef struct _GPPortSettingsUsbScsi {
char path[128];
} GPPortSettingsUsbScsi;
typedef union _GPPortSettings {
GPPortSettingsSerial serial;
GPPortSettingsUSB usb;
GPPortSettingsUsbDiskDirect usbdiskdirect;
GPPortSettingsUsbScsi usbscsi;
} GPPortSettings;
enum {
GP_PORT_USB_ENDPOINT_IN,
GP_PORT_USB_ENDPOINT_OUT,
GP_PORT_USB_ENDPOINT_INT
};
typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
typedef struct _GPPortPrivateCore GPPortPrivateCore;
typedef struct _GPPort {
/* For your convenience */
GPPortType type;
GPPortSettings settings;
GPPortSettings settings_pending;
int timeout;
GPPortPrivateLibrary *pl;
GPPortPrivateCore *pc;
} GPPort;
int gp_port_new (GPPort **port);
int gp_port_free (GPPort *port);
int gp_port_set_info (GPPort *port, GPPortInfo info);
int gp_port_get_info (GPPort *port, GPPortInfo *info);
int gp_port_open (GPPort *port);
int gp_port_close (GPPort *port);
int gp_port_reset (GPPort *port);
int gp_port_write (GPPort *port, const char *data, int size);
int gp_port_read (GPPort *port, char *data, int size);
int gp_port_check_int (GPPort *port, char *data, int size);
int gp_port_check_int_fast (GPPort *port, char *data, int size);
int gp_port_get_timeout (GPPort *port, int *timeout);
int gp_port_set_timeout (GPPort *port, int timeout);
int gp_port_set_settings (GPPort *port, GPPortSettings settings);
int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
typedef enum _GPPin {
GP_PIN_RTS,
GP_PIN_DTR,
GP_PIN_CTS,
GP_PIN_DSR,
GP_PIN_CD,
GP_PIN_RING
} GPPin;
typedef enum _GPLevel {
GP_LEVEL_LOW = 0,
GP_LEVEL_HIGH = 1
} GPLevel;
int gp_port_get_pin (GPPort *port, GPPin pin, GPLevel *level);
int gp_port_set_pin (GPPort *port, GPPin pin, GPLevel level);
int gp_port_send_break (GPPort *port, int duration);
int gp_port_flush (GPPort *port, int direction);
int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
int gp_port_usb_clear_halt (GPPort *port, int ep);
int gp_port_usb_msg_write (GPPort *port, int request, int value,
int index, char *bytes, int size);
int gp_port_usb_msg_read (GPPort *port, int request, int value,
int index, char *bytes, int size);
int gp_port_usb_msg_interface_write (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_usb_msg_interface_read (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_usb_msg_class_write (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_usb_msg_class_read (GPPort *port, int request,
int value, int index, char *bytes, int size);
int gp_port_seek (GPPort *port, int offset, int whence);
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);
/* Error reporting */
int gp_port_set_error (GPPort *port, const char *format, ...)
#ifdef __GNUC__
__attribute__((__format__(printf,2,3)))
#endif
;
const char *gp_port_get_error (GPPort *port);
/* DEPRECATED */
typedef GPPort gp_port;
typedef GPPortSettings gp_port_settings;
#define PIN_CTS GP_PIN_CTS
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GPHOTO2_PORT_H__ */
_GPPortSettingsSerial::bits
int bits
Definition: gphoto2-port.h:69
gp_port_open
int gp_port_open(GPPort *port)
Open a port.
Definition: gphoto2-port.c:269
_GPPortSettingsUSB::maxpacketsize
int maxpacketsize
Maximum USB packetsize of the IN endpoint. (r/o)
Definition: gphoto2-port.h:86
gp_port_set_settings
int gp_port_set_settings(GPPort *port, GPPortSettings settings)
Set port settings.
Definition: gphoto2-port.c:586
_GPPortSettingsSerial::parity
GPPortSerialParity parity
Definition: gphoto2-port.h:70
_GPPort::type
GPPortType type
Actual type of this port.
Definition: gphoto2-port.h:145
GP_LEVEL_HIGH
Pull to high (nV)
Definition: gphoto2-port.h:200
gp_port_set_info
int gp_port_set_info(GPPort *port, GPPortInfo info)
Configure a port.
Definition: gphoto2-port.c:149
GPPortSettingsUsbDiskDirect
struct _GPPortSettingsUsbDiskDirect GPPortSettingsUsbDiskDirect
Port settings for USB mass storage direct IO ports.
_GPPortSettingsUSB::outep
int outep
Bulk OUT endpoint used.
Definition: gphoto2-port.h:80
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:893
_GPPort::settings
GPPortSettings settings
Current port settings.
Definition: gphoto2-port.h:147
_GPPortSettingsUSB::interface
int interface
USB Interface number used.
Definition: gphoto2-port.h:83
gp_port_settings
GPPortSettings gp_port_settings
Definition: gphoto2-port.h:244
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:1114
gp_port_get_settings
int gp_port_get_settings(GPPort *port, GPPortSettings *settings)
Get the current port settings.
Definition: gphoto2-port.c:628
GPPortSettingsUsbScsi
struct _GPPortSettingsUsbScsi GPPortSettingsUsbScsi
Port settings for USB Mass Storage raw SCSI ports.
gp_port
GPPort gp_port
Definition: gphoto2-port.h:242
GPPortSettingsSerial
struct _GPPortSettingsSerial GPPortSettingsSerial
Port settings for serial ports.
_GPPort::settings_pending
GPPortSettings settings_pending
Settings to be committed.
Definition: gphoto2-port.h:148
GP_PIN_DTR
DTR line.
Definition: gphoto2-port.h:186
gp_port_get_timeout
int gp_port_get_timeout(GPPort *port, int *timeout)
Get the current port timeout.
Definition: gphoto2-port.c:564
_GPPortSettingsUsbDiskDirect
Port settings for USB mass storage direct IO ports.
Definition: gphoto2-port.h:97
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:699
GP_PIN_DSR
DSR line.
Definition: gphoto2-port.h:188
gp_port_new
int gp_port_new(GPPort **port)
Create new GPPort.
Definition: gphoto2-port.c:94
gp_port_get_info
int gp_port_get_info(GPPort *port, GPPortInfo *info)
Retreives information about the port.
Definition: gphoto2-port.c:251
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:860
GPPin
enum _GPPin GPPin
Serial pins.
GPPortSettings
union _GPPortSettings GPPortSettings
Union of port settings.
_GPPortSettingsUSB::intep
int intep
Interrupt endpoint used.
Definition: gphoto2-port.h:81
GP_PORT_SERIAL_PARITY_ODD
Parity is odd.
Definition: gphoto2-port.h:57
GPPortSerialParity
enum _GPPortSerialParity GPPortSerialParity
Serial parity.
gp_port_flush
int gp_port_flush(GPPort *port, int direction)
Flush data on serial port.
Definition: gphoto2-port.c:758
_GPPortSettingsSerial
Port settings for serial ports.
Definition: gphoto2-port.h:66
_GPPortSerialParity
_GPPortSerialParity
Serial parity.
Definition: gphoto2-port.h:53
gp_port_free
int gp_port_free(GPPort *port)
Free the port structure.
Definition: gphoto2-port.c:337
_GPPortSettings::usbscsi
GPPortSettingsUsbScsi usbscsi
usb scsi port specific settings
Definition: gphoto2-port.h:118
gp_port_close
int gp_port_close(GPPort *port)
Close a port.
Definition: gphoto2-port.c:293
_GPPort
The GPhoto port structure.
Definition: gphoto2-port.h:143
gp_port_check_int
int gp_port_check_int(GPPort *port, char *data, int size)
Check for intterupt.
Definition: gphoto2-port.c:459
gp_port_reset
int gp_port_reset(GPPort *port)
Reset a port.
Definition: gphoto2-port.c:315
GP_PORT_SERIAL_PARITY_OFF
Parity is off (disabled)
Definition: gphoto2-port.h:55
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:492
_GPPin
_GPPin
Serial pins.
Definition: gphoto2-port.h:184
GP_PORT_SERIAL_PARITY_EVEN
Parity is even.
Definition: gphoto2-port.h:56
_GPPortPrivateCore
Internal private libgphoto2_port data. This structure contains private data.
Definition: gphoto2-port.c:73
_GPPortSettingsUSB
Port settings for USB ports.
Definition: gphoto2-port.h:78
_GPPortSettings::usb
GPPortSettingsUSB usb
USB specific settings.
Definition: gphoto2-port.h:116
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:1011
_GPLevel
_GPLevel
Level to pull specific lines.
Definition: gphoto2-port.h:198
gp_port_get_error
const char * gp_port_get_error(GPPort *port)
Get verbose port error message.
Definition: gphoto2-port.c:1206
gp_port_read
int gp_port_read(GPPort *port, char *data, int size)
Read data from port.
Definition: gphoto2-port.c:423
_GPPortSettingsUSB::port
char port[64]
USB Portname. Specific to lowlevel USB.
Definition: gphoto2-port.h:91
_GPPortSettings
Union of port settings.
Definition: gphoto2-port.h:114
gp_port_usb_clear_halt
int gp_port_usb_clear_halt(GPPort *port, int ep)
Clear USB endpoint HALT condition.
Definition: gphoto2-port.c:832
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:786
_GPPortSettingsUSB::config
int config
USB bConfigurationValue used.
Definition: gphoto2-port.h:82
GP_PORT_USB_ENDPOINT_IN
USB bulk IN ep.
Definition: gphoto2-port.h:122
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:1046
gphoto2-port-info-list.h
GPPort
struct _GPPort GPPort
The GPhoto port structure.
gp_port_set_timeout
int gp_port_set_timeout(GPPort *port, int timeout)
Set timeout of port.
Definition: gphoto2-port.c:530
_GPPortSettings::serial
GPPortSettingsSerial serial
Serial specific settings.
Definition: gphoto2-port.h:115
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:810
_GPPort::pc
GPPortPrivateCore * pc
Port library private data pointer.
Definition: gphoto2-port.h:153
_GPPortSettingsUSB::inep
int inep
Bulk IN endpoint used.
Definition: gphoto2-port.h:79
_GPPort::timeout
int timeout
Port timeout in milliseconds.
Definition: gphoto2-port.h:150
_GPPort::pl
GPPortPrivateLibrary * pl
Camera driver private data pointer.
Definition: gphoto2-port.h:152
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:968
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:388
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:933
GP_PORT_USB_ENDPOINT_INT
USB Interrupt ep.
Definition: gphoto2-port.h:124
_GPPortSettingsUSB::altsetting
int altsetting
USB Alternative Setting used.
Definition: gphoto2-port.h:84
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:1080
_GPPortSettingsUsbScsi::path
char path[128]
Definition: gphoto2-port.h:105
_GPPortSettingsUsbScsi
Port settings for USB Mass Storage raw SCSI ports.
Definition: gphoto2-port.h:104
_GPPortSettings::usbdiskdirect
GPPortSettingsUsbDiskDirect usbdiskdirect
usb disk direct port specific settings
Definition: gphoto2-port.h:117
gp_port_set_error
int gp_port_set_error(GPPort *port, const char *format,...)
Set verbose port error message.
Definition: gphoto2-port.c:1176
GP_PIN_RTS
RTS line.
Definition: gphoto2-port.h:185
GP_LEVEL_LOW
Pull to low (0V)
Definition: gphoto2-port.h:199
GPLevel
enum _GPLevel GPLevel
Level to pull specific lines.
gp_port_send_break
int gp_port_send_break(GPPort *port, int duration)
Send a break over a serial port.
Definition: gphoto2-port.c:733
GP_PIN_RING
RING (Modem) line.
Definition: gphoto2-port.h:190
_GPPortSettingsUsbDiskDirect::path
char path[128]
Definition: gphoto2-port.h:98
GP_PIN_CTS
CTS line.
Definition: gphoto2-port.h:187
_GPPortInfo
Definition: gphoto2-port-info.h:32
GPPortSettingsUSB
struct _GPPortSettingsUSB GPPortSettingsUSB
Port settings for USB ports.
_GPPortSettingsSerial::speed
int speed
Definition: gphoto2-port.h:68
_GPPortSettingsSerial::port
char port[128]
Definition: gphoto2-port.h:67
GP_PORT_USB_ENDPOINT_OUT
USB bulk OUT ep.
Definition: gphoto2-port.h:123
GP_PIN_CD
Carrier Detect line.
Definition: gphoto2-port.h:189
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:647
_GPPortSettingsSerial::stopbits
int stopbits
Definition: gphoto2-port.h:72
GPPortType
GPPortType
The gphoto port type.
Definition: gphoto2-port-info-list.h:34