mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-04 14:17:50 -04:00
LimeSDR input: extract serial number from LMS info string
This commit is contained in:
parent
54599c1231
commit
d9b6dde304
@ -1,5 +1,7 @@
|
|||||||
project(limesdrinput)
|
project(limesdrinput)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
|
||||||
set(limesdrinput_SOURCES
|
set(limesdrinput_SOURCES
|
||||||
limesdrinputgui.cpp
|
limesdrinputgui.cpp
|
||||||
limesdrinput.cpp
|
limesdrinput.cpp
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "lime/LimeSuite.h"
|
#include "lime/LimeSuite.h"
|
||||||
#include "plugin/pluginapi.h"
|
#include "plugin/pluginapi.h"
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
@ -77,13 +80,22 @@ PluginInterface::SamplingDevices LimeSDRInputPlugin::enumSampleSources()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < nbDevices; i++)
|
for (int i = 0; i < nbDevices; i++)
|
||||||
{
|
{
|
||||||
qDebug("LimeSDRInputPlugin::enumSampleSources: device #%d: %s", i, (char *) deviceList[i]);
|
std::string serial;
|
||||||
QString displayedName(QString("LimeSDR[%1] %2").arg(i).arg(deviceList[i]));
|
|
||||||
result.append(SamplingDevice(displayedName,
|
if (findSerial((const char *) deviceList[i], serial))
|
||||||
m_hardwareID,
|
{
|
||||||
m_deviceTypeID,
|
qDebug("LimeSDRInputPlugin::enumSampleSources: device #%d: %s", i, (char *) deviceList[i]);
|
||||||
QString(deviceList[i]),
|
QString displayedName(QString("LimeSDR[%1] %2").arg(i).arg(serial.c_str()));
|
||||||
i));
|
result.append(SamplingDevice(displayedName,
|
||||||
|
m_hardwareID,
|
||||||
|
m_deviceTypeID,
|
||||||
|
QString(serial.c_str()),
|
||||||
|
i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDRInputPlugin::enumSampleSources: device #%d: cannot find serial in %s", i, (char *) deviceList[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,4 +117,21 @@ PluginGUI* LimeSDRInputPlugin::createSampleSourcePluginGUI(const QString& source
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LimeSDRInputPlugin::findSerial(const char *lmsInfoStr, std::string& serial)
|
||||||
|
{
|
||||||
|
std::regex serial_reg("serial=([0-9,A-F]+)");
|
||||||
|
std::string input(lmsInfoStr);
|
||||||
|
std::smatch result;
|
||||||
|
std::regex_search(input, result, serial_reg);
|
||||||
|
|
||||||
|
if (result[1].str().length()>0)
|
||||||
|
{
|
||||||
|
serial = result[1].str();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const PluginDescriptor m_pluginDescriptor;
|
static const PluginDescriptor m_pluginDescriptor;
|
||||||
|
static bool findSerial(const char *lmsInfoStr, std::string& serial);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user