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.
bladerf1inputplugin.cpp
Go to the documentation of this file.
1 // Copyright (C) 2015 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 "bladerf1inputplugin.h"
19 
20 #include <QtPlugin>
21 #include <libbladeRF.h>
22 #include "plugin/pluginapi.h"
23 #include "util/simpleserializer.h"
24 
25 #ifdef SERVER_MODE
26 #include "bladerf1input.h"
27 #else
28 #include "bladerf1inputgui.h"
29 #endif
30 
32  QString("BladeRF1 Input"),
33  QString("4.5.4"),
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 Blderf1InputPlugin::m_hardwareID = "BladeRF1";
42 
44  QObject(parent)
45 {
46 }
47 
49 {
50  return m_pluginDescriptor;
51 }
52 
54 {
55  pluginAPI->registerSampleSource(m_deviceTypeID, this);
56 }
57 
59 {
60  SamplingDevices result;
61  struct bladerf_devinfo *devinfo = nullptr;
62 
63  int count = bladerf_get_device_list(&devinfo);
64 
65  if (devinfo)
66  {
67  for(int i = 0; i < count; i++)
68  {
69  struct bladerf *dev;
70 
71  int status = bladerf_open_with_devinfo(&dev, &devinfo[i]);
72 
73  if (status == BLADERF_ERR_NODEV)
74  {
75  qCritical("BlderfInputPlugin::enumSampleSources: No device at index %d", i);
76  continue;
77  }
78  else if (status != 0)
79  {
80  qCritical("BlderfInputPlugin::enumSampleSources: Failed to open device at index %d", i);
81  continue;
82  }
83 
84  const char *boardName = bladerf_get_board_name(dev);
85 
86  if (strcmp(boardName, "bladerf1") == 0)
87  {
88  QString displayedName(QString("BladeRF1[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
89 
90  result.append(SamplingDevice(displayedName,
93  QString(devinfo[i].serial),
94  i,
97  1,
98  0));
99  }
100 
101  bladerf_close(dev);
102  }
103 
104  bladerf_free_device_list(devinfo); // Valgrind memcheck
105  }
106 
107  return result;
108 }
109 
110 #ifdef SERVER_MODE
112  const QString& sourceId,
113  QWidget **widget,
114  DeviceUISet *deviceUISet)
115 {
116  (void) sourceId;
117  (void) widget;
118  (void) deviceUISet;
119  return 0;
120 }
121 #else
123  const QString& sourceId,
124  QWidget **widget,
125  DeviceUISet *deviceUISet)
126 {
127  if(sourceId == m_deviceTypeID)
128  {
129  Bladerf1InputGui* gui = new Bladerf1InputGui(deviceUISet);
130  *widget = gui;
131  return gui;
132  }
133  else
134  {
135  return 0;
136  }
137 }
138 #endif
139 
141 {
142  if (sourceId == m_deviceTypeID)
143  {
144  Bladerf1Input *input = new Bladerf1Input(deviceAPI);
145  return input;
146  }
147  else
148  {
149  return 0;
150  }
151 }
152 
static const PluginDescriptor m_pluginDescriptor
#define BLADERF1INPUT_DEVICE_TYPE_ID
void registerSampleSource(const QString &sourceName, PluginInterface *plugin)
Definition: pluginapi.cpp:9
void initPlugin(PluginAPI *pluginAPI)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
Blderf1InputPlugin(QObject *parent=NULL)
static const QString m_deviceTypeID
virtual DeviceSampleSource * createSampleSourcePluginInstance(const QString &sourceId, DeviceAPI *deviceAPI)
int32_t i
Definition: decimators.h:244
virtual PluginInstanceGUI * createSampleSourcePluginInstanceGUI(const QString &sourceId, QWidget **widget, DeviceUISet *deviceUISet)
static const QString m_hardwareID
virtual SamplingDevices enumSampleSources()
Exposes a single input stream that can be one of the streams of a physical device.
const PluginDescriptor & getPluginDescriptor() const
QList< SamplingDevice > SamplingDevices