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

Implements the interface to Anytone D868UV, D878UV, etc radios. More...

#include <anytone_interface.hh>

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

Classes

struct  RadioInfoResponse
 Structure of radio information response. More...
 
struct  RadioVariant
 Collects information about the particular radio being accessed. More...
 
struct  ReadRequest
 Binary representation of a read request to the radio. More...
 
struct  ReadResponse
 Binary representation of a read response from the radio. More...
 
struct  WriteRequest
 Binary representation of a write request to the radio. More...
 

Public Member Functions

 AnytoneInterface (const USBDeviceDescriptor &descriptor, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
 Constructs a new interface to Anytone radios. More...
 
virtual ~AnytoneInterface ()
 Destructor.
 
void close ()
 Closes the interface to the device.
 
RadioInfo identifier (const ErrorStack &err=ErrorStack())
 Returns an identifier of the radio.
 
bool getInfo (RadioVariant &info)
 Reads the radio info from the device and returns it. More...
 
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, uint8_t *data, int nbytes, const ErrorStack &err=ErrorStack())
 Reads a chunk of data from the block-address bno (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, uint8_t *data, int nbytes, const ErrorStack &err=ErrorStack())
 Writes a chunk of data at the address addr. More...
 
bool write_finish (const ErrorStack &err=ErrorStack())
 This function ends a series of write operations. More...
 
bool reboot (const ErrorStack &err=ErrorStack())
 Some radios need to be rebooted after being read or programmed. More...
 
- Public Member Functions inherited from USBSerial
virtual ~USBSerial ()
 Destructor.
 
bool isOpen () const
 If true, the device has been found and is open.
 
void close ()
 Closes the interface to the device.
 
- Public Member Functions inherited from RadioInterface
virtual ~RadioInterface ()
 Destructor.
 

Static Public Member Functions

static USBDeviceInfo interfaceInfo ()
 Returns some information about this interface.
 
static QList< USBDeviceDescriptordetect (bool saveOnly=true)
 Tries to find all interfaces connected AnyTone radios.
 
- Static Public Member Functions inherited from USBSerial
static QList< USBDeviceDescriptordetect (uint16_t vid, uint16_t pid, bool isSave=true)
 Searches for all USB serial ports with the specified VID/PID.
 
static QList< USBDeviceDescriptordetect ()
 Searches for all USB serial ports.
 

Protected Types

enum  State {
  STATE_INITIALIZED , STATE_OPEN , STATE_PROGRAM , STATE_CLOSED ,
  STATE_ERROR
}
 Possible states of the radio interface. More...
 

Protected Member Functions

bool enter_program_mode (const ErrorStack &err=ErrorStack())
 Send command message to radio to ender program state.
 
bool request_identifier (RadioVariant &info, const ErrorStack &err=ErrorStack())
 Sends a request to radio to identify itself.
 
bool leave_program_mode (const ErrorStack &err=ErrorStack())
 Sends a command message to radio to leave program state and reboot.
 
bool send_receive (const char *cmd, int clen, char *resp, int rlen, const ErrorStack &err=ErrorStack())
 Internal used method to send messages to and receive responses from radio.
 
- Protected Member Functions inherited from USBSerial
 USBSerial (const USBDeviceDescriptor &descriptor, QSerialPort::BaudRate rate=QSerialPort::Baud115200, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
 Constructs an opens new serial interface to the devices identified by the given vendor and product IDs. More...
 
QString formatPinoutSignals ()
 Serializes the pinout singals.
 
- Protected Member Functions inherited from RadioInterface
 RadioInterface ()
 Hidden constructor.
 

Protected Attributes

State _state
 Holds the state of the interface.
 
RadioVariant _info
 Holds the radio info.
 

Additional Inherited Members

- Protected Slots inherited from USBSerial
void onError (QSerialPort::SerialPortError error_t)
 Callback for serial interface errors.
 
void onClose ()
 Callback when closing interface.
 
void signalingChanged ()
 Signaling callback.
 

Detailed Description

Implements the interface to Anytone D868UV, D878UV, etc radios.

This interface uses a USB serial-port to communicate with the device. To find the corresponding port, the device-specific VID 0x28e9 and PID 0x018a are used. Hence no udev rules are needed to access these devices. The user, however, should be a member of the dialout group to get access to the serial interfaces.

Member Enumeration Documentation

◆ State

enum AnytoneInterface::State
protected

Possible states of the radio interface.

Enumerator
STATE_INITIALIZED 

Initial state.

STATE_OPEN 

Interface to radio is open.

STATE_PROGRAM 

Radio is in program mode.

STATE_CLOSED 

Interface to radio is closed (captive final state).

STATE_ERROR 

An error occurred (captive final state), use errorMessage() to get an error message.

Constructor & Destructor Documentation

◆ AnytoneInterface()

AnytoneInterface::AnytoneInterface ( const USBDeviceDescriptor descriptor,
const ErrorStack err = ErrorStack(),
QObject *  parent = nullptr 
)
explicit

Constructs a new interface to Anytone radios.

If a matching device was found, isOpen returns true.

Member Function Documentation

◆ getInfo()

bool AnytoneInterface::getInfo ( RadioVariant info)

Reads the radio info from the device and returns it.

The information is only read once.

◆ read()

bool AnytoneInterface::read ( uint32_t  bank,
uint32_t  addr,
uint8_t *  data,
int  nbytes,
const ErrorStack err = ErrorStack() 
)
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.
errPasses an error stack to put error messages on.
Returns
true on success.

Implements RadioInterface.

◆ read_finish()

bool AnytoneInterface::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 AnytoneInterface::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.

◆ reboot()

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

Parameters
errPasses an error stack to put error messages on.

Reimplemented from RadioInterface.

◆ write()

bool AnytoneInterface::write ( uint32_t  bank,
uint32_t  addr,
uint8_t *  data,
int  nbytes,
const ErrorStack err = ErrorStack() 
)
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.
errPasses an error stack to put error messages on.
Returns
true on success.

Implements RadioInterface.

◆ write_finish()

bool AnytoneInterface::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 AnytoneInterface::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: