libdrmconf  0.12.0
A library to program DMR radios.
auctus_a6_interface.hh
1 
6 #ifndef AUCTUS_A6_INTERFACE_HH
7 #define AUCTUS_A6_INTERFACE_HH
8 
9 #include <QObject>
10 #include "usbserial.hh"
11 
20 {
21  Q_OBJECT
22 
23 public:
25  enum State {
27  IDLE,
30  ERROR
31  };
32 
33 protected:
35  explicit AuctusA6Interface(const USBDeviceDescriptor &descriptor,
36  const ErrorStack &err=ErrorStack(), QObject *parent=nullptr);
37 
38 public:
40  State state() const;
41 
42 protected:
44  bool send_receive(uint16_t command, const uint8_t *params, uint8_t plen,
45  uint8_t *response, uint8_t &rlen, const ErrorStack &err=ErrorStack());
47  bool send(uint16_t command, const uint8_t *params, uint8_t plen, const ErrorStack &err=ErrorStack());
49  bool receive(uint16_t &command, uint8_t *response, uint8_t &rlen, const ErrorStack &err=ErrorStack());
50 
52  bool read(uint8_t *data, qint64 n, unsigned int timeout_ms, const ErrorStack &err=ErrorStack());
53 
54 protected:
57 };
58 
59 #endif // AUCTUS_A6_INTERFACE_HH
Implements the communication interface to radios using the Auctus A6 chip.
Definition: auctus_a6_interface.hh:20
bool send_receive(uint16_t command, const uint8_t *params, uint8_t plen, uint8_t *response, uint8_t &rlen, const ErrorStack &err=ErrorStack())
Internal used method to send messages to and receive responses from radio.
Definition: auctus_a6_interface.cc:33
bool receive(uint16_t &command, uint8_t *response, uint8_t &rlen, const ErrorStack &err=ErrorStack())
Internal used method to receive a response.
Definition: auctus_a6_interface.cc:106
bool send(uint16_t command, const uint8_t *params, uint8_t plen, const ErrorStack &err=ErrorStack())
Internal used method to send a command.
Definition: auctus_a6_interface.cc:60
State _state
Holds the state of the interface.
Definition: auctus_a6_interface.hh:56
State
Possible states of the interface.
Definition: auctus_a6_interface.hh:25
@ ERROR
An error state.
Definition: auctus_a6_interface.hh:30
@ CLOSED
Conntection to device is closed.
Definition: auctus_a6_interface.hh:26
@ IDLE
Connection is open and device is ready.
Definition: auctus_a6_interface.hh:27
@ READ_THROUGH
Read from memory. The device just sends some amount of data.
Definition: auctus_a6_interface.hh:28
@ WRITE_THROUGH
Write to memory. The device just receives some amount of data.
Definition: auctus_a6_interface.hh:29
bool read(uint8_t *data, qint64 n, unsigned int timeout_ms, const ErrorStack &err=ErrorStack())
Reads exactly n bytes or timeouts.
Definition: auctus_a6_interface.cc:168
AuctusA6Interface(const USBDeviceDescriptor &descriptor, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
Hidden constructor.
Definition: auctus_a6_interface.cc:9
State state() const
Returns the interface state.
Definition: auctus_a6_interface.cc:27
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Base class for all radio interface descriptors representing a unique interface to a connected radio.
Definition: usbdevice.hh:197
Implements a serial connection to a radio via USB.
Definition: usbserial.hh:16