libnifalcon
1.0.1
|
#include <FalconCommLibUSB.h>
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 () |
![]() | |
FalconComm () | |
virtual | ~FalconComm () |
int | getLastBytesRead () |
int | getLastBytesWritten () |
int | getDeviceErrorCode () |
bool | isCommOpen () |
bool | hasBytesAvailable () |
unsigned int | getBytesAvailable () |
virtual void | setBytesAvailable (unsigned int b) |
![]() | |
FalconCore () | |
virtual | ~FalconCore () |
int | getErrorCode () |
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 |
![]() | |
int | m_deviceErrorCode |
int | m_lastBytesRead |
int | m_lastBytesWritten |
bool | m_isCommOpen |
bool | m_hasBytesAvailable |
int | m_bytesAvailable |
![]() | |
int | m_errorCode |
Private Member Functions | |
DECLARE_LOGGER () | |
Additional Inherited Members | |
![]() | |
enum | { FALCON_COMM_DEVICE_ERROR = 2000, FALCON_COMM_NOT_INITIALIZED, FALCON_COMM_DEVICE_NOT_FOUND_ERROR, FALCON_COMM_DEVICE_NOT_VALID_ERROR, FALCON_COMM_DEVICE_INDEX_OUT_OF_RANGE_ERROR, FALCON_COMM_FIRMWARE_NOT_FOUND_ERROR, FALCON_COMM_WRITE_ERROR, FALCON_COMM_READ_ERROR } |
![]() | |
static const unsigned int | MAX_DEVICES = 128 |
static const unsigned int | FALCON_VENDOR_ID = 0x0403 |
static const unsigned int | FALCON_PRODUCT_ID = 0xCB48 |
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
libnifalcon::FalconCommLibUSB::FalconCommLibUSB | ( | ) |
Constructor
libnifalcon::FalconCommLibUSB::~FalconCommLibUSB | ( | ) |
Destructor
|
static |
Callback for result of reading data
|
static |
Callback for result of writing data
|
virtual |
Closes the device, if open
Implements libnifalcon::FalconComm.
|
private |
|
virtual |
Returns the number of devices connected to the system
[out] | count | The number of devices available |
Implements libnifalcon::FalconComm.
bool libnifalcon::FalconCommLibUSB::initLibUSB | ( | ) |
Initializes libusb core
void libnifalcon::FalconCommLibUSB::issueRead | ( | ) |
Causes a read to be queued
|
virtual |
Opens the device at the specified index
[in] | index | Index of the device to open |
Implements libnifalcon::FalconComm.
|
virtual |
Polls the object for confirmation of write/read return
Reimplemented from libnifalcon::FalconComm.
|
virtual |
Read a specified number of bytes from the device
[out] | str | Buffer to read data into |
[in] | size | Amount of bytes to read |
Implements libnifalcon::FalconComm.
|
virtual |
Read a specified number of bytes from the device
[out] | str | Buffer to read data into |
[in] | size | Amount of bytes to read |
Implements libnifalcon::FalconComm.
|
virtual |
Reset the internal state of the communications object (bytes read/written, etc...)
Reimplemented from libnifalcon::FalconComm.
|
virtual |
Sets the number of bytes that are ready for reading
|
virtual |
Sets the communications mode and initializes the device to load firmware
Implements libnifalcon::FalconComm.
void libnifalcon::FalconCommLibUSB::setHasBytesAvailable | ( | bool | v | ) |
Mutator function needed by static callbacks for class updates
|
virtual |
Sets the communications mode and initializes the device to run in normal operation
Implements libnifalcon::FalconComm.
|
inline |
Mutator function needed by static callbacks for class updates
|
inline |
Mutator function needed by static callbacks for class updates
|
virtual |
Write a specified number of bytes to the device
[in] | str | Buffer to write data from |
[in] | size | Amount of bytes to write |
Implements libnifalcon::FalconComm.
|
virtual |
Write a specified number of bytes to the device
[in] | str | Buffer to write data from |
[in] | size | Amount of bytes to write |
Implements libnifalcon::FalconComm.
|
protected |
Transfer for reading
|
protected |
Buffers for I/O
|
protected |
libusb device handle struct
|
protected |
True if we currently have a read queued
|
protected |
True if we currently have a write queued
|
protected |
Used for setting timeouts
|
protected |
Transfer for control messages
|
protected |
Transfer for writing
|
protected |