Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

LOW_portUsbDevice_Linux.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_portUsbDevice_Linux.h  -  description
00003                              -------------------
00004     begin                : Sun Oct 12 2003
00005     copyright            : (C) 2003 by Harald Roelle
00006     email                : roelle@informatik.uni-muenchen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef LOW_PORTUSBDEVICE_LINUX_H
00019 #define LOW_PORTUSBDEVICE_LINUX_H
00020 
00021 
00022 #include "LOW_portUsbDevice.h"
00023 #include "LOW_portUsb_Factory.h"
00024 #include "LOW_objectSynchronizer.h"
00025 
00026 
00027 #include "usb.h"
00028 
00029 
00030 
00031 /** Linux specific implementation of LOW_portUsbDevice.
00032 
00033     Requires libusb version 0.1.6a or higher.
00034     
00035     @see http://libusb.sourceforge.net/
00036     @see USB Specification Version 1.1
00037     
00038     @author Harald Roelle
00039     @author Parts of the documentation taken from libusb.
00040  */
00041 class LOW_portUsbDevice_Linux : public LOW_portUsbDevice, public LOW_objectSynchronizer  {
00042 
00043 //=======================================================================================
00044 public:
00045 
00046   //=====================================================================================
00047   //
00048   // constructors
00049   //
00050 
00051   /** Destructor.
00052     */
00053   virtual ~LOW_portUsbDevice_Linux();
00054 
00055 
00056 
00057   //=====================================================================================
00058   //
00059   // methods required by LOW_portUsbDevice
00060   //
00061 
00062   virtual usbVendorID_t  getVendorID();
00063 
00064   virtual usbProductID_t getProductID();
00065 
00066   virtual void setConfiguration( const usbConfig_t inConfig);
00067 
00068   virtual void claimInterface( const usbInterface_t inInterface);
00069   
00070   virtual void releaseInterface( const usbInterface_t inInterface);
00071 
00072   virtual void setIfaceAltSetting( const usbSetting_t inAltSetting);
00073 
00074   virtual void controlMsg( const bmRequestType_t inReqType,
00075                            const bRequest_t inRequest,
00076                            const wValue_t inValue,
00077                            const wIndex_t inIndex,
00078                            const wLength_t inLength,
00079                            msgData_t inOutData,
00080                            const usbTimeout_t inTimeout);
00081   
00082   virtual void controlMsg( const bmRequestType_t inReqType,
00083                            const bRequest_t inRequest,
00084                            const wValue_t inValue,
00085                            const wIndex_t inIndex,
00086                            byteVec_t &inOutData,
00087                            const usbTimeout_t inTimeout);
00088 
00089   virtual void clearHalt( const usbEndpoint_t inEP);
00090 
00091   virtual unsigned int bulkWrite( const usbEndpoint_t inEP, const wLength_t inLength,
00092                                   const msgData_t inData, const usbTimeout_t inTimeout);
00093                           
00094   virtual unsigned int bulkWrite( const usbEndpoint_t inEP,
00095                                   const byteVec_t &inData, const usbTimeout_t inTimeout);
00096 
00097   virtual unsigned int bulkRead( const usbEndpoint_t inEP, const wLength_t inLength,
00098                                  msgData_t outData, const usbTimeout_t inTimeout);
00099                              
00100   virtual unsigned int bulkRead( const usbEndpoint_t inEP, 
00101                                  byteVec_t &outData, const usbTimeout_t inTimeout);
00102                              
00103 
00104                              
00105 //=======================================================================================
00106 protected:
00107 
00108 
00109   //=====================================================================================
00110   //
00111   // friend classes
00112   //
00113 
00114   friend class LOW_portUsb_Factory; /**< To allow construction. */
00115 
00116   
00117   //=====================================================================================
00118   //
00119   // constructors
00120   //
00121 
00122   /** Constructor.
00123       Not publicly constructable. Use LOW_portUsb_Factory.
00124   
00125       @param inPortSpec  Unique identifier for new USB device instance.
00126 
00127       @throw noSuchDevice_error  Device was not found.
00128    */
00129   LOW_portUsbDevice_Linux( const LOW_portUsb_Factory::usbDeviceSpecifier_t inUsbDevSpec);
00130 
00131 
00132   //=====================================================================================
00133   //
00134   // static methods
00135   //
00136 
00137   /** Get a list of port specifiers of devices with a certain vendor and product ID.
00138 
00139       @param inVendorID   Vendor for new USB device instance.
00140       @param inProductID  Product for new USB device instance.
00141 
00142       @return List of port specifiers.
00143    */
00144   static LOW_portUsb_Factory::usbDevSpecVec_t  getPortSpecifiers( const usbVendorID_t inVendorID,
00145                                                                   const usbProductID_t inProductID);
00146 
00147 
00148 
00149 //=======================================================================================
00150 private:
00151 
00152   //=====================================================================================
00153   //
00154   // attributes
00155   //
00156 
00157   struct usb_device *usbLibDevice; /**< libusb's device structure. */
00158   usb_dev_handle    *usbLibDevHdl; /**< libusb's handle to USB device. */
00159 
00160 
00161   //=====================================================================================
00162   //
00163   // static methods
00164   //
00165 
00166   /** Rescan all USB busses.
00167    */
00168   static void rescanBusses();
00169 
00170 
00171   //=====================================================================================
00172   //
00173   // methods
00174   //
00175 
00176   /** Get libusb's error message as C++ string.
00177    */
00178   virtual std::string libUsbErrMsg();
00179 
00180 
00181   //=====================================================================================
00182   //
00183   // static initializer
00184   //
00185 
00186   /** Needed for dirty little C++ hack to force static initialization on application start.
00187       @see initialize()
00188   */
00189   static int initHelper;
00190 
00191   /** Static inizializer.
00192       @see initHelper
00193   */
00194   static int initialize();
00195 
00196 };
00197 
00198 #endif

Generated on Tue Feb 3 11:30:26 2004 for OneWireLibrary++ by doxygen 1.3.2