libdrmconf
0.8.1
A library to program DMR radios.
|
Implements a radio interface for radios using the HID USB schema. More...
#include <hid_interface.hh>
Public Types | |
enum | MemoryBank { MEMBANK_NONE = -1, MEMBANK_CODEPLUG_LOWER = 0, MEMBANK_CODEPLUG_UPPER = 1, MEMBANK_CALLSIGN_LOWER = 3, MEMBANK_CALLSIGN_UPPER = 4 } |
Possible memory banks to select. More... | |
Public Member Functions | |
HID (int vid, int pid, QObject *parent=nullptr) | |
Connects to the radio with given vendor and product ID. | |
virtual | ~HID () |
Destructor. | |
bool | isOpen () const |
Returns true if the connection was established. | |
void | close () |
Closes the connection to the device. | |
QString | identifier () |
Returns radio identifier string. | |
bool | read_start (uint32_t bank, uint32_t addr) |
Starts the read process from the specified bank and at the given address. More... | |
bool | read (uint32_t bank, uint32_t addr, unsigned char *data, int nbytes) |
Reads a block of data from the device at the given block number. More... | |
bool | read_finish () |
This function ends a series of read operations. More... | |
bool | write_start (uint32_t bank, uint32_t addr) |
Starts the write process into the specified bank and at the given address. More... | |
bool | write (uint32_t bank, uint32_t addr, unsigned char *data, int nbytes) |
Writes a block of data to the device at the given block number. More... | |
bool | write_finish () |
This function ends a series of write operations. More... | |
const QString & | errorMessage () const |
Retruns the last error message. | |
![]() | |
HIDevice (int vid, int pid, 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) |
Send command/data to the device and store response in rdata . More... | |
void | close () |
Close connection to device. | |
const QString & | errorMessage () const |
Returns the last error message. | |
HIDevice (int vid, int pid, QObject *parent=nullptr) | |
Opens a connection to the device with given vendor and product ID. | |
virtual | ~HIDevice () |
Destrutor. | |
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) |
Send command/data to the device and store response in rdata . More... | |
void | close () |
Close connection to device. | |
![]() | |
virtual | ~RadioInterface () |
Destructor. | |
virtual bool | write (uint32_t bank, uint32_t addr, uint8_t *data, int nbytes)=0 |
Writes a chunk of data at the address addr . More... | |
virtual bool | read (uint32_t bank, uint32_t addr, uint8_t *data, int nbytes)=0 |
Reads a chunk of data from the block-address bno (block number). More... | |
virtual bool | reboot () |
Some radios need to be rebooted after being read or programmed. More... | |
Protected Member Functions | |
bool | selectMemoryBank (MemoryBank bank) |
Internal used function to select a memory bank. | |
![]() | |
int | write_read (const unsigned char *data, unsigned length, unsigned char *reply, unsigned rlength) |
Internal used implementation of send_recv(). | |
![]() | |
RadioInterface () | |
Hidden constructor. | |
Additional Inherited Members | |
![]() | |
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. | |
![]() | |
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. | |
QString | _errorMessage |
Holds the error message. | |
IOHIDManagerRef | _HIDManager |
Device manager. | |
volatile IOHIDDeviceRef | _dev |
Device handle. | |
unsigned char | _transfer_buf [42] |
Device buffer. | |
Implements a radio interface for radios using the HID USB schema.
enum HID::MemoryBank |
Possible memory banks to select.
bool HID::read | ( | uint32_t | bank, |
uint32_t | addr, | ||
unsigned char * | data, | ||
int | nbytes | ||
) |
Reads a block of data from the device at the given block number.
bank | The memory bank to read from. |
addr | The address to read from within the memory bank. |
data | Pointer to memory where the read data is stored. |
nbytes | The number of bytes to read. |
true
on success.
|
virtual |
This function ends a series of read
operations.
This function will be re-implemented by certain interfaces that need completion of read operations (e.g., HID).
Implements RadioInterface.
|
virtual |
Starts the read process from the specified bank and at the given address.
bank | Specifies the memory bank to read from. Usually there is only one bank. Some radios, however, to have several memory banks to hold the codeplug. For example the Open GD77 has EEPROM and Flash memory banks with independent addresses. |
addr | Specifies the address to read from. |
Implements RadioInterface.
bool HID::write | ( | uint32_t | bank, |
uint32_t | addr, | ||
unsigned char * | data, | ||
int | nbytes | ||
) |
Writes a block of data to the device at the given block number.
bank | The memory bank to read from. |
addr | The address to read from within the memory bank. |
data | Pointer to memory where the read data is stored. |
nbytes | The number of bytes to read. |
true
on success.
|
virtual |
This function ends a series of write
operations.
This function will be implemented by certain interfaces that need completion of write operations (e.g., HID).
Implements RadioInterface.
|
virtual |
Starts the write process into the specified bank and at the given address.
bank | Specifies the memory bank to write to. Usually there is only one bank. Some radios, however, to have several memory banks to hold the codeplug. For example the Open GD77 has EEPROM and Flash memory banks with independent addresses. |
addr | Specifies the address to write to. |
Implements RadioInterface.