LibDMRConf  0.6.0
A library to program DMR radios.
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DFUDevice Class Reference

This class implements DFU protocol to access radios. More...

#include <dfu_libusb.hh>

Inheritance diagram for DFUDevice:
RadioInterface

Public Member Functions

 DFUDevice (unsigned vid, unsigned pid, QObject *parent=nullptr)
 Opens a connection to the USB-DFU devuce at vendor vid and product pid.
 
virtual ~DFUDevice ()
 Destructor.
 
bool isOpen () const
 Return true if a connection to the device has been established.
 
QString identifier ()
 Returns a device identifier.
 
void close ()
 Closes the connection to the device.
 
bool erase (uint start, uint size, void(*progress)(uint, void *)=nullptr, void *ctx=nullptr)
 Erases a memory section at start of size size.
 
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, uint8_t *data, int nbytes)
 Reads a chunk of data from the block-address bno (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, uint8_t *data, int nbytes)
 Writes a chunk of data at the address addr. More...
 
bool write_finish ()
 This function ends a series of write operations. More...
 
bool reboot ()
 Some radios need to be rebooted after being read or programmed. More...
 
const QString & errorMessage () const
 Returns the last error message.
 
- Public Member Functions inherited from RadioInterface
virtual ~RadioInterface ()
 Destructor.
 

Protected Member Functions

int detach (int timeout)
 Internal used function to detach the device.
 
int get_status ()
 Internal used function to read the current status.
 
int clear_status ()
 Internal used function to clear the status.
 
int get_state (int &pstate)
 Internal used function to read the state.
 
int abort ()
 Internal used function to abort the current operation.
 
int wait_idle ()
 Internal used function to wait for a response from the device.
 
int md380_command (uint8_t a, uint8_t b)
 Internal used function to send a controll command to the device.
 
int set_address (uint32_t address)
 Internal used function to set the current I/O address.
 
int erase_block (uint32_t address)
 Internal used function to erase a specific block.
 
const char * identify ()
 Internal used function to read the device identifier.
 
const char * dfu_init (unsigned vid, unsigned pid)
 Internal used function to initialize the DFU connection to the device.
 
- Protected Member Functions inherited from RadioInterface
 RadioInterface ()
 Hidden constructor.
 

Protected Attributes

libusb_context * _ctx
 USB context.
 
libusb_device_handle * _dev
 USB device object.
 
status_t _status
 Device status.
 
const char * _ident
 Read identifier.
 
QString _errorMessage
 Holds the last error message.
 

Detailed Description

This class implements DFU protocol to access radios.

Many manufactures use the standardized DFU protocoll to programm codeplugs and update the firmware of their radios. This class implements this protocol.

Member Function Documentation

◆ read()

bool DFUDevice::read ( uint32_t  bank,
uint32_t  addr,
uint8_t *  data,
int  nbytes 
)
virtual

Reads a chunk of data from the block-address bno (block number).

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.
dataPointer where to store the read data.
nbytesSpecifies the number of bytes to read.
Returns
true on success.

Implements RadioInterface.

◆ read_finish()

bool DFUDevice::read_finish ( )
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.

◆ read_start()

bool DFUDevice::read_start ( uint32_t  bank,
uint32_t  addr 
)
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.

Implements RadioInterface.

◆ reboot()

bool DFUDevice::reboot ( )
virtual

Some radios need to be rebooted after being read or programmed.

This function will be re-implemented by some interfaces (e.g., DFUDevice) to reboot the radio. By default this function does nothing.

Reimplemented from RadioInterface.

◆ write()

bool DFUDevice::write ( uint32_t  bank,
uint32_t  addr,
uint8_t *  data,
int  nbytes 
)
virtual

Writes a chunk of data at the address addr.

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.
dataPointer to the actual data to be written.
nbytesSpecifies the number of bytes to write.
Returns
true on success.

Implements RadioInterface.

◆ write_finish()

bool DFUDevice::write_finish ( )
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.

◆ write_start()

bool DFUDevice::write_start ( uint32_t  bank,
uint32_t  addr 
)
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.

Implements RadioInterface.


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