libgphoto2 (libgphoto2): libgphoto2_port/libgphoto2_port/gphoto2-port.h Source File

Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# gphoto2-port.h

    00001 /* gphoto2-port.h
    00002  *
    00003  * Copyright © 2001 Lutz Müller <lutz@users.sf.net>
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Lesser General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  * Lesser General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Lesser General Public
    00016  * License along with this library; if not, write to the
    00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  * Boston, MA 02111-1307, USA.
    00019  */
    00020
    00021 #ifndef __GPHOTO2_PORT_H__
    00022 #define __GPHOTO2_PORT_H__
    00023
    00024 #include <gphoto2-port-info-list.h>
    00025
    00026 /* For portability */
    00027 #include <gphoto2-port-portability.h>
    00028 #ifdef OS2
    00029 #include <gphoto2-port-portability-os2.h>
    00030 #include <os2.h>
    00031 #endif
    00032
    00033 #ifdef __cplusplus
    00034 extern "C" {
    00035 #endif /* __cplusplus */
    00036
    00037 #ifndef TRUE
    00038 #define TRUE (0==0)
    00039 #endif
    00040
    00041 #ifndef FALSE
    00042 #define FALSE (1==0)
    00043 #endif
    00044
    00049 typedef enum _GPPortSerialParity
    00050 {
    00051     GP_PORT_SERIAL_PARITY_OFF = 0,
    00052     GP_PORT_SERIAL_PARITY_EVEN,
    00053     GP_PORT_SERIAL_PARITY_ODD
    00054 } GPPortSerialParity;
    00055
    00056
    00057 #define GP_PORT_MAX_BUF_LEN 4096             /* max length of receive buffer */
    00058
    00059 typedef struct _GPPortSettingsSerial GPPortSettingsSerial;
    00060 struct _GPPortSettingsSerial {
    00061         char port[128];
    00062         int speed;
    00063         int bits;
    00064         GPPortSerialParity parity;
    00066         int stopbits;
    00067 };
    00068
    00069 typedef struct _GPPortSettingsUSB GPPortSettingsUSB;
    00070 struct _GPPortSettingsUSB {
    00071         int inep, outep, intep;
    00072         int config;
    00073         int interface;
    00074         int altsetting;
    00075
    00076         /* must be last to avoid binary incompatibility.
    00077          * luckily we just need to make sure this struct does not
    00078          * get larger than _GPPortSettingsSerial. */
    00079         char port[64];
    00080 };
    00081
    00082 typedef struct _GPPortSettingsDisk GPPortSettingsDisk;
    00083 struct _GPPortSettingsDisk {
    00084         char mountpoint[128];
    00085 };
    00086
    00087 typedef union _GPPortSettings GPPortSettings;
    00088 union _GPPortSettings {
    00089         GPPortSettingsSerial serial;
    00090         GPPortSettingsUSB usb;
    00091         GPPortSettingsDisk disk;
    00092 };
    00093
    00094 enum {
    00095         GP_PORT_USB_ENDPOINT_IN,
    00096         GP_PORT_USB_ENDPOINT_OUT,
    00097         GP_PORT_USB_ENDPOINT_INT
    00098 };
    00099
    00100 typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
    00101 typedef struct _GPPortPrivateCore    GPPortPrivateCore;
    00102
    00103 typedef struct _GPPort           GPPort;
    00104 struct _GPPort {
    00105
    00106         /* For your convenience */
    00107         GPPortType type;
    00108
    00109         GPPortSettings settings;
    00110         GPPortSettings settings_pending;
    00111
    00112         int timeout; /* in milliseconds */
    00113
    00114         GPPortPrivateLibrary *pl;
    00115         GPPortPrivateCore    *pc;
    00116 };
    00117
    00118 int gp_port_new         (GPPort **port);
    00119 int gp_port_free        (GPPort *port);
    00120
    00121 int gp_port_set_info    (GPPort *port, GPPortInfo  info);
    00122 int gp_port_get_info    (GPPort *port, GPPortInfo *info);
    00123
    00124 int gp_port_open        (GPPort *port);
    00125 int gp_port_close       (GPPort *port);
    00126
    00127 int gp_port_write       (GPPort *port, const char *data, int size);
    00128 int gp_port_read        (GPPort *port,       char *data, int size);
    00129 int gp_port_check_int   (GPPort *port,       char *data, int size);
    00130 int gp_port_check_int_fast (GPPort *port,    char *data, int size);
    00131
    00132 int gp_port_get_timeout  (GPPort *port, int *timeout);
    00133 int gp_port_set_timeout  (GPPort *port, int  timeout);
    00134
    00135 int gp_port_set_settings (GPPort *port, GPPortSettings  settings);
    00136 int gp_port_get_settings (GPPort *port, GPPortSettings *settings);
    00137
    00138 enum _GPPin {
    00139         GP_PIN_RTS,
    00140         GP_PIN_DTR,
    00141         GP_PIN_CTS,
    00142         GP_PIN_DSR,
    00143         GP_PIN_CD,
    00144         GP_PIN_RING
    00145 };
    00146 typedef enum _GPPin GPPin;
    00147
    00148 enum _GPLevel {
    00149         GP_LEVEL_LOW  = 0,
    00150         GP_LEVEL_HIGH = 1
    00151 };
    00152 typedef enum _GPLevel GPLevel;
    00153
    00154 int gp_port_get_pin   (GPPort *port, GPPin pin, GPLevel *level);
    00155 int gp_port_set_pin   (GPPort *port, GPPin pin, GPLevel level);
    00156
    00157 int gp_port_send_break (GPPort *port, int duration);
    00158 int gp_port_flush      (GPPort *port, int direction);
    00159
    00160 int gp_port_usb_find_device (GPPort *port, int idvendor, int idproduct);
    00161 int gp_port_usb_find_device_by_class (GPPort *port, int mainclass, int subclass, int protocol);
    00162 int gp_port_usb_clear_halt  (GPPort *port, int ep);
    00163 int gp_port_usb_msg_write   (GPPort *port, int request, int value,
    00164                              int index, char *bytes, int size);
    00165 int gp_port_usb_msg_read    (GPPort *port, int request, int value,
    00166                              int index, char *bytes, int size);
    00167 int gp_port_usb_msg_interface_write    (GPPort *port, int request,
    00168                             int value, int index, char *bytes, int size);
    00169 int gp_port_usb_msg_interface_read    (GPPort *port, int request,
    00170                             int value, int index, char *bytes, int size);
    00171
    00172 /* Error reporting */
    00173 int         gp_port_set_error (GPPort *port, const char *format, ...)
    00174 #ifdef __GNUC__
    00175         __attribute__((__format__(printf,2,3)))
    00176 #endif
    00177 ;
    00178 const char *gp_port_get_error (GPPort *port);
    00179
    00180 /* DEPRECATED */
    00181 typedef GPPort gp_port;
    00182 typedef GPPortSettings gp_port_settings;
    00183 #define PIN_CTS GP_PIN_CTS
    00184
    00185 #ifdef __cplusplus
    00186 }
    00187 #endif /* __cplusplus */
    00188
    00189 #endif /* __GPHOTO2_PORT_H__ */
    00190
    00191