Logo Search packages:      
Sourcecode: libgphoto2 version File versions

gphoto2-port.h

Go to the documentation of this file.
/** \file 
 *
 * \author Copyright 2001 Lutz Mueller <lutz@users.sf.net>
 *
 * \par License
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * \par
 * This library is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details. 
 *
 * \par
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#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

/**
 * \brief Serial parity
 * 
 * Parity of the serial port.
 */
00053 typedef enum _GPPortSerialParity
{
00055     GP_PORT_SERIAL_PARITY_OFF = 0,  /**< \brief Parity is off (disabled) */
00056     GP_PORT_SERIAL_PARITY_EVEN,           /**< \brief Parity is even. */
00057     GP_PORT_SERIAL_PARITY_ODD       /**< \brief Parity is odd. */
} GPPortSerialParity;

/** \brief Maximum length of receive buffer */
00061 #define GP_PORT_MAX_BUF_LEN 4096             

/**
 * \brief Port settings for serial ports.
 */
00066 typedef struct _GPPortSettingsSerial {
00067       char port[128];         /**< The portname (/dev/ttyX)*/
00068       int speed;        /**< The baudrate of the device. */
00069       int bits;         /**< How many bits data. */
00070       GPPortSerialParity parity;    /**< parity data, see GP_PORT_SERIAL_PARITY_ 
                          defines */
00072       int stopbits;           /**< How many stop bits are used. */
} GPPortSettingsSerial;

/**
 * \brief Port settings for USB ports.
 */
00078 typedef struct _GPPortSettingsUSB {
00079       int inep;         /**< \brief Bulk IN endpoint used. */
00080       int outep;        /**< \brief Bulk OUT endpoint used. */
00081       int intep;        /**< \brief Interrupt endpoint used. */
00082       int config;       /**< \brief USB bConfigurationValue used. */
00083       int interface;          /**< \brief USB Interface number used. */
00084       int altsetting;         /**< \brief USB Alternative Setting used. */

00086       int maxpacketsize;      /**< \brief Maximum USB packetsize of the IN endpoint. (r/o) */

      /* must be last to avoid binary incompatibility.
       * luckily we just need to make sure this struct does not 
       * get larger than _GPPortSettingsSerial. */
00091       char port[64];          /**< \brief USB Portname. Specific to lowlevel USB. */
} GPPortSettingsUSB;

/**
 * \brief Port settings for the local disk (directories) port.
 */
00097 typedef struct _GPPortSettingsDisk {
00098       char mountpoint[128];   /**< \brief Path in the UNIX fs which corresponds to gphoto2 / */
} GPPortSettingsDisk;

/**
 * \brief Union of port settings.
 *
 * This contains a shared union of possible settings for ports needing
 * them.
 */
00107 typedef union _GPPortSettings {
00108       GPPortSettingsSerial serial;  /**< \brief Serial specific settings */
00109       GPPortSettingsUSB usb;        /**< \brief USB specific settings */
00110       GPPortSettingsDisk disk;      /**< \brief Disk port specific settings */
} GPPortSettings;

enum {
00114         GP_PORT_USB_ENDPOINT_IN,    /**< \brief USB bulk IN ep */
00115         GP_PORT_USB_ENDPOINT_OUT,   /**< \brief USB bulk OUT ep */
00116         GP_PORT_USB_ENDPOINT_INT    /**< \brief USB Interrupt ep */
};

typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary;
typedef struct _GPPortPrivateCore    GPPortPrivateCore;

/**
 * \brief The GPhoto port structure.
 *
 * This structure tracks the physical connection of the device.
 * It can correspond the various methods of lowlevel access, serial
 * usb and others and abstracts them as much as possible.
 *
 * Frontends should consider this structure opaque and only use accessor
 * functions.
 *
 * Camera drivers should only access the type and pl members directly,
 * and use accessor functions for the rest.
 */
00135 typedef struct _GPPort {
      /* For your convenience */
00137       GPPortType type;        /**< \brief Actual type of this port */

00139       GPPortSettings settings;      /**< \brief Current port settings. */
00140         GPPortSettings settings_pending;/**< \brief Settings to be committed. */

00142         int timeout;                /**< \brief Port timeout in milliseconds. */

00144       GPPortPrivateLibrary *pl;     /**< \brief Camera driver private data pointer. */
00145       GPPortPrivateCore    *pc;     /**< \brief Port library private data pointer. */
} 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_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);

/**
 * \brief Serial pins.
 * 
 * A number of serial pins to trigger and pull. This is necessary
 * for some devices that have more than just the regular 3 or 4 wires.
 */
00174 typedef enum _GPPin {
00175       GP_PIN_RTS, /**< \brief RTS line */
00176       GP_PIN_DTR, /**< \brief DTR line */
00177       GP_PIN_CTS, /**< \brief CTS line */
00178       GP_PIN_DSR, /**< \brief DSR line */
00179       GP_PIN_CD,  /**< \brief Carrier Detect line */
00180       GP_PIN_RING /**< \brief RING (Modem) line */
} GPPin;

/**
 * \brief Level to pull specific lines.
 * 
 * The level on which to pull some of the serial lines.
 */
00188 typedef enum _GPLevel {
00189       GP_LEVEL_LOW  = 0,      /**< \brief Pull to low (0V) */
00190       GP_LEVEL_HIGH = 1 /**< \brief Pull to high (nV) */
} 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);

/* 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 */
/** \deprecated internal typedef */
00225 typedef GPPort gp_port;
/** \deprecated internal typedef */
00227 typedef GPPortSettings gp_port_settings;
/** \deprecated internal define */
00229 #define PIN_CTS GP_PIN_CTS

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __GPHOTO2_PORT_H__ */



Generated by  Doxygen 1.6.0   Back to index