libdrmconf  0.10.4
A library to program DMR radios.
radioddity_interface.hh
1 #ifndef RADIODDITY_INTERFACE_HH
2 #define RADIODDITY_INTERFACE_HH
3 
4 #include <QtGlobal>
5 #include <QObject>
6 #include "radiointerface.hh"
7 
8 #ifdef Q_OS_MACOS
9 #include "hid_macos.hh"
10 #else
11 #include "hid_libusb.hh"
12 #endif
13 
18 {
19  Q_OBJECT
20 
21 public:
23  enum MemoryBank {
24  MEMBANK_NONE = -1,
29  };
30 
31 public:
33  explicit RadioddityInterface(const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent = nullptr);
35  virtual ~RadioddityInterface();
36 
38  bool isOpen() const;
39 
40  void close();
41 
44 
45  bool read_start(uint32_t bank, uint32_t addr, const ErrorStack &err=ErrorStack());
46 
54  bool read(uint32_t bank, uint32_t addr, unsigned char *data, int nbytes, const ErrorStack &err=ErrorStack());
55 
56  bool read_finish(const ErrorStack &err=ErrorStack());
57 
58  bool write_start(uint32_t bank, uint32_t addr, const ErrorStack &err=ErrorStack());
59 
67  bool write(uint32_t bank, uint32_t addr, unsigned char *data, int nbytes, const ErrorStack &err=ErrorStack());
68 
69  bool write_finish(const ErrorStack &err=ErrorStack());
70 
71 public:
75  static QList<USBDeviceDescriptor> detect();
76 
77 protected:
79  bool selectMemoryBank(MemoryBank bank, const ErrorStack &err=ErrorStack());
80 
81 private:
83  MemoryBank _current_bank;
85  RadioInfo _identifier;
86 };
87 
88 #endif // RADIODDITY_INTERFACE_HH
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Implements the HID radio interface using libusb.
Definition: hid_libusb.hh:12
Provides some information about a radio model.
Definition: radioinfo.hh:16
Abstract radio interface.
Definition: radiointerface.hh:21
Implements a radio interface for radios using the HID USB schema (i.e.
Definition: radioddity_interface.hh:18
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: radioddity_interface.cc:119
bool selectMemoryBank(MemoryBank bank, const ErrorStack &err=ErrorStack())
Internal used function to select a memory bank.
Definition: radioddity_interface.cc:250
void close()
Closes the connection to the device.
Definition: radioddity_interface.cc:52
bool read_finish(const ErrorStack &err=ErrorStack())
This function ends a series of read operations.
Definition: radioddity_interface.cc:157
bool read(uint32_t bank, uint32_t addr, unsigned char *data, int nbytes, const ErrorStack &err=ErrorStack())
Reads a block of data from the device at the given block number.
Definition: radioddity_interface.cc:131
RadioInfo identifier(const ErrorStack &err=ErrorStack())
Returns radio identifier string.
Definition: radioddity_interface.cc:59
static USBDeviceInfo interfaceInfo()
Returns some information about the interface.
Definition: radioddity_interface.cc:37
bool isOpen() const
Returns true if the connection was established.
Definition: radioddity_interface.cc:47
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: radioddity_interface.cc:180
virtual ~RadioddityInterface()
Destructor.
Definition: radioddity_interface.cc:31
bool write_finish(const ErrorStack &err=ErrorStack())
This function ends a series of write operations.
Definition: radioddity_interface.cc:229
MemoryBank
Possible memory banks to select.
Definition: radioddity_interface.hh:23
@ MEMBANK_CODEPLUG_LOWER
Lower memory bank (EEPROM).
Definition: radioddity_interface.hh:25
@ MEMBANK_NONE
No bank selected.
Definition: radioddity_interface.hh:24
@ MEMBANK_CODEPLUG_UPPER
Upper memory bank (FLASH).
Definition: radioddity_interface.hh:26
@ MEMBANK_CALLSIGN_LOWER
Callsign DB memory lower bank (also FLASH).
Definition: radioddity_interface.hh:27
@ MEMBANK_CALLSIGN_UPPER
Callsign DB memory upper bank (also FLASH).
Definition: radioddity_interface.hh:28
bool write(uint32_t bank, uint32_t addr, unsigned char *data, int nbytes, const ErrorStack &err=ErrorStack())
Writes a block of data to the device at the given block number.
Definition: radioddity_interface.cc:192
RadioddityInterface(const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
Connects to the radio via the given descriptor.
Definition: radioddity_interface.cc:24
static QList< USBDeviceDescriptor > detect()
Tries to find all interfaces connected AnyTone radios.
Definition: radioddity_interface.cc:42
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