SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
airspyhfplugin.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <QtPlugin>
19 #include <libairspyhf/airspyhf.h>
20 
21 #include "plugin/pluginapi.h"
22 #include "util/simpleserializer.h"
23 #include "airspyhfplugin.h"
24 #ifdef SERVER_MODE
25 #include "airspyhfinput.h"
26 #else
27 #include "airspyhfgui.h"
28 #endif
29 
30 
32  QString("AirspyHF Input"),
33  QString("4.5.2"),
34  QString("(c) Edouard Griffiths, F4EXB"),
35  QString("https://github.com/f4exb/sdrangel"),
36  true,
37  QString("https://github.com/f4exb/sdrangel")
38 };
39 
40 const QString AirspyHFPlugin::m_hardwareID = "AirspyHF";
42 const int AirspyHFPlugin::m_maxDevices = 32;
43 
45  QObject(parent)
46 {
47 }
48 
50 {
51  return m_pluginDescriptor;
52 }
53 
55 {
56  pluginAPI->registerSampleSource(m_deviceTypeID, this);
57 }
58 
60 {
61  SamplingDevices result;
62  int nbDevices;
63  uint64_t deviceSerials[m_maxDevices];
64 
65  nbDevices = airspyhf_list_devices(deviceSerials, m_maxDevices);
66 
67  if (nbDevices < 0)
68  {
69  qCritical("AirspyHFPlugin::enumSampleSources: failed to list Airspy HF devices");
70  }
71 
72  for (int i = 0; i < nbDevices; i++)
73  {
74  if (deviceSerials[i])
75  {
76  QString serial_str = QString::number(deviceSerials[i], 16);
77  QString displayedName(QString("AirspyHF[%1] %2").arg(i).arg(serial_str));
78 
79  result.append(SamplingDevice(displayedName,
82  serial_str,
83  i,
86  1,
87  0));
88 
89  qDebug("AirspyHFPlugin::enumSampleSources: enumerated Airspy HF device #%d", i);
90  }
91  else
92  {
93  qDebug("AirspyHFPlugin::enumSampleSources: finished to enumerate Airspy HF. %d devices found", i);
94  break; // finished
95  }
96  }
97 
98  return result;
99 }
100 
101 #ifdef SERVER_MODE
103  const QString& sourceId,
104  QWidget **widget,
105  DeviceUISet *deviceUISet)
106 {
107  (void) sourceId;
108  (void) widget;
109  (void) deviceUISet;
110  return 0;
111 }
112 #else
114  const QString& sourceId,
115  QWidget **widget,
116  DeviceUISet *deviceUISet)
117 {
118  if (sourceId == m_deviceTypeID)
119  {
120  AirspyHFGui* gui = new AirspyHFGui(deviceUISet);
121  *widget = gui;
122  return gui;
123  }
124  else
125  {
126  return 0;
127  }
128 }
129 #endif
130 
132 {
133  if (sourceId == m_deviceTypeID)
134  {
135  AirspyHFInput* input = new AirspyHFInput(deviceAPI);
136  return input;
137  }
138  else
139  {
140  return 0;
141  }
142 }
virtual SamplingDevices enumSampleSources()
AirspyHFPlugin(QObject *parent=0)
void registerSampleSource(const QString &sourceName, PluginInterface *plugin)
Definition: pluginapi.cpp:9
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
virtual DeviceSampleSource * createSampleSourcePluginInstance(const QString &sourceId, DeviceAPI *deviceAPI)
void initPlugin(PluginAPI *pluginAPI)
static const int m_maxDevices
int32_t i
Definition: decimators.h:244
static const QString m_deviceTypeID
Exposes a single input stream that can be one of the streams of a physical device.
static const PluginDescriptor m_pluginDescriptor
#define AIRSPYHF_DEVICE_TYPE_ID
const PluginDescriptor & getPluginDescriptor() const
static const QString m_hardwareID
virtual PluginInstanceGUI * createSampleSourcePluginInstanceGUI(const QString &sourceId, QWidget **widget, DeviceUISet *deviceUISet)
QList< SamplingDevice > SamplingDevices
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48