1 #ifndef ANYTONEINTERFACE_HH
2 #define ANYTONEINTERFACE_HH
4 #include "usbserial.hh"
66 static QList<USBDeviceDescriptor>
detect(
bool saveOnly=
true);
99 bool check(uint32_t addr, QString &msg)
const;
Implements the interface to Anytone D868UV, D878UV, etc radios.
Definition: anytone_interface.hh:15
bool leave_program_mode(const ErrorStack &err=ErrorStack())
Sends a command message to radio to leave program state and reboot.
Definition: anytone_interface.cc:342
void close()
Closes the interface to the device.
Definition: anytone_interface.cc:126
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).
Definition: anytone_interface.cc:230
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.
Definition: anytone_interface.cc:172
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.
Definition: anytone_interface.cc:182
State _state
Holds the state of the interface.
Definition: anytone_interface.hh:137
RadioInfo identifier(const ErrorStack &err=ErrorStack())
Returns an identifier of the radio.
Definition: anytone_interface.cc:142
bool read_finish(const ErrorStack &err=ErrorStack())
This function ends a series of read operations.
Definition: anytone_interface.cc:263
bool enter_program_mode(const ErrorStack &err=ErrorStack())
Send command message to radio to ender program state.
Definition: anytone_interface.cc:283
State
Possible states of the radio interface.
Definition: anytone_interface.hh:127
@ STATE_CLOSED
Interface to radio is closed (captive final state).
Definition: anytone_interface.hh:131
@ STATE_ERROR
An error occurred (captive final state), use errorMessage() to get an error message.
Definition: anytone_interface.hh:132
@ STATE_OPEN
Interface to radio is open.
Definition: anytone_interface.hh:129
@ STATE_PROGRAM
Radio is in program mode.
Definition: anytone_interface.hh:130
@ STATE_INITIALIZED
Initial state.
Definition: anytone_interface.hh:128
static USBDeviceInfo interfaceInfo()
Returns some information about this interface.
Definition: anytone_interface.cc:114
AnytoneInterface(const USBDeviceDescriptor &descriptor, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
Constructs a new interface to Anytone radios.
Definition: anytone_interface.cc:88
bool reboot(const ErrorStack &err=ErrorStack())
Some radios need to be rebooted after being read or programmed.
Definition: anytone_interface.cc:269
virtual ~AnytoneInterface()
Destructor.
Definition: anytone_interface.cc:108
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.
Definition: anytone_interface.cc:220
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.
Definition: anytone_interface.cc:363
RadioVariant _info
Holds the radio info.
Definition: anytone_interface.hh:139
bool getInfo(RadioVariant &info)
Reads the radio info from the device and returns it.
Definition: anytone_interface.cc:163
bool request_identifier(RadioVariant &info, const ErrorStack &err=ErrorStack())
Sends a request to radio to identify itself.
Definition: anytone_interface.cc:314
bool write_finish(const ErrorStack &err=ErrorStack())
This function ends a series of write operations.
Definition: anytone_interface.cc:214
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Provides some information about a radio model.
Definition: radioinfo.hh:16
Base class for all radio interface descriptors representing a unique interface to a connected radio.
Definition: usbdevice.hh:197
Generic information about a possible radio interface.
Definition: usbdevice.hh:121
Implements a serial connection to a radio via USB.
Definition: usbserial.hh:16
static QList< USBDeviceDescriptor > detect()
Searches for all USB serial ports.
Definition: usbserial.cc:133
Structure of radio information response.
Definition: anytone_interface.hh:118
uint8_t eot
Fixed 0x06 on success.
Definition: anytone_interface.hh:123
uint8_t bands
Frequency bands supported by radio.
Definition: anytone_interface.hh:121
char prefix
Fixed prefix. Set to 'I' on success.
Definition: anytone_interface.hh:119
Collects information about the particular radio being accessed.
Definition: anytone_interface.hh:20
char bands
A code for which bands are supported.
Definition: anytone_interface.hh:24
RadioVariant()
Empty constructor.
Definition: anytone_interface.cc:73
bool isValid() const
Returns true if the radio info is valid.
Definition: anytone_interface.cc:80
QString version
The (firmware/hardware) version.
Definition: anytone_interface.hh:26
QString name
The name of the radio.
Definition: anytone_interface.hh:22
Binary representation of a read request to the radio.
Definition: anytone_interface.hh:80
uint8_t size
Fixed to 16.
Definition: anytone_interface.hh:83
char cmd
Fixed to 'R'.
Definition: anytone_interface.hh:81
uint32_t addr
Memory address in little-endian.
Definition: anytone_interface.hh:82
Binary representation of a read response from the radio.
Definition: anytone_interface.hh:89
char cmd
Fixed to 'W'.
Definition: anytone_interface.hh:90
uint8_t ack
Fixed to 0x06.
Definition: anytone_interface.hh:95
uint8_t sum
Sum over address, size and data.
Definition: anytone_interface.hh:94
uint8_t size
Fixed to 16.
Definition: anytone_interface.hh:92
uint32_t addr
Memory address in big-endian.
Definition: anytone_interface.hh:91
Binary representation of a write request to the radio.
Definition: anytone_interface.hh:103
uint8_t size
Fixed to 16.
Definition: anytone_interface.hh:106
uint32_t addr
Memory address in big-endian.
Definition: anytone_interface.hh:105
uint8_t ack
Fixed to 0x06;.
Definition: anytone_interface.hh:109
uint8_t sum
Sum over addr, size and data.
Definition: anytone_interface.hh:108
char cmd
Fixed to 'W'.
Definition: anytone_interface.hh:104