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

LOW_portUsbDevice_Linux Class Reference

Linux specific implementation of LOW_portUsbDevice. More...

#include <LOW_portUsbDevice_Linux.h>

Inheritance diagram for LOW_portUsbDevice_Linux:

Inheritance graph
[legend]
Collaboration diagram for LOW_portUsbDevice_Linux:

Collaboration graph
[legend]
List of all members.

Public Types

typedef uint16_t usbVendorID_t
 Type for USB vendor ID. More...

typedef uint16_t usbProductID_t
 Type for USB product ID. More...

typedef uint8_t usbConfig_t
 Type for USB configuration. More...

typedef uint8_t usbInterface_t
 Type for USB interface. More...

typedef uint8_t usbSetting_t
 Type for USB setting. More...

typedef uint8_t bmRequestType_t
 Corresponds to type defined in USB 1.1 specification. More...

typedef uint8_t bRequest_t
 Corresponds to type defined in USB 1.1 specification. More...

typedef uint16_t wValue_t
 Corresponds to type defined in USB 1.1 specification. More...

typedef uint16_t wIndex_t
 Corresponds to type defined in USB 1.1 specification. More...

typedef uint16_t wLength_t
 Corresponds to type defined in USB 1.1 specification. More...

typedef uint8_t * msgData_t
 Pointer type for I/O methods. More...

typedef uint16_t usbTimeout_t
 Type for timeout on USB operations in ms. More...

typedef uint8_t usbEndpoint_t
 Type for USB endpoint. More...


Public Methods

virtual ~LOW_portUsbDevice_Linux ()
 Destructor. More...

virtual usbVendorID_t getVendorID ()
 Get vendor ID of USB device. More...

virtual usbProductID_t getProductID ()
 Get product ID of USB device. More...

virtual void setConfiguration (const usbConfig_t inConfig)
 Resets a device. More...

virtual void claimInterface (const usbInterface_t inInterface)
 Claim an interface of a device. More...

virtual void releaseInterface (const usbInterface_t inInterface)
 Releases a previously claimed interface. More...

virtual void setIfaceAltSetting (const usbSetting_t inAltSetting)
 Sets the active alternate setting of the current interface. More...

virtual void controlMsg (const bmRequestType_t inReqType, const bRequest_t inRequest, const wValue_t inValue, const wIndex_t inIndex, const wLength_t inLength, msgData_t inOutData, const usbTimeout_t inTimeout)
 Send a control message to a device. More...

virtual void controlMsg (const bmRequestType_t inReqType, const bRequest_t inRequest, const wValue_t inValue, const wIndex_t inIndex, byteVec_t &inOutData, const usbTimeout_t inTimeout)
 Send a control message to a device. More...

virtual void clearHalt (const usbEndpoint_t inEP)
 Clears any halt status on an endpoint. More...

virtual unsigned int bulkWrite (const usbEndpoint_t inEP, const wLength_t inLength, const msgData_t inData, const usbTimeout_t inTimeout)
 Write data to a bulk endpoint. More...

virtual unsigned int bulkWrite (const usbEndpoint_t inEP, const byteVec_t &inData, const usbTimeout_t inTimeout)
 Write data to a bulk endpoint. More...

virtual unsigned int bulkRead (const usbEndpoint_t inEP, const wLength_t inLength, msgData_t outData, const usbTimeout_t inTimeout)
 Read data from a bulk endpoint. More...

virtual unsigned int bulkRead (const usbEndpoint_t inEP, byteVec_t &outData, const usbTimeout_t inTimeout)
 Read data from a bulk endpoint. More...

 class_DERIVE_FROM_EXCEPTION (portUsbDevice_error, LOW_exception)
 Exception base class for all exceptions thrown by LOW_portUsbDevice. More...

 class_DERIVE_FROM_EXCEPTION (noSuchDevice_error, portUsbDevice_error)
 Exception class when a device could not be found. More...


Protected Methods

 LOW_portUsbDevice_Linux (const LOW_portUsb_Factory::usbDeviceSpecifier_t inUsbDevSpec)
 Constructor. More...

 LOW_portUsbDevice_Linux (const usbVendorID_t inVendorID, const usbProductID_t inProductID)
 Constructor. More...


