dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Raw HID Plugin

Impliments a HID USB connection to the flight hardware as a QIODevice. More...

Classes

class  RawHIDReadThread
 
class  RawHIDWriteThread
 
class  RawHID
 
class  RawHIDConnection
 
class  RawHIDPlugin
 
struct  USBPortInfo
 
class  USBMonitor
 
class  USBSignalFilter
 

Enumerations

enum  USBMonitor::RunState { USBMonitor::Bootloader = 0x01, USBMonitor::Running = 0x02, USBMonitor::Upgrader = 0x03 }
 

Functions

 RawHIDReadThread::RawHIDReadThread (hid_device *device)
 
virtual RawHIDReadThread::~RawHIDReadThread ()
 
int RawHIDReadThread::getReadData (char *data, int size)
 
qint64 RawHIDReadThread::getBytesAvailable ()
 
void RawHIDReadThread::stop ()
 
void RawHIDReadThread::run ()
 
 RawHIDWriteThread::RawHIDWriteThread (hid_device *device)
 
virtual RawHIDWriteThread::~RawHIDWriteThread ()
 
int RawHIDWriteThread::pushDataToWrite (const char *data, int size)
 
qint64 RawHIDWriteThread::getBytesToWrite ()
 
void RawHIDWriteThread::stop ()
 Tell the thread to stop and make sure it wakes up immediately. More...
 
void RawHIDWriteThread::run ()
 
 RawHID::RawHID ()
 
 RawHID::RawHID (USBDevice *deviceName)
 
virtual RawHID::~RawHID ()
 
virtual bool RawHID::open (OpenMode mode)
 
virtual void RawHID::close ()
 
virtual bool RawHID::isSequential () const
 
virtual qint64 RawHID::readData (char *data, qint64 maxSize)
 
virtual qint64 RawHID::writeData (const char *data, qint64 maxSize)
 
virtual qint64 RawHID::bytesAvailable () const
 
virtual qint64 RawHID::bytesToWrite () const
 
 RawHIDConnection::RawHIDConnection ()
 
virtual RawHIDConnection::~RawHIDConnection ()
 
virtual QList< Core::IDevice * > RawHIDConnection::availableDevices ()
 
virtual QIODevice * RawHIDConnection::openDevice (Core::IDevice *deviceName)
 
virtual void RawHIDConnection::closeDevice (const QString &deviceName)
 
virtual QString RawHIDConnection::connectionName ()
 
virtual QString RawHIDConnection::shortName ()
 
virtual void RawHIDConnection::suspendPolling ()
 
virtual void RawHIDConnection::resumePolling ()
 
bool RawHIDConnection::deviceOpened ()
 
unsigned char USBPortInfo::getRunState ()
 
bool USBPortInfo::operator== (USBPortInfo const &port)
 
 Q_DECLARE_METATYPE (USBPortInfo)
 
static USBMonitorUSBMonitor::instance ()
 
 USBMonitor::USBMonitor (QObject *parent=nullptr)
 
 USBMonitor::~USBMonitor ()
 
QList< USBPortInfoUSBMonitor::availableDevices ()
 
QList< USBPortInfoUSBMonitor::availableDevices (int vid, int pid, int boardModel, int runState)
 Be a bit more picky and ask only for a specific type of device: More...
 
 USBSignalFilter::USBSignalFilter (int vid, int pid, int boardModel, int runState)
 
 USBSignalFilter::USBSignalFilter (QList< int > vid, int pid, int boardModel, int runState)
 

Variables

QByteArray RawHIDReadThread::m_readBuffer
 
QMutex RawHIDReadThread::m_readBufMtx
 
hid_device * RawHIDReadThread::m_handle
 
bool RawHIDReadThread::m_running
 
QByteArray RawHIDWriteThread::m_writeBuffer
 
QMutex RawHIDWriteThread::m_writeBufMtx
 
QWaitCondition RawHIDWriteThread::m_newDataToWrite
 
hid_device * RawHIDWriteThread::m_handle
 
bool RawHIDWriteThread::m_running
 
USBDeviceRawHID::m_deviceInfo
 
hid_device * RawHID::m_handle
 
RawHIDReadThreadRawHID::m_readThread
 
RawHIDWriteThreadRawHID::m_writeThread
 
QString USBPortInfo::serialNumber
 
QString USBPortInfo::manufacturer
 
QString USBPortInfo::product
 
QString USBPortInfo::path
 Opaque OS-specific path. More...
 
int USBPortInfo::vendorID
 Vendor ID. More...
 
int USBPortInfo::productID
 Product ID. More...
 
int USBPortInfo::bcdDevice
 

Signals

void RawHIDReadThread::readyToRead ()
 
void USBMonitor::deviceDiscovered (const USBPortInfo &info)
 
void USBMonitor::deviceRemoved (const USBPortInfo &info)
 
void USBSignalFilter::deviceDiscovered ()
 
void USBSignalFilter::deviceRemoved ()
 

Protected Slots

void RawHIDConnection::onDeviceConnected ()
 
void RawHIDConnection::onDeviceDisconnected ()
 

