1 #ifndef OPENGD77INTERFACE_HH
2 #define OPENGD77INTERFACE_HH
4 #include "usbserial.hh"
5 #include "errorstack.hh"
23 static const uint32_t
FLASH = 1;
52 static QList<USBDeviceDescriptor>
detect(
bool saveOnly=
true);
62 READ_DISPLAY_BUFFER = 6,
65 READ_FIRMWARE_INFO = 9
78 bool initReadFlash(uint32_t address, uint16_t length);
80 bool initReadEEPROM(uint32_t address, uint16_t length);
82 bool initReadFirmwareInfo();
110 SET_FLASH_SECTOR = 1,
111 WRITE_SECTOR_BUFFER = 2,
112 WRITE_FLASH_SECTOR = 3,
126 struct __attribute__((packed)) {
137 bool initWriteEEPROM(uint32_t addr,
const uint8_t *data, uint16_t size);
139 bool initSetFlashSector(uint32_t addr);
141 bool initWriteFlash(uint32_t addr,
const uint8_t *data, uint16_t size);
143 bool initFinishWriteFlash();
162 CLOSE_CPS_SCREEN = 5,
168 SAVE_SETTINGS_NOT_VFOS = 0,
170 SAVE_SETTINGS_AND_VFOS = 2,
198 void initShowCPSScreen();
200 void initClearScreen();
202 void initDisplay(uint8_t x, uint8_t y,
const char *message, uint8_t iSize, uint8_t alignment, uint8_t inverted);
204 void initRenderCPS();
206 void initCloseScreen();
208 void initCommand(
Option option);
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Implements the interfact to a radio running the Open GD77 firmware.
Definition: opengd77_interface.hh:16
bool setFlashSector(uint32_t addr, const ErrorStack &err=ErrorStack())
Select the correct Flash sector for the given address.
Definition: opengd77_interface.cc:499
bool sendShowCPSScreen(const ErrorStack &err=ErrorStack())
Send a "show CPS screen" message.
Definition: opengd77_interface.cc:607
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:328
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:207
int32_t _sector
The current Flash sector, set to -1 if none is currently selected.
Definition: opengd77_interface.hh:242
bool reboot(const ErrorStack &err=ErrorStack())
Some radios need to be rebooted after being read or programmed.
Definition: opengd77_interface.cc:361
void close()
Closes the interface to the device.
Definition: opengd77_interface.cc:192
OpenGD77Interface(const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
Constructs a new interface to a specific OpenGD77 device.
Definition: opengd77_interface.cc:170
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:249
bool finishWriteFlash(const ErrorStack &err=ErrorStack())
Finalize writing to the Flash memory.
Definition: opengd77_interface.cc:572
static const uint32_t EEPROM
The EEPROM memory bank.
Definition: opengd77_interface.hh:21
bool sendClearScreen(const ErrorStack &err=ErrorStack())
Send a "clear screen" message.
Definition: opengd77_interface.cc:638
static USBDeviceInfo interfaceInfo()
Returns some information about this interface.
Definition: opengd77_interface.cc:181
bool read_finish(const ErrorStack &err=ErrorStack())
This function ends a series of read operations.
Definition: opengd77_interface.cc:353
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:304
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:449
bool sendCommand(CommandRequest::Option option, const ErrorStack &err=ErrorStack())
Sends some command message with the given options.
Definition: opengd77_interface.cc:767
virtual ~OpenGD77Interface()
Destructor.
Definition: opengd77_interface.cc:176
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:535
bool sendCloseScreen(const ErrorStack &err=ErrorStack())
Send a "close screen" message.
Definition: opengd77_interface.cc:736
bool sendRenderCPS(const ErrorStack &err=ErrorStack())
Send a "render CPS screen" message.
Definition: opengd77_interface.cc:704
bool write_finish(const ErrorStack &err=ErrorStack())
This function ends a series of write operations.
Definition: opengd77_interface.cc:291
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:672
bool readEEPROM(uint32_t addr, uint8_t *data, uint16_t len, const ErrorStack &err=ErrorStack())
Write some data to EEPROM at the given address.
Definition: opengd77_interface.cc:367
static const uint32_t FLASH
The Flash memory bank.
Definition: opengd77_interface.hh:23
RadioInfo identifier(const ErrorStack &err=ErrorStack())
Returns an identifier of the radio.
Definition: opengd77_interface.cc:198
bool writeEEPROM(uint32_t addr, const uint8_t *data, uint16_t len, const ErrorStack &err=ErrorStack())
Read some data from EEPROM at the given address.
Definition: opengd77_interface.cc:414
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
Represents a command message.
Definition: opengd77_interface.hh:155
uint8_t size
The size.
Definition: opengd77_interface.hh:189
uint8_t alignment
The text alignment.
Definition: opengd77_interface.hh:191
uint8_t option
The command option.
Definition: opengd77_interface.hh:184
uint8_t inverted
Is text inverted?
Definition: opengd77_interface.hh:193
uint8_t command
The command.
Definition: opengd77_interface.hh:178
Command
Possible commands.
Definition: opengd77_interface.hh:157
uint8_t y
The y-position on the screen.
Definition: opengd77_interface.hh:187
char type
Message type, here 'C' for command.
Definition: opengd77_interface.hh:176
Option
Possible options.
Definition: opengd77_interface.hh:167
Represents a read message.
Definition: opengd77_interface.hh:56
uint32_t address
Memory address to read from in big endian.
Definition: opengd77_interface.hh:73
Command
Possible read sources.
Definition: opengd77_interface.hh:58
uint8_t command
Memory to read from, FLASH, EEPROM, ROM, etc.
Definition: opengd77_interface.hh:71
char type
'R' read block, 'W' write block, 'C' command.
Definition: opengd77_interface.hh:69
uint16_t length
Amount of data to read in big endian.
Definition: opengd77_interface.hh:75
Represents a read response message.
Definition: opengd77_interface.hh:86
uint16_t length
Length of paylod.
Definition: opengd77_interface.hh:90
uint32_t _unknown24
Some unknown number in little endian, seen 0x4014.
Definition: opengd77_interface.hh:101
uint32_t _unknown00
Some unknown number in little endian, seen 0x0001.
Definition: opengd77_interface.hh:97
char type
Same code as request. That is 'R' read block, 'W' write block, 'C' command.
Definition: opengd77_interface.hh:88
uint32_t _unknown04
Some unknown number in little endian, seen 0x0003.
Definition: opengd77_interface.hh:98
Represents a write message.
Definition: opengd77_interface.hh:107
Command
Possible write destinations.
Definition: opengd77_interface.hh:109
uint16_t length
Payload length.
Definition: opengd77_interface.hh:130
char type
'R' read block, 'W' write block or 'C' command.
Definition: opengd77_interface.hh:118
uint32_t address
Target address.
Definition: opengd77_interface.hh:128
uint8_t command
Command,.
Definition: opengd77_interface.hh:120
Represents a write-response message.
Definition: opengd77_interface.hh:147
char type
Same code as request. That is 'R' read block, 'W' write block, 'C' command or '-' on Error.
Definition: opengd77_interface.hh:149
uint8_t command
Same code as request if OK.
Definition: opengd77_interface.hh:151