Private Methods

virtual void rescanBusses ()
 Rescan all USB busses. More...

virtual std::string libUsbErrMsg ()
 Get libusb's error message as C++ string. More...


Static Private Methods

int initialize ()
 Static inizializer. More...


Private Attributes

usb_device * usbLibDevice
 libusb's device structure. More...

usb_dev_handle * usbLibDevHdl
 libusb's handle to USB device. More...


Static Private Attributes

int initHelper = initialize()
 Needed for dirty little C++ hack to force static initialization on application start. More...


Friends

class LOW_portUsb_Factory
 To allow construction. More...


Detailed Description

Linux specific implementation of LOW_portUsbDevice.

Requires libusb version 0.1.6a or higher.

See also:
http://libusb.sourceforge.net/ , USB Specification Version 1.1
Author:
Harald Roelle , Parts of the documentation taken from libusb.

Definition at line 41 of file LOW_portUsbDevice_Linux.h.


Member Typedef Documentation

typedef uint8_t LOW_portUsbDevice::bmRequestType_t [inherited]
 

Corresponds to type defined in USB 1.1 specification.

Definition at line 78 of file LOW_portUsbDevice.h.

typedef uint8_t LOW_portUsbDevice::bRequest_t [inherited]
 

Corresponds to type defined in USB 1.1 specification.

Definition at line 79 of file LOW_portUsbDevice.h.

typedef uint8_t* LOW_portUsbDevice::msgData_t [inherited]
 

Pointer type for I/O methods.

Definition at line 83 of file LOW_portUsbDevice.h.

Referenced by bulkRead(), bulkWrite(), and controlMsg().

typedef uint8_t LOW_portUsbDevice::usbConfig_t [inherited]
 

Type for USB configuration.

Definition at line 75 of file LOW_portUsbDevice.h.

typedef uint8_t LOW_portUsbDevice::usbEndpoint_t [inherited]
 

Type for USB endpoint.

Definition at line 85 of file LOW_portUsbDevice.h.

typedef uint8_t LOW_portUsbDevice::usbInterface_t [inherited]
 

Type for USB interface.

Definition at line 76 of file LOW_portUsbDevice.h.

typedef uint16_t LOW_portUsbDevice::usbProductID_t [inherited]
 

Type for USB product ID.

Definition at line 74 of file LOW_portUsbDevice.h.

Referenced by getProductID(), and LOW_portUsb_Factory::new_portUsbDevice().

typedef uint8_t LOW_portUsbDevice::usbSetting_t [inherited]
 

Type for USB setting.

Definition at line 77 of file LOW_portUsbDevice.h.

typedef uint16_t LOW_portUsbDevice::usbTimeout_t [inherited]
 

Type for timeout on USB operations in ms.

Definition at line 84 of file LOW_portUsbDevice.h.

Referenced by LOW_linkDS2490::waitUntilIdle().

typedef uint16_t LOW_portUsbDevice::usbVendorID_t [inherited]
 

Type for USB vendor ID.

Definition at line 73 of file LOW_portUsbDevice.h.

Referenced by getVendorID(), and LOW_portUsb_Factory::new_portUsbDevice().

typedef uint16_t LOW_portUsbDevice::wIndex_t [inherited]
 

Corresponds to type defined in USB 1.1 specification.

Definition at line 81 of file LOW_portUsbDevice.h.

Referenced by LOW_linkDS2490::comCmd_blockIO(), LOW_linkDS2490::comCmd_byteIO(), LOW_linkDS2490::comCmd_doAndRelease(), LOW_linkDS2490::comCmd_matchAccess(), LOW_linkDS2490::comCmd_oneWireReset(), LOW_linkDS2490::comCmd_readCrcProtPage(), LOW_linkDS2490::comCmd_readRedirectPageCrc(), LOW_linkDS2490::comCmd_readStraight(), LOW_linkDS2490::comCmd_searchAccess(), LOW_linkDS2490::comCmd_setDuration(), LOW_linkDS2490::comCmd_setPath(), LOW_linkDS2490::comCmd_writeEprom(), LOW_linkDS2490::comCmd_writeSramPage(), LOW_linkDS2490::modCmd_setDsoW0RecoveryTime(), LOW_linkDS2490::modCmd_setEnablePulse(), LOW_linkDS2490::modCmd_setEnableSpeedChange(), LOW_linkDS2490::modCmd_setOneWireSpeed(), LOW_linkDS2490::modCmd_setProgPulseDuration(), LOW_linkDS2490::modCmd_setPulldownSlewRate(), LOW_linkDS2490::modCmd_setStrongPullupDuration(), and LOW_linkDS2490::modCmd_setWrite1LowTime().