Detailed Description

Impliments a HID USB connection to the flight hardware as a QIODevice.

Monitors the USB bus for devince insertion/removal.

Implements the USB monitor on Mac using*.

Todo:
XX
Todo:
XX
Todo:
XX

Enumeration Type Documentation

Enumerator
Bootloader 
Running 
Upgrader 

Definition at line 90 of file usbmonitor.h.

Function Documentation

QList< Core::IDevice * > RawHIDConnection::availableDevices ( )
virtual

Returns the list of all currently available devices

Implements Core::IConnection.

Definition at line 85 of file rawhidplugin.cpp.

QList< USBPortInfo > USBMonitor::availableDevices ( )

Definition at line 142 of file usbmonitor.cpp.

QList< USBPortInfo > USBMonitor::availableDevices ( int  vid,
int  pid,
int  bcdDeviceMSB,
int  bcdDeviceLSB 
)

Be a bit more picky and ask only for a specific type of device:

Parameters
[in]vidVID to screen or1 to ignore
[in]pidPID to screen or1 to ignore
[in]bcdDeviceMSBMSB of bcdDevice to screen or1 to ignore
[in]bcdDeviceLSBLSB of bcdDevice to screen or1 to ignore
Returns
List of USBPortInfo that meet this criterion
Note
On OpenPilot, the bcdDeviceLSB indicates the run state: bootloader or running. bcdDeviceMSB indicates the board model.

Definition at line 159 of file usbmonitor.cpp.

qint64 RawHID::bytesAvailable ( ) const
protectedvirtual

Definition at line 295 of file rawhid.cpp.

qint64 RawHID::bytesToWrite ( ) const
protectedvirtual

Definition at line 303 of file rawhid.cpp.

void RawHID::close ( )
virtual

Definition at line 269 of file rawhid.cpp.

void RawHIDConnection::closeDevice ( const QString &  deviceName)
virtual

Reimplemented from Core::IConnection.

Definition at line 123 of file rawhidplugin.cpp.

QString RawHIDConnection::connectionName ( )
virtual

Connection type name "USB HID"

Implements Core::IConnection.

Definition at line 134 of file rawhidplugin.cpp.

bool RawHIDConnection::deviceOpened ( )
inline

Definition at line 67 of file rawhidplugin.h.

qint64 RawHIDReadThread::getBytesAvailable ( )

return the bytes buffered

Definition at line 113 of file rawhid.cpp.

qint64 RawHIDWriteThread::getBytesToWrite ( )

Return the number of bytes buffered

Definition at line 215 of file rawhid.cpp.

int RawHIDReadThread::getReadData ( char *  data,
int  size 
)

Return the data read so far without waiting

Definition at line 101 of file rawhid.cpp.

unsigned char USBPortInfo::getRunState ( )
inline

Definition at line 54 of file usbmonitor.h.

USBMonitor * USBMonitor::instance ( )
static

Definition at line 176 of file usbmonitor.cpp.

bool RawHID::isSequential ( ) const
virtual

Definition at line 290 of file rawhid.cpp.

bool RawHID::open ( OpenMode  mode)
virtual

Definition at line 235 of file rawhid.cpp.

QIODevice * RawHIDConnection::openDevice ( Core::IDevice device)
virtual

Open a device, and return a QIODevice interface from it It should be a dynamically created object as it will be deleted by the connection manager.

Implements Core::IConnection.

Definition at line 110 of file rawhidplugin.cpp.

bool USBPortInfo::operator== ( USBPortInfo const &  port)
inline

Definition at line 56 of file usbmonitor.h.

int RawHIDWriteThread::pushDataToWrite ( const char *  data,
int  size 
)

Add some data to be written without waiting

Definition at line 205 of file rawhid.cpp.

Q_DECLARE_METATYPE ( USBPortInfo  )
RawHID::RawHID ( )
RawHID::RawHID ( USBDevice deviceName)

Definition at line 222 of file rawhid.cpp.

RawHIDConnection::RawHIDConnection ( )

Definition at line 40 of file rawhidplugin.cpp.

RawHIDReadThread::RawHIDReadThread ( hid_device *  device)

Definition at line 48 of file rawhid.cpp.

RawHIDWriteThread::RawHIDWriteThread ( hid_device *  device)

Definition at line 121 of file rawhid.cpp.

qint64 RawHID::readData ( char *  data,
qint64  maxSize 
)
protectedvirtual

Definition at line 311 of file rawhid.cpp.

void RawHIDConnection::resumePolling ( )
virtual

Tells the Raw HID plugin to resume polling for USB devices

Reimplemented from Core::IConnection.

Definition at line 155 of file rawhidplugin.cpp.

void RawHIDReadThread::run ( )
protected

Definition at line 64 of file rawhid.cpp.

void RawHIDWriteThread::run ( )
protected

Definition at line 129 of file rawhid.cpp.

QString RawHIDConnection::shortName ( )
virtual

Short name to display in a combo box

Reimplemented from Core::IConnection.

Definition at line 139 of file rawhidplugin.cpp.

