libdrmconf  0.12.0
A library to program DMR radios.
usbdevice.hh
1 
89 #ifndef USBDEVICE_HH
90 #define USBDEVICE_HH
91 
92 #include <inttypes.h>
93 #include <QVariant>
94 
99  uint8_t bus;
100  uint8_t device;
101  uint32_t locationId;
102 
104  USBDeviceHandle();
106  USBDeviceHandle(uint8_t busno, uint8_t deviceno, uint32_t locid=0);
107 
109  bool operator==(const USBDeviceHandle &other);
110 };
111 Q_DECLARE_METATYPE(USBDeviceHandle)
112 
113 
121 {
122 public:
124  enum class Class {
125  None,
126  Serial,
127  DFU,
128  HID,
129  C7K
130  };
131 
132 public:
134  USBDeviceInfo();
136  USBDeviceInfo(Class cls, uint16_t vid, uint16_t pid, bool save=true);
138  virtual ~USBDeviceInfo();
139 
141  USBDeviceInfo(const USBDeviceInfo &other);
143  USBDeviceInfo &operator =(const USBDeviceInfo &other);
144 
146  bool operator ==(const USBDeviceInfo &other) const;
148  bool operator !=(const USBDeviceInfo &other) const;
149 
151  bool isValid() const;
152 
154  Class interfaceClass() const;
155 
157  bool hasVendorID() const;
159  uint16_t vendorId() const;
161  bool hasProductID() const;
163  uint16_t productId() const;
164 
166  QString description() const;
167 
169  QString longDescription() const;
170 
175  bool isSave() const;
176 
177 protected:
181  uint16_t _vid;
183  uint16_t _pid;
185  bool _save;
186 };
187 
188 
197 {
198 protected:
200  USBDeviceDescriptor(const USBDeviceInfo &info, const QString &device);
203 
204 public:
209 
212 
215  bool isValid() const;
216 
218  QString description() const;
219 
221  const QVariant &device() const;
223  QString deviceHandle() const;
224 
225 public:
227  static QList<USBDeviceDescriptor> detect(bool saveOnly=true);
228 
229 protected:
231  bool validSerial() const;
233  bool validRawUSB() const;
234 
235 protected:
237  QVariant _device;
238 };
239 
240 #endif // USBDEVICE_HH
Base class for all radio interface descriptors representing a unique interface to a connected radio.
Definition: usbdevice.hh:197
QString deviceHandle() const
Returns a unique string representation of the device information.
Definition: usbdevice.cc:295
static QList< USBDeviceDescriptor > detect(bool saveOnly=true)
Searches for all connected radios (may contain false positives).
Definition: usbdevice.cc:312
QVariant _device
Holds some information to identify the radio interface uniquely.
Definition: usbdevice.hh:237
bool validSerial() const
Checks a serial port.
Definition: usbdevice.cc:255
QString description() const
Returns a human readable description of the device.
Definition: usbdevice.cc:273
bool validRawUSB() const
Checks a raw USB device.
Definition: usbdevice.cc:209
bool isValid() const
Returns true if the descriptor is still valid.
Definition: usbdevice.cc:190
USBDeviceDescriptor & operator=(const USBDeviceDescriptor &other)
Assignment.
Definition: usbdevice.cc:183
USBDeviceDescriptor()
Empty constructor.
Definition: usbdevice.cc:158
const QVariant & device() const
Returns the device information identifying the interface uniquely.
Definition: usbdevice.cc:290
Generic information about a possible radio interface.
Definition: usbdevice.hh:121
uint16_t _pid
The USB pid.
Definition: usbdevice.hh:183
bool _save
If true, it is save to send commands to the device without user approval.
Definition: usbdevice.hh:185
uint16_t _vid
The USB vid.
Definition: usbdevice.hh:181
Class _class
The class of the interface.
Definition: usbdevice.hh:179
Class
Possible interface types.
Definition: usbdevice.hh:124
Combines the USB bus and device number, to address a USB device uniquely.
Definition: usbdevice.hh:98
uint8_t bus
Holds the bus number.
Definition: usbdevice.hh:99
uint32_t locationId
On MacOS, holds the location ID.
Definition: usbdevice.hh:101
bool operator==(const USBDeviceHandle &other)
Compares only wrt bus and device number.
Definition: usbdevice.cc:32
uint8_t device
Holds the device address.
Definition: usbdevice.hh:100
USBDeviceHandle()
Empty constructor.
Definition: usbdevice.cc:19