mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-16 21:42:34 -04:00
PlutoSDR: remove from device enumeration if device is not accessible (allocate context fails)
This commit is contained in:
parent
21ed8a8391
commit
9ba88b396b
@ -29,6 +29,10 @@
|
|||||||
DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
|
DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
|
||||||
m_lpfFIRRxGain(0),
|
m_lpfFIRRxGain(0),
|
||||||
m_lpfFIRTxGain(0),
|
m_lpfFIRTxGain(0),
|
||||||
|
m_ctx(0),
|
||||||
|
m_devPhy(0),
|
||||||
|
m_devRx(0),
|
||||||
|
m_devTx(0),
|
||||||
m_chnRx0(0),
|
m_chnRx0(0),
|
||||||
m_chnTx0(0),
|
m_chnTx0(0),
|
||||||
m_rxBuf(0),
|
m_rxBuf(0),
|
||||||
@ -36,9 +40,14 @@ DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
|
|||||||
m_xoInitial(0)
|
m_xoInitial(0)
|
||||||
{
|
{
|
||||||
m_ctx = iio_create_context_from_uri(uri.c_str());
|
m_ctx = iio_create_context_from_uri(uri.c_str());
|
||||||
|
|
||||||
|
if (m_ctx)
|
||||||
|
{
|
||||||
m_devPhy = iio_context_find_device(m_ctx, "ad9361-phy");
|
m_devPhy = iio_context_find_device(m_ctx, "ad9361-phy");
|
||||||
m_devRx = iio_context_find_device(m_ctx, "cf-ad9361-lpc");
|
m_devRx = iio_context_find_device(m_ctx, "cf-ad9361-lpc");
|
||||||
m_devTx = iio_context_find_device(m_ctx, "cf-ad9361-dds-core-lpc");
|
m_devTx = iio_context_find_device(m_ctx, "cf-ad9361-dds-core-lpc");
|
||||||
|
}
|
||||||
|
|
||||||
m_valid = m_ctx && m_devPhy && m_devRx && m_devTx;
|
m_valid = m_ctx && m_devPhy && m_devRx && m_devTx;
|
||||||
|
|
||||||
if (m_valid) {
|
if (m_valid) {
|
||||||
@ -64,6 +73,21 @@ DevicePlutoSDRBox::~DevicePlutoSDRBox()
|
|||||||
if (m_ctx) { iio_context_destroy(m_ctx); }
|
if (m_ctx) { iio_context_destroy(m_ctx); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DevicePlutoSDRBox::probeURI(const std::string& uri)
|
||||||
|
{
|
||||||
|
bool retVal;
|
||||||
|
struct iio_context *ctx;
|
||||||
|
|
||||||
|
ctx = iio_create_context_from_uri(uri.c_str());
|
||||||
|
retVal = (ctx != 0);
|
||||||
|
|
||||||
|
if (ctx) {
|
||||||
|
iio_context_destroy(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
void DevicePlutoSDRBox::set_params(DeviceType devType,
|
void DevicePlutoSDRBox::set_params(DeviceType devType,
|
||||||
const std::vector<std::string>& params)
|
const std::vector<std::string>& params)
|
||||||
{
|
{
|
||||||
@ -218,6 +242,8 @@ void DevicePlutoSDRBox::setFilter(const std::string &filterConfigStr)
|
|||||||
|
|
||||||
bool DevicePlutoSDRBox::openRx()
|
bool DevicePlutoSDRBox::openRx()
|
||||||
{
|
{
|
||||||
|
if (!m_valid) { return false; }
|
||||||
|
|
||||||
if (!m_chnRx0) {
|
if (!m_chnRx0) {
|
||||||
m_chnRx0 = iio_device_find_channel(m_devRx, "voltage0", false);
|
m_chnRx0 = iio_device_find_channel(m_devRx, "voltage0", false);
|
||||||
}
|
}
|
||||||
@ -243,6 +269,8 @@ bool DevicePlutoSDRBox::openRx()
|
|||||||
|
|
||||||
bool DevicePlutoSDRBox::openTx()
|
bool DevicePlutoSDRBox::openTx()
|
||||||
{
|
{
|
||||||
|
if (!m_valid) { return false; }
|
||||||
|
|
||||||
if (!m_chnTx0) {
|
if (!m_chnTx0) {
|
||||||
m_chnTx0 = iio_device_find_channel(m_devTx, "voltage0", true);
|
m_chnTx0 = iio_device_find_channel(m_devTx, "voltage0", true);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
DevicePlutoSDRBox(const std::string& uri);
|
DevicePlutoSDRBox(const std::string& uri);
|
||||||
~DevicePlutoSDRBox();
|
~DevicePlutoSDRBox();
|
||||||
bool isValid() const { return m_valid; }
|
bool isValid() const { return m_valid; }
|
||||||
|
static bool probeURI(const std::string& uri);
|
||||||
|
|
||||||
void set_params(DeviceType devType, const std::vector<std::string> ¶ms);
|
void set_params(DeviceType devType, const std::vector<std::string> ¶ms);
|
||||||
bool get_param(DeviceType devType, const std::string ¶m, std::string &value);
|
bool get_param(DeviceType devType, const std::string ¶m, std::string &value);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <iio.h>
|
#include <iio.h>
|
||||||
|
|
||||||
|
#include "deviceplutosdrbox.h"
|
||||||
#include "deviceplutosdrscan.h"
|
#include "deviceplutosdrscan.h"
|
||||||
|
|
||||||
void DevicePlutoSDRScan::scan()
|
void DevicePlutoSDRScan::scan()
|
||||||
@ -50,6 +51,11 @@ void DevicePlutoSDRScan::scan()
|
|||||||
{
|
{
|
||||||
const char *description = iio_context_info_get_description(info[i]);
|
const char *description = iio_context_info_get_description(info[i]);
|
||||||
const char *uri = iio_context_info_get_uri(info[i]);
|
const char *uri = iio_context_info_get_uri(info[i]);
|
||||||
|
|
||||||
|
if (!DevicePlutoSDRBox::probeURI(std::string(uri))) { // continue if not accessible
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
printf("PlutoSDRScan::scan: %d: %s [%s]\n", i, description, uri);
|
printf("PlutoSDRScan::scan: %d: %s [%s]\n", i, description, uri);
|
||||||
char *pch = strstr(const_cast<char*>(description), "PlutoSDR");
|
char *pch = strstr(const_cast<char*>(description), "PlutoSDR");
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
ValueDial::ValueDial(QWidget* parent, ColorMapper colorMapper) :
|
ValueDial::ValueDial(QWidget* parent, ColorMapper colorMapper) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
m_delta(0),
|
||||||
m_animationState(0),
|
m_animationState(0),
|
||||||
m_colorMapper(colorMapper)
|
m_colorMapper(colorMapper)
|
||||||
{
|
{
|
||||||
@ -133,6 +134,13 @@ void ValueDial::setValueRange(uint numDigits, quint64 min, quint64 max)
|
|||||||
setFixedWidth((m_numDigits + m_numDecimalPoints) * m_digitWidth + 2);
|
setFixedWidth((m_numDigits + m_numDecimalPoints) * m_digitWidth + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ValueDial::setDelta(qint64 delta)
|
||||||
|
{
|
||||||
|
m_delta = delta;
|
||||||
|
m_animationTimer.start(20);
|
||||||
|
m_textNew = formatText(m_valueNew);
|
||||||
|
}
|
||||||
|
|
||||||
quint64 ValueDial::findExponent(int digit)
|
quint64 ValueDial::findExponent(int digit)
|
||||||
{
|
{
|
||||||
quint64 e = 1;
|
quint64 e = 1;
|
||||||
@ -158,7 +166,8 @@ QChar ValueDial::digitNeigh(QChar c, bool dir)
|
|||||||
|
|
||||||
QString ValueDial::formatText(quint64 value)
|
QString ValueDial::formatText(quint64 value)
|
||||||
{
|
{
|
||||||
QString str = QString("%1").arg(value, m_numDigits, 10, QChar('0'));
|
qint64 displayValue = value + m_delta > 0 ? value + m_delta : 0;
|
||||||
|
QString str = QString("%1").arg(displayValue, m_numDigits, 10, QChar('0'));
|
||||||
|
|
||||||
for(int i = 0; i < m_numDecimalPoints; i++)
|
for(int i = 0; i < m_numDecimalPoints; i++)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,8 @@ public:
|
|||||||
|
|
||||||
void setValue(quint64 value);
|
void setValue(quint64 value);
|
||||||
void setValueRange(uint numDigits, quint64 min, quint64 max);
|
void setValueRange(uint numDigits, quint64 min, quint64 max);
|
||||||
|
void setDelta(qint64 delta);
|
||||||
|
qint64 getDelta() const { return m_delta; }
|
||||||
void setFont(const QFont& font);
|
void setFont(const QFont& font);
|
||||||
void setBold(bool bold);
|
void setBold(bool bold);
|
||||||
void setColorMapper(ColorMapper colorMapper);
|
void setColorMapper(ColorMapper colorMapper);
|
||||||
@ -49,6 +51,7 @@ private:
|
|||||||
quint64 m_value;
|
quint64 m_value;
|
||||||
quint64 m_valueMax;
|
quint64 m_valueMax;
|
||||||
quint64 m_valueMin;
|
quint64 m_valueMin;
|
||||||
|
qint64 m_delta;
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
|
||||||
quint64 m_valueNew;
|
quint64 m_valueNew;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user