void RawHIDReadThread::stop ( )
inline

Definition at line 69 of file rawhid.h.

void RawHIDWriteThread::stop ( )

Tell the thread to stop and make sure it wakes up immediately.

Definition at line 196 of file rawhid.cpp.

void RawHIDConnection::suspendPolling ( )
virtual

Tells the Raw HID plugin to stop polling for USB devices

Reimplemented from Core::IConnection.

Definition at line 147 of file rawhidplugin.cpp.

USBMonitor::USBMonitor ( QObject *  parent = nullptr)

Initialize the USB monitor here

Definition at line 51 of file usbmonitor.cpp.

USBSignalFilter::USBSignalFilter ( int  vid,
int  pid,
int  boardModel,
int  runState 
)

Definition at line 70 of file usbsignalfilter.cpp.

USBSignalFilter::USBSignalFilter ( QList< int >  vid,
int  pid,
int  boardModel,
int  runState 
)

Definition at line 84 of file usbsignalfilter.cpp.

qint64 RawHID::writeData ( const char *  data,
qint64  maxSize 
)
protectedvirtual

Definition at line 319 of file rawhid.cpp.

RawHID::~RawHID ( )
virtual

Definition at line 230 of file rawhid.cpp.

RawHIDConnection::~RawHIDConnection ( )
virtual

Definition at line 54 of file rawhidplugin.cpp.

RawHIDReadThread::~RawHIDReadThread ( )
virtual

Definition at line 54 of file rawhid.cpp.

RawHIDWriteThread::~RawHIDWriteThread ( )
virtual

Definition at line 127 of file rawhid.cpp.

USBMonitor::~USBMonitor ( )

Definition at line 68 of file usbmonitor.cpp.

Variable Documentation

int USBPortInfo::bcdDevice

Definition at line 52 of file usbmonitor.h.

USBDevice* RawHID::m_deviceInfo
protected

Definition at line 156 of file rawhid.h.

hid_device* RawHIDReadThread::m_handle
protected

Definition at line 84 of file rawhid.h.

hid_device* RawHIDWriteThread::m_handle
protected

Definition at line 123 of file rawhid.h.

hid_device* RawHID::m_handle
protected

Definition at line 157 of file rawhid.h.

QWaitCondition RawHIDWriteThread::m_newDataToWrite
protected

Synchronize task with data arival

Definition at line 121 of file rawhid.h.

QByteArray RawHIDReadThread::m_readBuffer
protected

QByteArray might not be the most efficient way to implement a circular buffer but it's good enough and very simple

Definition at line 79 of file rawhid.h.

QMutex RawHIDReadThread::m_readBufMtx
protected

A mutex to protect read buffer

Definition at line 82 of file rawhid.h.

RawHIDReadThread* RawHID::m_readThread
protected

Definition at line 159 of file rawhid.h.

bool RawHIDReadThread::m_running
protected

Definition at line 86 of file rawhid.h.

bool RawHIDWriteThread::m_running
protected

Definition at line 125 of file rawhid.h.

QByteArray RawHIDWriteThread::m_writeBuffer
protected

QByteArray might not be the most efficient way to implement a circular buffer but it's good enough and very simple

Definition at line 115 of file rawhid.h.

QMutex RawHIDWriteThread::m_writeBufMtx
protected

A mutex to protect read buffer

Definition at line 118 of file rawhid.h.

RawHIDWriteThread* RawHID::m_writeThread
protected

Definition at line 160 of file rawhid.h.

QString USBPortInfo::manufacturer

Definition at line 45 of file usbmonitor.h.

QString USBPortInfo::path

Opaque OS-specific path.

Definition at line 48 of file usbmonitor.h.

QString USBPortInfo::product

Definition at line 46 of file usbmonitor.h.

int USBPortInfo::productID

Product ID.

Definition at line 51 of file usbmonitor.h.

QString USBPortInfo::serialNumber

Definition at line 44 of file usbmonitor.h.

int USBPortInfo::vendorID

Vendor ID.

Definition at line 50 of file usbmonitor.h.

Signals

void USBSignalFilter::deviceDiscovered ( )
signal
void USBMonitor::deviceDiscovered ( const USBPortInfo info)
signal

A new device has been connected to the system.

setUpNotifications() must be called first to enable event-driven device notifications. Currently only implemented on Windows and OS X.

Parameters
infoThe device that has been discovered.
void USBSignalFilter::deviceRemoved ( )
signal
void USBMonitor::deviceRemoved ( const USBPortInfo info)
signal

A device has been disconnected from the system.

setUpNotifications() must be called first to enable event-driven device notifications. Currently only implemented on Windows and OS X.

Parameters
infoThe device that was disconnected.
void RawHIDReadThread::readyToRead ( )
signal

Protected Slots

void RawHIDConnection::onDeviceConnected ( )
protectedslot

The USB monitor tells us a new device appeared

Definition at line 66 of file rawhidplugin.cpp.

void RawHIDConnection::onDeviceDisconnected ( )
protectedslot

The USB monitor tells us a device disappeard

Definition at line 74 of file rawhidplugin.cpp.