libdrmconf  0.10.4
A library to program DMR radios.
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
HIDevice Class Reference

Implements the HID radio interface using libusb. More...

#include <hid_libusb.hh>

Inheritance diagram for HIDevice:
Inheritance graph
[legend]
Collaboration diagram for HIDevice:
Collaboration graph
[legend]

Classes

class  Descriptor
 Specialization to address a HI device uniquely. More...
 

Public Member Functions

 HIDevice (const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
 Connects to the device with given vendor and product ID.
 
virtual ~HIDevice ()
 Destructor.
 
bool isOpen () const
 Returns true if the connection is established.
 
bool hid_send_recv (const unsigned char *data, unsigned nbytes, unsigned char *rdata, unsigned rlength, const ErrorStack &err=ErrorStack())
 Send command/data to the device and store response in rdata. More...
 
void close ()
 Close connection to device.
 
 HIDevice (const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
 Opens a connection to the device with given vendor and product ID.
 
virtual ~HIDevice ()
 Destructor.
 
bool isOpen () const
 Returns true if the connection was established.
 
bool hid_send_recv (const unsigned char *data, unsigned nbytes, unsigned char *rdata, unsigned rlength, const ErrorStack &err=ErrorStack())
 Send command/data to the device and store response in rdata. More...
 
void close ()
 Close connection to device.
 

Static Public Member Functions

static QList< USBDeviceDescriptordetect (uint16_t vid, uint16_t pid)
 Finds all HID interfaces with the specified VID/PID combination.
 
static QList< USBDeviceDescriptordetect (uint16_t vid, uint16_t pid)
 Finds all HID interfaces with the specified VID/PID combination.
 

Protected Member Functions

int write_read (const unsigned char *data, unsigned length, unsigned char *reply, unsigned rlength, const ErrorStack &err=ErrorStack())
 Internal used implementation of send_recv().
 

Static Protected Member Functions

static void read_callback (struct libusb_transfer *t)
 Callback for response data.
 
static void callback_input (void *context, IOReturn result, void *sender, IOHIDReportType type, uint32_t reportID, uint8_t *data, CFIndex nbytes)
 Internal callback for response data.
 
static void callback_open (void *context, IOReturn result, void *sender, IOHIDDeviceRef deviceRef)
 Internal callback for device opend.
 
static void callback_close (void *ontext, IOReturn result, void *sender, IOHIDDeviceRef deviceRef)
 Internal callback for device closed.
 

Protected Attributes

libusb_context * _ctx
 libusb context.
 
libusb_device_handle * _dev
 libusb device.
 
struct libusb_transfer * _transfer
 libusb async transfer descriptor.
 
unsigned char _receive_buf [42]
 Receive buffer.
 
volatile int _nbytes_received = 0
 Receive result.
 
ErrorStack _cbError
 Internal used error stack for the static callback function.
 
IOHIDManagerRef _HIDManager
 Device manager.
 
volatile IOHIDDeviceRef _dev
 Device handle.
 
unsigned char _transfer_buf [42]
 Device buffer.
 

Detailed Description

Implements the HID radio interface using libusb.

Implements the HID radio interface MacOS X API.

Member Function Documentation

◆ hid_send_recv() [1/2]

bool HIDevice::hid_send_recv ( const unsigned char *  data,
unsigned  nbytes,
unsigned char *  rdata,
unsigned  rlength,
const ErrorStack err = ErrorStack() 
)

Send command/data to the device and store response in rdata.

Parameters
dataPointer to the command/data to send.
nbytesThe number of bytes to send.
rdataPointer to receive buffer.
rlengthSize of receive buffer.
errPasses an error stack to put error messages on.

◆ hid_send_recv() [2/2]

bool HIDevice::hid_send_recv ( const unsigned char *  data,
unsigned  nbytes,
unsigned char *  rdata,
unsigned  rlength,
const ErrorStack err = ErrorStack() 
)

Send command/data to the device and store response in rdata.

Parameters
dataPointer to the command/data to send.
nbytesThe number of bytes to send.
rdataPointer to receive buffer.
rlengthSize of receive buffer.
errThe stack to put error messages on.

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