typedef uint16_t LOW_portUsbDevice::wLength_t [inherited]
 

Corresponds to type defined in USB 1.1 specification.

Definition at line 82 of file LOW_portUsbDevice.h.

Referenced by LOW_linkDS2490::comCmd_readStraight().

typedef uint16_t LOW_portUsbDevice::wValue_t [inherited]
 

Corresponds to type defined in USB 1.1 specification.

Definition at line 80 of file LOW_portUsbDevice.h.

Referenced by LOW_linkDS2490::comCmd_bitIO(), LOW_linkDS2490::comCmd_blockIO(), LOW_linkDS2490::comCmd_byteIO(), LOW_linkDS2490::comCmd_doAndRelease(), LOW_linkDS2490::comCmd_matchAccess(), LOW_linkDS2490::comCmd_oneWireReset(), LOW_linkDS2490::comCmd_pulse(), LOW_linkDS2490::comCmd_readCrcProtPage(), LOW_linkDS2490::comCmd_readRedirectPageCrc(), LOW_linkDS2490::comCmd_readStraight(), LOW_linkDS2490::comCmd_searchAccess(), LOW_linkDS2490::comCmd_setDuration(), LOW_linkDS2490::comCmd_setPath(), LOW_linkDS2490::comCmd_writeEprom(), LOW_linkDS2490::comCmd_writeSramPage(), and LOW_linkDS2490::handleCommonComCmdBits().


Constructor & Destructor Documentation

LOW_portUsbDevice_Linux::~LOW_portUsbDevice_Linux   [virtual]
 

Destructor.

Definition at line 99 of file LOW_portUsbDevice_Linux.cpp.

References libUsbErrMsg(), LOW_helper_msglog::printPerror(), and usbLibDevHdl.

LOW_portUsbDevice_Linux::LOW_portUsbDevice_Linux const LOW_portUsb_Factory::usbDeviceSpecifier_t    inUsbDevSpec [protected]
 

Constructor.

Not publicly constructable. Use LOW_portUsb_Factory.

Parameters:
inPortSpec  Unique identifier for new USB device instance.
Exceptions:
noSuchDevice_error  Device was not found.

Definition at line 48 of file LOW_portUsbDevice_Linux.cpp.

References libUsbErrMsg(), rescanBusses(), usbLibDevHdl, and usbLibDevice.

LOW_portUsbDevice_Linux::LOW_portUsbDevice_Linux const usbVendorID_t    inVendorID,
const usbProductID_t    inProductID
[protected]
 

Constructor.

If more than one device with the same vendor/product id is present, the first device found is used. Not publicly constructable. Use appropriate LOW_portUsb_Factory.

Parameters:
inVendorID  Vendor for new USB device instance.
inProductID  Product for new USB device instance.
Exceptions:
noSuchDevice_error  Device was not found.

Definition at line 75 of file LOW_portUsbDevice_Linux.cpp.

References libUsbErrMsg(), rescanBusses(), usbLibDevHdl, and usbLibDevice.


Member Function Documentation

unsigned int LOW_portUsbDevice_Linux::bulkRead const usbEndpoint_t    inEP,
byteVec_t   outData,
const usbTimeout_t    inTimeout
[virtual]
 

Read data from a bulk endpoint.

Parameters:
inEP  The endpoint.
outData  Data that was read. Preset length of the array determines amount of bytes to read.
inTimeout  Timeout to wait for completion.
Returns:
Number of bytes actually read.

Reimplemented from LOW_portUsbDevice.

Definition at line 289 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, bulkRead(), byteVec_t, and LOW_portUsbDevice::msgData_t.

