libnifalcon
1.0.1
|
#include <FalconComm.h>
Public Member Functions | |
FalconComm () | |
virtual | ~FalconComm () |
virtual bool | getDeviceCount (unsigned int &count)=0 |
virtual bool | open (unsigned int index)=0 |
virtual bool | close ()=0 |
virtual bool | read (uint8_t *str, unsigned int size)=0 |
virtual bool | write (uint8_t *str, unsigned int size)=0 |
virtual bool | readBlocking (uint8_t *str, unsigned int size)=0 |
virtual bool | writeBlocking (uint8_t *str, unsigned int size)=0 |
virtual bool | setFirmwareMode ()=0 |
virtual bool | setNormalMode ()=0 |
int | getLastBytesRead () |
int | getLastBytesWritten () |
int | getDeviceErrorCode () |
bool | isCommOpen () |
virtual void | reset () |
bool | hasBytesAvailable () |
unsigned int | getBytesAvailable () |
virtual void | setBytesAvailable (unsigned int b) |
virtual void | poll () |
![]() | |
FalconCore () | |
virtual | ~FalconCore () |
int | getErrorCode () |
Protected Attributes | |
int | m_deviceErrorCode |
int | m_lastBytesRead |
int | m_lastBytesWritten |
bool | m_isCommOpen |
bool | m_hasBytesAvailable |
int | m_bytesAvailable |
![]() | |
int | m_errorCode |
Static Protected Attributes | |
static const unsigned int | MAX_DEVICES = 128 |
static const unsigned int | FALCON_VENDOR_ID = 0x0403 |
static const unsigned int | FALCON_PRODUCT_ID = 0xCB48 |
FalconComm is the base class for all communications behavior implementations. The Falcon itself uses an FTDI chip to talk to the computer, so these will most likely be proxies to either an FTDI library (like FTD2XX), or reimplementation of FTDI calls (like our libusb implementation).
FalconComm is responsible for handling a few different tasks
All communications objects are considered to be non-blocking, and should reimplement a poll function to maintain this. Both FTD2XX and libusb, the two implementations of the FalconComm class as of this writing, operate in a non-blocking way. If blocking calls are required (currently only used for loading firmware), blocking functions are provided but are specified as such to warn the user.
As mentioned above, the falcon can operate in two modes
To get the device into firmware mode, the follow set of steps needs to happen:
Once this set of commands has been run and the send/receives match what is listed above, we can continue with loading the firmware. The actual firmware loading simply consists of sending 128 byte blocks of the firmware to the device, and receiving back those blocks for error checking. This happens in the FalconFirmware::loadFirmware function.
Child classes of FalconComm implement the above code in their setFirmwareMode() function.
Once firmware is loaded, the falcon needs to be returned to normal mode in order to exchange useful data with the driver. To do this, we execute the following steps:
After this, the falcon will be in normal communications mode, and regular I/O can begin. I/O specifics are defined in the firmware classes of libnifalcon.
While FalconComm is mainly geared toward making sure we can talk to the device, it can also be used for test purposes, like building network interfaces to emulate the falcon hardware.
anonymous enum |
|
inline |
Constructor
|
inlinevirtual |
Destructor
|
pure virtual |
Closes the device, if open
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
inline |
Returns the number of bytes available to read (buffered from object)
|
pure virtual |
Returns the number of devices connected to the system
[out] | count | The number of devices available |
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
inline |
Returns the device specific error code for in-depth debugging
|
inline |
Returns the number of bytes returned in the last read function
|
inline |
Returns the number of bytes returned in the last write function
|
inline |
Checks to see whether there are bytes available to read from the object
|
inline |
Returns whether the device is open or not
|
pure virtual |
Opens the device at the specified index
[in] | index | Index of the device to open |
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
inlinevirtual |
Polls the object for confirmation of write/read return
Reimplemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
pure virtual |
Read a specified number of bytes from the device
[out] | str | Buffer to read data into |
[in] | size | Amount of bytes to read |
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
pure virtual |
Read a specified number of bytes from the device
[out] | str | Buffer to read data into |
[in] | size | Amount of bytes to read |
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
inlinevirtual |
Reset the internal state of the communications object (bytes read/written, etc...)
Reimplemented in libnifalcon::FalconCommLibUSB.
|
inlinevirtual |
Sets the number of bytes that are ready for reading
|
pure virtual |
Sets the communications mode and initializes the device to load firmware
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
pure virtual |
Sets the communications mode and initializes the device to run in normal operation
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
pure virtual |
Write a specified number of bytes to the device
[in] | str | Buffer to write data from |
[in] | size | Amount of bytes to write |
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
pure virtual |
Write a specified number of bytes to the device
[in] | str | Buffer to write data from |
[in] | size | Amount of bytes to write |
Implemented in libnifalcon::FalconCommLibUSB, and libnifalcon::FalconCommFTD2XX.
|
staticprotected |
USB Product ID from the Falcon
|
staticprotected |
USB Vendor ID for the Falcon
|
protected |
Number of bytes object has available to read
|
protected |
Communications policy specific error code
|
protected |
Whether or not the object has bytes available to read
|
protected |
Whether or not the communications are open
|
protected |
Number of bytes read in last read operation
|
protected |
Number of bytes written in the last write operation
|
staticprotected |
Maximum number of devices to store in count buffers