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.
bladerf2outputplugin.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 <QtPlugin>
19 #include <libbladeRF.h>
20 #include "plugin/pluginapi.h"
21 #include "util/simpleserializer.h"
22 
23 #include "bladerf2outputplugin.h"
24 
25 #ifdef SERVER_MODE
26 #include "bladerf2output.h"
27 #else
28 #include "bladerf2outputgui.h"
29 #endif
30 
32  QString("BladeRF2 Output"),
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 BladeRF2OutputPlugin::m_hardwareID = "BladeRF2";
42 
44  QObject(parent)
45 {
46 }
47 
49 {
50  return m_pluginDescriptor;
51 }
52 
54 {
55  pluginAPI->registerSampleSink(m_deviceTypeID, this);
56 }
57 
59 {
60  SamplingDevices result;
61  struct bladerf_devinfo *devinfo = 0;
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("Bladerf2OutputPlugin::enumSampleSinks: No device at index %d", i);
76  continue;
77  }
78  else if (status != 0)
79  {
80  qCritical("Bladerf2OutputPlugin::enumSampleSinks: 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, "bladerf2") == 0)
87  {
88  unsigned int nbTxChannels = bladerf_get_channel_count(dev, BLADERF_TX);
89 
90  for (unsigned int j = 0; j < nbTxChannels; j++)
91  {
92  qDebug("Blderf2InputPlugin::enumSampleSinks: device #%d (%s) channel %u", i, devinfo[i].serial, j);
93  QString displayedName(QString("BladeRF2[%1:%2] %3").arg(devinfo[i].instance).arg(j).arg(devinfo[i].serial));
94  result.append(SamplingDevice(displayedName,
97  QString(devinfo[i].serial),
98  i,
101  nbTxChannels,
102  j));
103  }
104  }
105 
106  bladerf_close(dev);
107  }
108 
109  bladerf_free_device_list(devinfo); // Valgrind memcheck
110  }
111 
112  return result;
113 }
114 
115 #ifdef SERVER_MODE
117  const QString& sinkId,
118  QWidget **widget,
119  DeviceUISet *deviceUISet)
120 {
121  (void) sinkId;
122  (void) widget;
123  (void) deviceUISet;
124  return 0;
125 }
126 #else
128  const QString& sinkId,
129  QWidget **widget,
130  DeviceUISet *deviceUISet)
131 {
132  if(sinkId == m_deviceTypeID)
133  {
134  BladeRF2OutputGui* gui = new BladeRF2OutputGui(deviceUISet);
135  *widget = gui;
136  return gui;
137  }
138  else
139  {
140  return 0;
141  }
142 }
143 #endif
144 
146 {
147  if(sinkId == m_deviceTypeID)
148  {
149  BladeRF2Output* output = new BladeRF2Output(deviceAPI);
150  return output;
151  }
152  else
153  {
154  return 0;
155  }
156 }
157 
158 
159 
160 
void registerSampleSink(const QString &sinkName, PluginInterface *plugin)
Definition: pluginapi.cpp:24
virtual SamplingDevices enumSampleSinks()
static const QString m_deviceTypeID
static const PluginDescriptor m_pluginDescriptor
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
#define BLADERF2OUTPUT_DEVICE_TYPE_ID
virtual DeviceSampleSink * createSampleSinkPluginInstance(const QString &sinkId, DeviceAPI *deviceAPI)
virtual PluginInstanceGUI * createSampleSinkPluginInstanceGUI(const QString &sinkId, QWidget **widget, DeviceUISet *deviceUISet)
const PluginDescriptor & getPluginDescriptor() const
int32_t i
Definition: decimators.h:244
Exposes a single output stream that can be one of the streams of a physical device.
static const QString m_hardwareID
BladeRF2OutputPlugin(QObject *parent=0)
QList< SamplingDevice > SamplingDevices
void initPlugin(PluginAPI *pluginAPI)