unsigned int LOW_portUsbDevice_Linux::bulkRead const usbEndpoint_t    inEP,
const wLength_t    inLength,
msgData_t    outData,
const usbTimeout_t    inTimeout
[virtual]
 

Read data from a bulk endpoint.

Parameters:
inEP  The endpoint.
inLength  Number of bytes to read.
outData  Pointer to memory to write data to. Memory must be already allocated!
inTimeout  Timeout to wait for completion.
Returns:
Number of bytes actually read.

Reimplemented from LOW_portUsbDevice.

Definition at line 277 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, libUsbErrMsg(), and usbLibDevHdl.

Referenced by bulkRead().

unsigned int LOW_portUsbDevice_Linux::bulkWrite const usbEndpoint_t    inEP,
const byteVec_t   inData,
const usbTimeout_t    inTimeout
[virtual]
 

Write data to a bulk endpoint.

Parameters:
inEP  The endpoint.
inData  Data to write.
inTimeout  Timeout to wait for completion.
Returns:
Number of bytes actually written.

Reimplemented from LOW_portUsbDevice.

Definition at line 257 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, bulkWrite(), byteVec_t, and LOW_portUsbDevice::msgData_t.

unsigned int LOW_portUsbDevice_Linux::bulkWrite const usbEndpoint_t    inEP,
const wLength_t    inLength,
const msgData_t    inData,
const usbTimeout_t    inTimeout
[virtual]
 

Write data to a bulk endpoint.

Parameters:
inEP  The endpoint.
inLength  Number of bytes to write.
inData  Pointer to data to write.
inTimeout  Timeout to wait for completion.
Returns:
Number of bytes actually written.

Reimplemented from LOW_portUsbDevice.

Definition at line 245 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE_WEAK__, libUsbErrMsg(), and usbLibDevHdl.

Referenced by bulkWrite().

void LOW_portUsbDevice_Linux::claimInterface const usbInterface_t    inInterface [virtual]
 

Claim an interface of a device.

Claims the interface with the Operating System.

Note: The method must be called before you perform any operations related to this interface (like setIfaceAltSetting(), bulkWrite(), etc).

Parameters:
inInterface  The value as specified in the USB descriptor field bInterfaceNumber.

Reimplemented from LOW_portUsbDevice.

Definition at line 159 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, libUsbErrMsg(), and usbLibDevHdl.

LOW_portUsbDevice::class_DERIVE_FROM_EXCEPTION noSuchDevice_error   ,
portUsbDevice_error   
[inherited]
 

Exception class when a device could not be found.

LOW_portUsbDevice::class_DERIVE_FROM_EXCEPTION portUsbDevice_error   ,
LOW_exception   
[inherited]
 

Exception base class for all exceptions thrown by LOW_portUsbDevice.

void LOW_portUsbDevice_Linux::clearHalt const usbEndpoint_t    inEP [virtual]
 

Clears any halt status on an endpoint.

Parameters:
inEOP  The value specified in the USB descriptor field bEndpointAddress.

Reimplemented from LOW_portUsbDevice.

Definition at line 233 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, libUsbErrMsg(), and usbLibDevHdl.

void LOW_portUsbDevice_Linux::controlMsg const bmRequestType_t    inReqType,
const bRequest_t    inRequest,
const wValue_t    inValue,
const wIndex_t    inIndex,
byteVec_t   inOutData,
const usbTimeout_t    inTimeout
[virtual]
 

Send a control message to a device.

Performs a control request to the default control pipe on a device.

The parameters mirror the types of the same name in the USB specification.

Reimplemented from LOW_portUsbDevice.

Definition at line 208 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, byteVec_t, controlMsg(), and LOW_portUsbDevice::msgData_t.

void LOW_portUsbDevice_Linux::controlMsg const bmRequestType_t    inReqType,
const bRequest_t    inRequest,
const wValue_t    inValue,
const wIndex_t    inIndex,
const wLength_t    inLength,
msgData_t    inOutData,
const usbTimeout_t    inTimeout
[virtual]
 

Send a control message to a device.

Performs a control request to the default control pipe on a device.

The parameters mirror the types of the same name in the USB specification.

Reimplemented from LOW_portUsbDevice.

Definition at line 192 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, libUsbErrMsg(), and usbLibDevHdl.

