1#ifndef OPENGD77INTERFACE_HH
2#define OPENGD77INTERFACE_HH
5#include "errorstack.hh"
205 static QList<USBDeviceDescriptor>
detect(
bool saveOnly=
true);
215 READ_DISPLAY_BUFFER = 6,
217 READ_AMBE_BUFFER = 8,
218 READ_FIRMWARE_INFO = 9
242 GD77=0, GD77S=1, DM1801=2,
RD5R=3, DM1801A=4, MD9600=5,
278 SET_FLASH_SECTOR = 1,
279 WRITE_SECTOR_BUFFER = 2,
280 WRITE_FLASH_SECTOR = 3,
294 struct __attribute__((packed)) {
305 bool initWriteEEPROM(Variant variant, uint32_t addr,
const uint8_t *data, uint16_t size);
307 bool initSetFlashSector(Variant variant, uint32_t addr);
309 bool initWriteFlash(Variant variant, uint32_t addr,
const uint8_t *data, uint16_t size);
311 bool initFinishWriteFlash(Variant variant);
330 CLOSE_CPS_SCREEN = 5,
336 SAVE_SETTINGS_NOT_VFOS = 0,
338 SAVE_SETTINGS_AND_VFOS = 2,
360 struct __attribute__((packed)) {
Implements an USB interface to the Baofeng DM-1701 and Retevis RT84 VHF/UHF 5W DMR (Tier I&II) radios...
Definition dm1701.hh:39
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
Implements an USB interface to the Radioddity GD-77(S) VHF/UHF 5W DMR (Tier I&II) radios.
Definition gd77.hh:22
Implements an USB interface to the TYT MD-2017 & Retevis RT82 VHF/UHF 5W DMR (Tier I&II) radios.
Definition md2017.hh:36
bool setFlashSector(uint32_t addr, const ErrorStack &err=ErrorStack())
Select the correct Flash sector for the given address.
Definition opengd77_interface.cc:591
bool sendShowCPSScreen(const ErrorStack &err=ErrorStack())
Send a "show CPS screen" message.
Definition opengd77_interface.cc:737
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 opengd77_interface.cc:400
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 opengd77_interface.cc:280
int32_t _sector
The current Flash sector, set to -1 if none is currently selected.
Definition opengd77_interface.hh:435
bool reboot(const ErrorStack &err=ErrorStack())
Some radios need to be rebooted after being read or programmed.
Definition opengd77_interface.cc:452
void close()
Closes the interface to the device.
Definition opengd77_interface.cc:229
Variant
Specifies the detected model variant.
Definition opengd77_interface.hh:165
bool setDateTime(const QDateTime &datetime, const ErrorStack &err)
Some radios allow to set date and time of the internal clock during codeplug upload.
Definition opengd77_interface.cc:435
OpenGD77Interface(const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
Constructs a new interface to a specific OpenGD77 device.
Definition opengd77_interface.cc:206
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 opengd77_interface.cc:322
bool finishWriteFlash(const ErrorStack &err=ErrorStack())
Finalize writing to the Flash memory.
Definition opengd77_interface.cc:664
static const uint32_t EEPROM
The EEPROM memory bank.
Definition opengd77_interface.hh:160
bool sendClearScreen(const ErrorStack &err=ErrorStack())
Send a "clear screen" message.
Definition opengd77_interface.cc:768
bool sendSetDateTime(const QDateTime &dt, const ErrorStack &err=ErrorStack())
Send a "set date time" message.
Definition opengd77_interface.cc:898
static USBDeviceInfo interfaceInfo()
Returns some information about this interface.
Definition opengd77_interface.cc:218
bool read_finish(const ErrorStack &err=ErrorStack())
This function ends a series of read operations.
Definition opengd77_interface.cc:427
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 opengd77_interface.cc:376
bool readFlash(uint32_t addr, uint8_t *data, uint16_t len, const ErrorStack &err=ErrorStack())
Read some data from Flash at the given address.
Definition opengd77_interface.cc:541
bool sendCommand(CommandRequest::Option option, const ErrorStack &err=ErrorStack())
Sends some command message with the given options.
Definition opengd77_interface.cc:930
virtual ~OpenGD77Interface()
Destructor.
Definition opengd77_interface.cc:213
bool writeFlash(uint32_t addr, const uint8_t *data, uint16_t len, const ErrorStack &err=ErrorStack())
Write some data to the given Flash memory.
Definition opengd77_interface.cc:627
bool sendCloseScreen(const ErrorStack &err=ErrorStack())
Send a "close screen" message.
Definition opengd77_interface.cc:866
bool sendRenderCPS(const ErrorStack &err=ErrorStack())
Send a "render CPS screen" message.
Definition opengd77_interface.cc:834
bool write_finish(const ErrorStack &err=ErrorStack())
This function ends a series of write operations.
Definition opengd77_interface.cc:364
Variant _protocolVariant
The protocol variant determined by the device type obtained by the firmware info.
Definition opengd77_interface.hh:430
bool sendDisplay(uint8_t 1, uint8_t y, const char *message, uint8_t iSize, uint8_t alignment, uint8_t inverted, const ErrorStack &err=ErrorStack())
Send a "display some text" message.
Definition opengd77_interface.cc:802
bool readFirmwareInfo(FirmwareInfo &radioInfo, const ErrorStack &err=ErrorStack())
Read radio info struct.
Definition opengd77_interface.cc:700
bool _extendedCallsignDB
If true, the device allows for storing parts of the call-sign DB inside the voice prompt memory.
Definition opengd77_interface.hh:433
bool extendedCallsignDB() const
Returns true if the device allows for storing part of the call-sign DB inside the voice prompt memory...
Definition opengd77_interface.cc:274
bool readEEPROM(uint32_t addr, uint8_t *data, uint16_t len, const ErrorStack &err=ErrorStack())
Read some data from EEPROM at the given address.
Definition opengd77_interface.cc:459
static const uint32_t FLASH
The Flash memory bank.
Definition opengd77_interface.hh:162
RadioInfo identifier(const ErrorStack &err=ErrorStack())
Returns an identifier of the radio.
Definition opengd77_interface.cc:235
bool writeEEPROM(uint32_t addr, const uint8_t *data, uint16_t len, const ErrorStack &err=ErrorStack())
Write some data to EEPROM at the given address.
Definition opengd77_interface.cc:506
Implements an interface to the Baofeng/Radioddity RD-5R VHF/UHF 5W DMR (Tier I/II) radio.
Definition rd5r.hh:37
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
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 ID...
Definition usbserial.cc:19
static QList< USBDeviceDescriptor > detect()
Searches for all USB serial ports.
Definition usbserial.cc:133
Represents a command message.
Definition opengd77_interface.hh:323
void initClearScreen()
Construct a clear-screen command message.
Definition opengd77_interface.cc:133
void initRenderCPS()
Construct a "render CPS" message.
Definition opengd77_interface.cc:160
void initCloseScreen()
Construct a "close screen" command message.
Definition opengd77_interface.cc:172
char message[16]
Some text message.
Definition opengd77_interface.hh:374
void initSetDateTime(const QDateTime &dt)
Construct a SET_DATETIME message with the given date time.
Definition opengd77_interface.cc:196
uint8_t alignment
The text alignment.
Definition opengd77_interface.hh:366
uint8_t option
The command option.
Definition opengd77_interface.hh:356
uint8_t inverted
Is text inverted?
Definition opengd77_interface.hh:368
void initCommand(Option option)
Construct a command message with the given option.
Definition opengd77_interface.cc:184
void initDisplay(uint8_t 1, uint8_t y, const char *message, unsigned int iSize, uint8_t font, uint8_t alignment, uint8_t inverted)
Construct a "show text on screen" message.
Definition opengd77_interface.cc:145
uint8_t command
The command.
Definition opengd77_interface.hh:350
Command
Possible commands.
Definition opengd77_interface.hh:325
uint8_t y
The y-position on the screen.
Definition opengd77_interface.hh:362
void initShowCPSScreen()
Construct "show CPS screen" command message.
Definition opengd77_interface.cc:121
char type
Message type, here 'C' for command.
Definition opengd77_interface.hh:348
uint8_t font
The font size.
Definition opengd77_interface.hh:364
Option
Possible options.
Definition opengd77_interface.hh:335
uint8_t
The x-position on the screen.
Definition opengd77_interface.hh:354
Radio information struct.
Definition opengd77_interface.hh:239
char build_date[16]
Firmware build time, YYYYMMDDhhmmss, 0-padded.
Definition opengd77_interface.hh:249
uint16_t features
Some flags, signaling the presence of some features.
Definition opengd77_interface.hh:251
RadioType
Possible radio types, returned by the radio_info struct.
Definition opengd77_interface.hh:241
bool featureVoicePromptLoaded() const
Returns true if the voice prompt data is loaded.
Definition opengd77_interface.cc:33
uint32_t structVersion
Struct version number (currently 3).
Definition opengd77_interface.hh:246
uint32_t flashChipSerial
Serial number of the flash chip.
Definition opengd77_interface.hh:250
bool featureExtendedCallsignDB() const
Returns true if the vocie prompt memory is used for storing callsign db.
Definition opengd77_interface.cc:28
uint32_t radioType
Device variant (see RadioType).
Definition opengd77_interface.hh:247
bool featureInvertedDisplay() const
Returns true if the devices display is inverted.
Definition opengd77_interface.cc:23
char fw_revision[16]
Firmware revision ASCII, 0-padded.
Definition opengd77_interface.hh:248
Represents a read message.
Definition opengd77_interface.hh:209
bool initReadEEPROM(uint32_t address, uint16_t length)
Constructs an EEPROM read message.
Definition opengd77_interface.cc:43
bool initReadFlash(uint32_t address, uint16_t length)
Constructs a FLASH read message.
Definition opengd77_interface.cc:52
bool initReadFirmwareInfo()
Constructs a firmware-info read message.
Definition opengd77_interface.cc:61
uint32_t address
Memory address to read from in big endian.
Definition opengd77_interface.hh:226
Command
Possible read sources.
Definition opengd77_interface.hh:211
uint8_t command
Memory to read from, FLASH, EEPROM, ROM, etc.
Definition opengd77_interface.hh:224
char type
'R' read block, 'W' write block, 'C' command.
Definition opengd77_interface.hh:222
uint16_t length
Amount of data to read in big endian.
Definition opengd77_interface.hh:228
Represents a read response message.
Definition opengd77_interface.hh:262
uint16_t length
Length of paylod.
Definition opengd77_interface.hh:266
FirmwareInfo info
Firmware information struct.
Definition opengd77_interface.hh:270
uint8_t data[32]
Data payload.
Definition opengd77_interface.hh:269
char type
Same code as request. That is 'R' read block, 'W' write block, 'C' command.
Definition opengd77_interface.hh:264
Represents a write message.
Definition opengd77_interface.hh:275
Command
Possible write destinations.
Definition opengd77_interface.hh:277
uint8_t sector[3]
24 bit sector number.
Definition opengd77_interface.hh:292
uint16_t length
Payload length.
Definition opengd77_interface.hh:298
char type
'R' read block, 'W'/'X' write block or 'C' command.
Definition opengd77_interface.hh:286
uint32_t address
Target address.
Definition opengd77_interface.hh:296
uint8_t data[32]
Payload data.
Definition opengd77_interface.hh:300
uint8_t command
Command,.
Definition opengd77_interface.hh:288
Represents a write-response message.
Definition opengd77_interface.hh:315
char type
Same code as request. That is 'R' read block, 'W' write block, 'C' command or '-' on Error.
Definition opengd77_interface.hh:317
uint8_t command
Same code as request if OK.
Definition opengd77_interface.hh:319