libnifalcon::FalconCommLibUSB Class Reference
[Communications Classes]

#include <FalconCommLibUSB.h>

Inherits libnifalcon::FalconComm.

Collaboration diagram for libnifalcon::FalconCommLibUSB:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 FalconCommLibUSB ()
 ~FalconCommLibUSB ()
virtual bool getDeviceCount (unsigned int &count)
virtual bool open (unsigned int index)
virtual bool close ()
virtual bool read (uint8_t *str, unsigned int size)
virtual bool write (uint8_t *str, unsigned int size)
virtual bool readBlocking (uint8_t *str, unsigned int size)
virtual bool writeBlocking (uint8_t *str, unsigned int size)
virtual bool setFirmwareMode ()
virtual bool setNormalMode ()
virtual void setBytesAvailable (uint32_t b)
void setHasBytesAvailable (bool v)
void setSent ()
void setReceived ()
bool initLibUSB ()
void poll ()
void reset ()
void issueRead ()

Static Public Member Functions

static void cb_in (struct libusb_transfer *transfer)
static void cb_out (struct libusb_transfer *transfer)

Protected Attributes

bool m_isWriteAllocated
bool m_isReadAllocated
struct timeval * m_tv
libusb_device_handle * m_falconDevice
unsigned char input [128]
unsigned char output [128]
struct libusb_transfer * in_transfer
struct libusb_transfer * out_transfer
struct libusb_context * m_usbContext

Private Member Functions

 DECLARE_LOGGER ()


Detailed Description

FalconCommLibUSB is the libusb-1.0 implementation of the falcon communications core. This core is meant to be used on non-windows platforms, since it's open source (unlike ftd2xx) and seems to work well. Much of the code is a reimplementation of functions found in libftdi:

http://www.intra2net.com/en/developer/libftdi/

However, due to our need to access the falcon at as close to a sustained 1khz rate as possible, we needed to use a non-blocking communications layer.

FalconCommLibUSB is built directly into the libnifalcon core library, as is chosen for the user by default by the FalconDevice constructor, so it is usually not needed. However, it is left here for code compatibility for code that already used comm behavior setting, which was required before libnifalcon v1.0


Constructor & Destructor Documentation

libnifalcon::FalconCommLibUSB::FalconCommLibUSB (  ) 

Constructor

libnifalcon::FalconCommLibUSB::~FalconCommLibUSB (  ) 

Destructor


Member Function Documentation

void libnifalcon::FalconCommLibUSB::cb_in ( struct libusb_transfer *  transfer  )  [static]

Callback for result of reading data

void libnifalcon::FalconCommLibUSB::cb_out ( struct libusb_transfer *  transfer  )  [static]

Callback for result of writing data

bool libnifalcon::FalconCommLibUSB::close (  )  [virtual]

Closes the device, if open

Returns:
True if device is closed successfully, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

libnifalcon::FalconCommLibUSB::DECLARE_LOGGER (  )  [private]

bool libnifalcon::FalconCommLibUSB::getDeviceCount ( unsigned int &  count  )  [virtual]

Returns the number of devices connected to the system

Parameters:
[out] count The number of devices available
Returns:
True if count was retreived correctly, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

bool libnifalcon::FalconCommLibUSB::initLibUSB (  ) 

Initializes libusb core

Returns:
True on successful initialization, false otherwise

void libnifalcon::FalconCommLibUSB::issueRead (  ) 

Causes a read to be queued

bool libnifalcon::FalconCommLibUSB::open ( unsigned int  index  )  [virtual]

Opens the device at the specified index

Parameters:
[in] index Index of the device to open
Returns:
True if device is opened successfully, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

void libnifalcon::FalconCommLibUSB::poll (  )  [virtual]

Polls the object for confirmation of write/read return

Reimplemented from libnifalcon::FalconComm.

bool libnifalcon::FalconCommLibUSB::read ( uint8_t *  str,
unsigned int  size 
) [virtual]

Read a specified number of bytes from the device

Parameters:
[out] str Buffer to read data into
[in] size Amount of bytes to read
Returns:
True if (size) amount of bytes is read successfully, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

bool libnifalcon::FalconCommLibUSB::readBlocking ( uint8_t *  str,
unsigned int  size 
) [virtual]

Read a specified number of bytes from the device

Parameters:
[out] str Buffer to read data into
[in] size Amount of bytes to read
Returns:
True if (size) amount of bytes is read successfully, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

void libnifalcon::FalconCommLibUSB::reset (  )  [virtual]

Reset the internal state of the communications object (bytes read/written, etc...)

Reimplemented from libnifalcon::FalconComm.

void libnifalcon::FalconCommLibUSB::setBytesAvailable ( uint32_t  b  )  [virtual]

Sets the number of bytes that are ready for reading

Returns:
Number of bytes available to read

bool libnifalcon::FalconCommLibUSB::setFirmwareMode (  )  [virtual]

Sets the communications mode and initializes the device to load firmware

Returns:
True if device is successfully set to load firwmare, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

void libnifalcon::FalconCommLibUSB::setHasBytesAvailable ( bool  v  ) 

Mutator function needed by static callbacks for class updates

bool libnifalcon::FalconCommLibUSB::setNormalMode (  )  [virtual]

Sets the communications mode and initializes the device to run in normal operation

Returns:
True if device is successfully set to normal operation, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

void libnifalcon::FalconCommLibUSB::setReceived (  )  [inline]

Mutator function needed by static callbacks for class updates

void libnifalcon::FalconCommLibUSB::setSent (  )  [inline]

Mutator function needed by static callbacks for class updates

bool libnifalcon::FalconCommLibUSB::write ( uint8_t *  str,
unsigned int  size 
) [virtual]

Write a specified number of bytes to the device

Parameters:
[in] str Buffer to write data from
[in] size Amount of bytes to write
Returns:
True if (size) amount of bytes is written successfully, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.

bool libnifalcon::FalconCommLibUSB::writeBlocking ( uint8_t *  str,
unsigned int  size 
) [virtual]

Write a specified number of bytes to the device

Parameters:
[in] str Buffer to write data from
[in] size Amount of bytes to write
Returns:
True if (size) amount of bytes is written successfully, false otherwise. Error code set if false.

Implements libnifalcon::FalconComm.


Member Data Documentation

struct libusb_transfer* libnifalcon::FalconCommLibUSB::in_transfer [read, protected]

Transfer for reading

unsigned char libnifalcon::FalconCommLibUSB::input[128] [protected]

Buffers for I/O

libusb_device_handle* libnifalcon::FalconCommLibUSB::m_falconDevice [protected]

libusb device handle struct

True if we currently have a read queued

True if we currently have a write queued

struct timeval* libnifalcon::FalconCommLibUSB::m_tv [read, protected]

Used for setting timeouts

struct libusb_context* libnifalcon::FalconCommLibUSB::m_usbContext [read, protected]

Transfer for control messages

struct libusb_transfer* libnifalcon::FalconCommLibUSB::out_transfer [read, protected]

Transfer for writing

unsigned char libnifalcon::FalconCommLibUSB::output[128] [protected]


The documentation for this class was generated from the following files:

Generated on Sun Sep 20 12:24:28 2009 for libnifalcon by  doxygen 1.5.9