Referenced by controlMsg().

LOW_portUsbDevice_Linux::usbProductID_t LOW_portUsbDevice_Linux::getProductID   [virtual]
 

Get product ID of USB device.

Reimplemented from LOW_portUsbDevice.

Definition at line 122 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ__, usbLibDevice, and LOW_portUsbDevice::usbProductID_t.

LOW_portUsbDevice_Linux::usbVendorID_t LOW_portUsbDevice_Linux::getVendorID   [virtual]
 

Get vendor ID of USB device.

Reimplemented from LOW_portUsbDevice.

Definition at line 114 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_READ__, usbLibDevice, and LOW_portUsbDevice::usbVendorID_t.

int LOW_portUsbDevice_Linux::initialize   [static, private]
 

Static inizializer.

See also:
initHelper

Definition at line 30 of file LOW_portUsbDevice_Linux.cpp.

std::string LOW_portUsbDevice_Linux::libUsbErrMsg   [private, virtual]
 

Get libusb's error message as C++ string.

Definition at line 326 of file LOW_portUsbDevice_Linux.cpp.

Referenced by bulkRead(), bulkWrite(), claimInterface(), clearHalt(), controlMsg(), LOW_portUsbDevice_Linux(), releaseInterface(), setConfiguration(), setIfaceAltSetting(), and ~LOW_portUsbDevice_Linux().

void LOW_portUsbDevice_Linux::releaseInterface const usbInterface_t    inInterface [virtual]
 

Releases a previously claimed interface.

Releases an interface previously claimed with claimInterface().

Parameters:
inInterface  The value as specified in the USB descriptor field bInterfaceNumber.

Reimplemented from LOW_portUsbDevice.

Definition at line 170 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, libUsbErrMsg(), and usbLibDevHdl.

void LOW_portUsbDevice_Linux::rescanBusses   [private, virtual]
 

Rescan all USB busses.

Definition at line 316 of file LOW_portUsbDevice_Linux.cpp.

Referenced by LOW_portUsbDevice_Linux().

void LOW_portUsbDevice_Linux::setConfiguration const usbConfig_t    inConfig [virtual]
 

Resets a device.

Resets the specified device by sending a RESET down the port it is connected to.

Reimplemented from LOW_portUsbDevice.

Definition at line 147 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, libUsbErrMsg(), and usbLibDevHdl.

void LOW_portUsbDevice_Linux::setIfaceAltSetting const usbSetting_t    inAltSetting [virtual]
 

Sets the active alternate setting of the current interface.

Parameters:
inAltInterface  The value as specified in the USB descriptor field bAlternateSetting.

Reimplemented from LOW_portUsbDevice.

Definition at line 180 of file LOW_portUsbDevice_Linux.cpp.

References __LOW_SYNCHRONIZE_METHOD_WRITE__, libUsbErrMsg(), and usbLibDevHdl.


Friends And Related Function Documentation

friend class LOW_portUsb_Factory [friend]
 

To allow construction.

Definition at line 114 of file LOW_portUsbDevice_Linux.h.


Member Data Documentation

int LOW_portUsbDevice_Linux::initHelper = initialize() [static, private]
 

Needed for dirty little C++ hack to force static initialization on application start.

See also:
initialize()

Definition at line 29 of file LOW_portUsbDevice_Linux.cpp.

usb_dev_handle* LOW_portUsbDevice_Linux::usbLibDevHdl [private]
 

libusb's handle to USB device.

Definition at line 153 of file LOW_portUsbDevice_Linux.h.

Referenced by bulkRead(), bulkWrite(), claimInterface(), clearHalt(), controlMsg(), LOW_portUsbDevice_Linux(), releaseInterface(), setConfiguration(), setIfaceAltSetting(), and ~LOW_portUsbDevice_Linux().

struct usb_device* LOW_portUsbDevice_Linux::usbLibDevice [private]
 

libusb's device structure.

Definition at line 152 of file LOW_portUsbDevice_Linux.h.

Referenced by getProductID(), getVendorID(), and LOW_portUsbDevice_Linux().


The documentation for this class was generated from the following files:
Generated on Mon Oct 27 22:56:33 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001