libdrmconf  0.12.0
A library to program DMR radios.
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
RadioddityInterface Class Reference

Implements a radio interface for radios using the HID USB schema (i.e. More...

#include <radioddity_interface.hh>

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

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

 RadioddityInterface (const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
 Connects to the radio via the given descriptor.
 
virtual ~RadioddityInterface ()
 Destructor.
 
bool isOpen () const
 Returns true if the connection was established.
 
void close ()
 Closes the connection to the device.
 
RadioInfo identifier (const ErrorStack &err=ErrorStack())
 Returns radio identifier string.
 
bool read_start (uint32_t bank, uint32_t addr, const ErrorStack &err=ErrorStack())
 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, const ErrorStack &err=ErrorStack())
 Reads a block of data from the device at the given block number. More...
 
bool read_finish (const ErrorStack &err=ErrorStack())
 This function ends a series of read operations. More...
 
bool write_start (uint32_t bank, uint32_t addr, const ErrorStack &err=ErrorStack())
 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, const ErrorStack &err=ErrorStack())
 Writes a block of data to the device at the given block number. More...
 
bool write_finish (const ErrorStack &err=ErrorStack())
 This function ends a series of write operations. More...
 
- Public Member Functions inherited from HIDevice
 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.
 
- Public Member Functions inherited from RadioInterface
virtual ~RadioInterface ()
 Destructor.
 
virtual bool write (uint32_t bank, uint32_t addr, uint8_t *data, int nbytes, const ErrorStack &err=ErrorStack())=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, const ErrorStack &err=ErrorStack())=0
 Reads a chunk of data from the block-address bno (block number). More...
 
virtual bool reboot (const ErrorStack &err=ErrorStack())
 Some radios need to be rebooted after being read or programmed. More...
 

Static Public Member Functions

static USBDeviceInfo interfaceInfo ()
 Returns some information about the interface.
 
static QList< USBDeviceDescriptordetect (bool saveOnly=true)
 Tries to find all interfaces connected AnyTone radios.
 
- Static Public Member Functions inherited from HIDevice
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

bool selectMemoryBank (MemoryBank bank, const ErrorStack &err=ErrorStack())
 Internal used function to select a memory bank.
 
- Protected Member Functions inherited from HIDevice
int write_read (const unsigned char *data, unsigned length, unsigned char *reply, unsigned rlength, const ErrorStack &err=ErrorStack())
 Internal used implementation of send_recv().
 
- Protected Member Functions inherited from RadioInterface
 RadioInterface ()
 Hidden constructor.
 

Additional Inherited Members

- Static Protected Member Functions inherited from HIDevice
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 inherited from HIDevice
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 a radio interface for radios using the HID USB schema (i.e.

Radioddity devices).

Member Enumeration Documentation

◆ MemoryBank

Possible memory banks to select.

Enumerator
MEMBANK_NONE 

No bank selected.

MEMBANK_CODEPLUG_LOWER 

Lower memory bank (EEPROM).

MEMBANK_CODEPLUG_UPPER 

Upper memory bank (FLASH).

MEMBANK_CALLSIGN_LOWER 

Callsign DB memory lower bank (also FLASH).

MEMBANK_CALLSIGN_UPPER 

Callsign DB memory upper bank (also FLASH).

Member Function Documentation

◆ read()

bool RadioddityInterface::read ( uint32_t  bank,
uint32_t  addr,
unsigned char *  data,
int  nbytes,
const ErrorStack err = ErrorStack() 
)

Reads a block of data from the device at the given block number.

Parameters
bankThe memory bank to read from.
addrThe address to read from within the memory bank.
dataPointer to memory where the read data is stored.
nbytesThe number of bytes to read.
errThe error stack, messages are put onto.
Returns
true on success.

◆ read_finish()

bool RadioddityInterface::read_finish ( const ErrorStack err = ErrorStack())
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).

Parameters
errPasses an error stack to put error messages on.

Implements RadioInterface.

◆ read_start()

bool RadioddityInterface::read_start ( uint32_t  bank,
uint32_t  addr,
const ErrorStack err = ErrorStack() 
)
virtual

Starts the read process from the specified bank and at the given address.

Parameters
bankSpecifies 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.
addrSpecifies the address to read from.
errPasses an error stack to put error messages on.

Implements RadioInterface.

◆ write()

bool RadioddityInterface::write ( uint32_t  bank,
uint32_t  addr,
unsigned char *  data,
int  nbytes,
const ErrorStack err = ErrorStack() 
)

Writes a block of data to the device at the given block number.

Parameters
bankThe memory bank to read from.
addrThe address to read from within the memory bank.
dataPointer to memory where the read data is stored.
nbytesThe number of bytes to read.
errThe error stack, messages are put onto.
Returns
true on success.

◆ write_finish()

bool RadioddityInterface::write_finish ( const ErrorStack err = ErrorStack())
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).

Parameters
errPasses an error stack to put error messages on.

Implements RadioInterface.

◆ write_start()

bool RadioddityInterface::write_start ( uint32_t  bank,
uint32_t  addr,
const ErrorStack err = ErrorStack() 
)
virtual

Starts the write process into the specified bank and at the given address.

Parameters
bankSpecifies 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.
addrSpecifies the address to write to.
errPasses an error stack to put error messages on.

Implements RadioInterface.


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