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.
Classes | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
PlutoSDRInput Class Reference

#include <plutosdrinput.h>

+ Inheritance diagram for PlutoSDRInput:
+ Collaboration diagram for PlutoSDRInput:

Classes

class  MsgConfigurePlutoSDR
 
class  MsgFileRecord
 
class  MsgStartStop
 

Public Member Functions

 PlutoSDRInput (DeviceAPI *deviceAPI)
 
 ~PlutoSDRInput ()
 
virtual void destroy ()
 
virtual void init ()
 initializations to be done when all collaborating objects are created and possibly connected More...
 
virtual bool start ()
 
virtual void stop ()
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
virtual const QString & getDeviceDescription () const
 
virtual int getSampleRate () const
 Sample rate exposed by the source. More...
 
virtual void setSampleRate (int sampleRate)
 For when the source sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const
 Center frequency exposed by the source. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)
 
virtual bool handleMessage (const Message &message)
 
virtual int webapiRunGet (SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
virtual int webapiRun (bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
virtual int webapiSettingsGet (SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
uint32_t getADCSampleRate () const
 
uint32_t getFIRSampleRate () const
 
void getRSSI (std::string &rssiStr)
 
void getLORange (qint64 &minLimit, qint64 &maxLimit)
 
void getbbLPRange (quint32 &minLimit, quint32 &maxLimit)
 
void getGain (int &gainStr)
 
bool fetchTemperature ()
 
float getTemperature ()
 
- Public Member Functions inherited from DeviceSampleSource
 DeviceSampleSource ()
 
virtual ~DeviceSampleSource ()
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

bool openDevice ()
 
void closeDevice ()
 
void suspendBuddies ()
 
void resumeBuddies ()
 
bool applySettings (const PlutoSDRInputSettings &settings, bool force=false)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const PlutoSDRInputSettings &settings)
 
void webapiFormatDeviceReport (SWGSDRangel::SWGDeviceReport &response)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const PlutoSDRInputSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
FileRecordm_fileSink
 
QString m_deviceDescription
 
PlutoSDRInputSettings m_settings
 
bool m_running
 
DevicePlutoSDRShared m_deviceShared
 
struct iio_buffer * m_plutoRxBuffer
 
PlutoSDRInputThreadm_plutoSDRInputThread
 
DevicePlutoSDRBox::SampleRates m_deviceSampleRates
 
QMutex m_mutex
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Additional Inherited Members

- Public Types inherited from DeviceSampleSource
enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 
enum  FrequencyShiftScheme { FSHIFT_STD = 0, FSHIFT_TXSYNC }
 
- Static Public Member Functions inherited from DeviceSampleSource
static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme)
 
- Protected Slots inherited from DeviceSampleSource
void handleInputMessages ()
 
- Protected Attributes inherited from DeviceSampleSource
SampleSinkFifo m_sampleFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the source. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 38 of file plutosdrinput.h.

Constructor & Destructor Documentation

◆ PlutoSDRInput()

PlutoSDRInput::PlutoSDRInput ( DeviceAPI deviceAPI)

Definition at line 43 of file plutosdrinput.cpp.

References arg().

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

43  :
44  m_deviceAPI(deviceAPI),
45  m_fileSink(0),
46  m_deviceDescription("PlutoSDRInput"),
47  m_running(false),
48  m_plutoRxBuffer(0),
50 {
57 
59  openDevice();
60  resumeBuddies();
61 
62  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
65 
66  m_networkManager = new QNetworkAccessManager();
67  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
68 }
PlutoSDRInputThread * m_plutoSDRInputThread
FileRecord * m_fileSink
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
struct iio_buffer * m_plutoRxBuffer
DevicePlutoSDRBox::SampleRates m_deviceSampleRates
QNetworkAccessManager * m_networkManager
QString m_deviceDescription
uint32_t m_hb3Rate
Rate of the HB3/(DEC3 or INT3) filter (Rx: out, Tx: in) - this is the HB2 working sample rate...
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
DeviceAPI * m_deviceAPI
void addAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Adds a sink to receive full baseband and that is not a channel (e.g. spectrum)
Definition: deviceapi.cpp:89
uint32_t m_firRate
Rate of FIR filter (Rx: out, Tx: in) - this is the host/device communication sample rate...
uint32_t m_hb2Rate
Rate of the HB2 filter (Rx: out, Tx: in) - this is the HB1 working sample rate.
uint32_t m_hb1Rate
Rate of the HB1 filter (Rx: out, Tx: in) - this is the FIR working sample rate.
uint32_t m_bbRateHz
Baseband PLL rate (Hz) - used internally.
void networkManagerFinished(QNetworkReply *reply)
uint32_t m_addaConnvRate
A/D or D/A converter rat - this is the HB3 working sample rate.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~PlutoSDRInput()

PlutoSDRInput::~PlutoSDRInput ( )

Definition at line 70 of file plutosdrinput.cpp.

References closeDevice(), m_deviceAPI, m_fileSink, m_networkManager, networkManagerFinished(), DeviceAPI::removeAncillarySink(), resumeBuddies(), and suspendBuddies().

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

71 {
72  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
73  delete m_networkManager;
75  delete m_fileSink;
77  closeDevice();
78  resumeBuddies();
79 }
FileRecord * m_fileSink
QNetworkAccessManager * m_networkManager
DeviceAPI * m_deviceAPI
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
void networkManagerFinished(QNetworkReply *reply)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

bool PlutoSDRInput::applySettings ( const PlutoSDRInputSettings settings,
bool  force = false 
)
private

Definition at line 359 of file plutosdrinput.cpp.

References arg(), DeviceSampleSource::calculateDeviceCenterFrequency(), DeviceAPI::configureCorrections(), DevicePlutoSDRShared::MsgCrossReportToBuddy::create(), DevicePlutoSDRBox::DEVICE_PHY, DevicePlutoSDRParams::getBox(), DeviceAPI::getDeviceEngineInputMessageQueue(), DevicePlutoSDRBox::getRxSampleRates(), DeviceAPI::getSinkBuddies(), FileRecord::handleMessage(), PlutoSDRInputThread::isRunning(), DevicePlutoSDRBox::SampleRates::m_addaConnvRate, PlutoSDRInputSettings::m_antennaPath, DevicePlutoSDRBox::SampleRates::m_bbRateHz, PlutoSDRInputSettings::m_centerFrequency, PlutoSDRInputSettings::m_dcBlock, m_deviceAPI, DevicePlutoSDRShared::m_deviceParams, m_deviceSampleRates, m_deviceShared, PlutoSDRInputSettings::m_devSampleRate, PlutoSDRInputSettings::m_fcPos, PlutoSDRInputSettings::m_fileRecordName, m_fileSink, DevicePlutoSDRBox::SampleRates::m_firRate, PlutoSDRInputSettings::m_gain, PlutoSDRInputSettings::m_gainMode, DevicePlutoSDRBox::SampleRates::m_hb1Rate, DevicePlutoSDRBox::SampleRates::m_hb2Rate, DevicePlutoSDRBox::SampleRates::m_hb3Rate, PlutoSDRInputSettings::m_hwBBDCBlock, PlutoSDRInputSettings::m_hwIQCorrection, PlutoSDRInputSettings::m_hwRFDCBlock, PlutoSDRInputSettings::m_iqCorrection, PlutoSDRInputSettings::m_log2Decim, PlutoSDRInputSettings::m_LOppmTenths, PlutoSDRInputSettings::m_lpfBW, PlutoSDRInputSettings::m_lpfFIRBW, PlutoSDRInputSettings::m_lpfFIREnable, PlutoSDRInputSettings::m_lpfFIRGain, PlutoSDRInputSettings::m_lpfFIRlog2Decim, m_plutoSDRInputThread, PlutoSDRInputSettings::m_reverseAPIAddress, PlutoSDRInputSettings::m_reverseAPIDeviceIndex, PlutoSDRInputSettings::m_reverseAPIPort, m_settings, DevicePlutoSDRShared::m_thread, DevicePlutoSDRShared::m_threadWasRunning, PlutoSDRInputSettings::m_transverterDeltaFrequency, PlutoSDRInputSettings::m_transverterMode, PlutoSDRInputSettings::m_useReverseAPI, MessageQueue::push(), DevicePlutoSDRBox::set_params(), PlutoSDRInputThread::setFcPos(), DevicePlutoSDRBox::setFIR(), DevicePlutoSDRBox::setFIREnable(), PlutoSDRInputThread::setLog2Decimation(), DevicePlutoSDRBox::setLOPPMTenths(), DevicePlutoSDRBox::setSampleRate(), PlutoSDRInputThread::startWork(), DevicePlutoSDRShared::ThreadInterface::startWork(), PlutoSDRInputThread::stopWork(), DevicePlutoSDRShared::ThreadInterface::stopWork(), PlutoSDRInputSettings::translateGainMode(), PlutoSDRInputSettings::translateRFPath(), DevicePlutoSDRBox::USE_RX, and webapiReverseSendSettings().

Referenced by handleMessage(), init(), and start().

360 {
361  bool forwardChangeOwnDSP = false;
362  bool forwardChangeOtherDSP = false;
363  bool ownThreadWasRunning = false;
364  bool suspendAllOtherThreads = false; // All others means Tx in fact
366  QLocale loc;
367  QList<QString> reverseAPIKeys;
368 
369  qDebug().noquote() << "PlutoSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
370  << " m_devSampleRate: " << loc.toString(m_settings.m_devSampleRate) << "S/s"
371  << " m_LOppmTenths: " << m_settings.m_LOppmTenths
372  << " m_dcBlock: " << m_settings.m_dcBlock
373  << " m_iqCorrection: " << m_settings.m_iqCorrection
374  << " m_hwBBDCBlock: " << m_settings.m_hwBBDCBlock
375  << " m_hwRFDCBlock: " << m_settings.m_hwRFDCBlock
376  << " m_hwIQCorrection: " << m_settings.m_hwIQCorrection
377  << " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
378  << " m_lpfFIRBW: " << loc.toString(m_settings.m_lpfFIRBW)
379  << " m_lpfFIRlog2Decim: " << m_settings.m_lpfFIRlog2Decim
380  << " m_lpfFIRGain: " << m_settings.m_lpfFIRGain
381  << " m_log2Decim: " << loc.toString(1<<m_settings.m_log2Decim)
382  << " m_fcPos: " << m_settings.m_fcPos
383  << " m_lpfBW: " << loc.toString(m_settings.m_lpfBW)
384  << " m_gain: " << m_settings.m_gain
385  << " m_antennaPath: " << (int) m_settings.m_antennaPath
386  << " m_gainMode: " << (int) m_settings.m_gainMode
387  << " m_transverterMode: " << m_settings.m_transverterMode
388  << " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
389  << " force: " << force;
390 
391  if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
392  reverseAPIKeys.append("centerFrequency");
393  }
394  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) {
395  reverseAPIKeys.append("devSampleRate");
396  }
397  if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
398  reverseAPIKeys.append("LOppmTenths");
399  }
400  if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) {
401  reverseAPIKeys.append("dcBlock");
402  }
403  if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
404  reverseAPIKeys.append("iqCorrection");
405  }
406  if ((m_settings.m_hwBBDCBlock != settings.m_hwBBDCBlock) || force) {
407  reverseAPIKeys.append("hwBBDCBlock");
408  }
409  if ((m_settings.m_hwRFDCBlock != settings.m_hwRFDCBlock) || force) {
410  reverseAPIKeys.append("hwRFDCBlock");
411  }
412  if ((m_settings.m_hwIQCorrection != settings.m_hwIQCorrection) || force) {
413  reverseAPIKeys.append("hwIQCorrection");
414  }
415  if ((m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force) {
416  reverseAPIKeys.append("lpfFIREnable");
417  }
418  if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) || force) {
419  reverseAPIKeys.append("lpfFIRBW");
420  }
421  if ((m_settings.m_lpfFIRlog2Decim != settings.m_lpfFIRlog2Decim) || force) {
422  reverseAPIKeys.append("lpfFIRlog2Decim");
423  }
424  if ((m_settings.m_lpfFIRGain != settings.m_lpfFIRGain) || force) {
425  reverseAPIKeys.append("lpfFIRGain");
426  }
427  if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) {
428  reverseAPIKeys.append("log2Decim");
429  }
430  if ((m_settings.m_fcPos != settings.m_fcPos) || force) {
431  reverseAPIKeys.append("fcPos");
432  }
433  if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) {
434  reverseAPIKeys.append("lpfBW");
435  }
436  if ((m_settings.m_gain != settings.m_gain) || force) {
437  reverseAPIKeys.append("gain");
438  }
439  if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) {
440  reverseAPIKeys.append("antennaPath");
441  }
442  if ((m_settings.m_gainMode != settings.m_gainMode) || force) {
443  reverseAPIKeys.append("gainMode");
444  }
445  if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) {
446  reverseAPIKeys.append("transverterMode");
447  }
449  reverseAPIKeys.append("transverterDeltaFrequency");
450  }
451  if ((m_settings.m_fileRecordName != settings.m_fileRecordName) || force) {
452  reverseAPIKeys.append("fileRecordName");
453  }
454 
455  // determine if buddies threads or own thread need to be suspended
456 
457  // changes affecting all buddies can occur if
458  // - device to host sample rate is changed
459  // - FIR filter is enabled or disabled
460  // - FIR filter is changed
461  // - LO correction is changed
462  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
463  (m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) ||
465  (settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) ||
466  (settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) ||
467  (m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
468  {
469  suspendAllOtherThreads = true;
470  }
471 
472  if (suspendAllOtherThreads)
473  {
474  const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
475  std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
476 
477  for (; itSink != sinkBuddies.end(); ++itSink)
478  {
479  DevicePlutoSDRShared *buddySharedPtr = (DevicePlutoSDRShared *) (*itSink)->getBuddySharedPtr();
480 
481  if (buddySharedPtr->m_thread) {
482  buddySharedPtr->m_thread->stopWork();
483  buddySharedPtr->m_threadWasRunning = true;
484  }
485  else
486  {
487  buddySharedPtr->m_threadWasRunning = false;
488  }
489  }
490  }
491 
493  {
495  ownThreadWasRunning = true;
496  }
497 
498  // apply settings
499 
500  if ((m_settings.m_dcBlock != settings.m_dcBlock) ||
501  (m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
502  {
504  }
505 
506  // Change affecting device sample rate chain and other buddies
507  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
508  (m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) ||
510  (settings.m_lpfFIRBW != m_settings.m_lpfFIRBW) ||
511  (settings.m_lpfFIRGain != m_settings.m_lpfFIRGain) || force)
512  {
513  plutoBox->setFIR(settings.m_devSampleRate, settings.m_lpfFIRlog2Decim, DevicePlutoSDRBox::USE_RX, settings.m_lpfFIRBW, settings.m_lpfFIRGain);
514  plutoBox->setFIREnable(settings.m_lpfFIREnable); // eventually enable/disable FIR
515  plutoBox->setSampleRate(settings.m_devSampleRate); // and set end point sample rate
516 
517  plutoBox->getRxSampleRates(m_deviceSampleRates); // pick up possible new rates
518  qDebug() << "PlutoSDRInput::applySettings: BBPLL(Hz): " << m_deviceSampleRates.m_bbRateHz
519  << " ADC: " << m_deviceSampleRates.m_addaConnvRate
520  << " -HB3-> " << m_deviceSampleRates.m_hb3Rate
521  << " -HB2-> " << m_deviceSampleRates.m_hb2Rate
522  << " -HB1-> " << m_deviceSampleRates.m_hb1Rate
523  << " -FIR-> " << m_deviceSampleRates.m_firRate;
524 
525  forwardChangeOtherDSP = true;
526  forwardChangeOwnDSP = (m_settings.m_devSampleRate != settings.m_devSampleRate) || force;
527  }
528 
529  if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
530  {
531  if (m_plutoSDRInputThread != 0)
532  {
534  qDebug() << "PlutoSDRInput::applySettings: set soft decimation to " << (1<<settings.m_log2Decim);
535  }
536 
537  forwardChangeOwnDSP = true;
538  }
539 
540  if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
541  {
542  plutoBox->setLOPPMTenths(settings.m_LOppmTenths);
543  forwardChangeOtherDSP = true;
544  }
545 
546  std::vector<std::string> params;
547  bool paramsToSet = false;
548 
550  || (m_settings.m_fcPos != settings.m_fcPos)
551  || (m_settings.m_log2Decim != settings.m_log2Decim)
555  {
556  qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
557  settings.m_centerFrequency,
559  settings.m_log2Decim,
561  settings.m_devSampleRate,
562  DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
563  settings.m_transverterMode);
564 
565  params.push_back(QString(tr("out_altvoltage0_RX_LO_frequency=%1").arg(deviceCenterFrequency)).toStdString());
566  paramsToSet = true;
567  forwardChangeOwnDSP = true;
568 
569  if ((m_settings.m_fcPos != settings.m_fcPos) || force)
570  {
571  if (m_plutoSDRInputThread != 0)
572  {
574  qDebug() << "PlutoSDRInput::applySettings: set fcPos to " << settings.m_fcPos;
575  }
576  }
577  }
578 
579  if ((m_settings.m_lpfBW != settings.m_lpfBW) || force)
580  {
581  params.push_back(QString(tr("in_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString());
582  paramsToSet = true;
583  }
584 
585  if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
586  {
587  QString rfPortStr;
589  params.push_back(QString(tr("in_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString());
590  paramsToSet = true;
591  }
592 
593  if ((m_settings.m_gainMode != settings.m_gainMode) || force)
594  {
595  QString gainModeStr;
597  params.push_back(QString(tr("in_voltage0_gain_control_mode=%1").arg(gainModeStr)).toStdString());
598  paramsToSet = true;
599  }
600 
601  if ((m_settings.m_gain != settings.m_gain) || force)
602  {
603  params.push_back(QString(tr("in_voltage0_hardwaregain=%1").arg(settings.m_gain)).toStdString());
604  paramsToSet = true;
605  }
606 
607  if ((m_settings.m_hwBBDCBlock != settings.m_hwBBDCBlock) || force)
608  {
609  params.push_back(QString(tr("in_voltage_bb_dc_offset_tracking_en=%1").arg(settings.m_hwBBDCBlock ? 1 : 0)).toStdString());
610  paramsToSet = true;
611  }
612 
613  if ((m_settings.m_hwRFDCBlock != settings.m_hwRFDCBlock) || force)
614  {
615  params.push_back(QString(tr("in_voltage_rf_dc_offset_tracking_en=%1").arg(settings.m_hwRFDCBlock ? 1 : 0)).toStdString());
616  paramsToSet = true;
617  }
618 
619  if ((m_settings.m_hwIQCorrection != settings.m_hwIQCorrection) || force)
620  {
621  params.push_back(QString(tr("in_voltage_quadrature_tracking_en=%1").arg(settings.m_hwIQCorrection ? 1 : 0)).toStdString());
622  paramsToSet = true;
623  }
624 
625  if (paramsToSet)
626  {
627  plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
628  }
629 
630  if (settings.m_useReverseAPI)
631  {
632  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
636  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
637  }
638 
639  m_settings = settings;
640 
641  if (suspendAllOtherThreads)
642  {
643  const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
644  std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
645 
646  for (; itSink != sinkBuddies.end(); ++itSink)
647  {
648  DevicePlutoSDRShared *buddySharedPtr = (DevicePlutoSDRShared *) (*itSink)->getBuddySharedPtr();
649 
650  if (buddySharedPtr->m_threadWasRunning) {
651  buddySharedPtr->m_thread->startWork();
652  }
653  }
654  }
655 
656  if (ownThreadWasRunning) {
658  }
659 
660  // TODO: forward changes to other (Tx) DSP
661  if (forwardChangeOtherDSP)
662  {
663 
664  qDebug("PlutoSDRInput::applySettings: forwardChangeOtherDSP");
665 
666  const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
667  std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
668 
669  for (; itSink != sinkBuddies.end(); ++itSink)
670  {
672  settings.m_devSampleRate,
673  settings.m_lpfFIREnable,
674  settings.m_lpfFIRlog2Decim,
675  settings.m_lpfFIRBW,
676  settings.m_LOppmTenths);
677 
678  if ((*itSink)->getSamplingDeviceGUIMessageQueue())
679  {
681  (*itSink)->getSamplingDeviceGUIMessageQueue()->push(msgToGUI);
682  }
683 
684  (*itSink)->getSamplingDeviceInputMessageQueue()->push(msg);
685  }
686  }
687 
688  if (forwardChangeOwnDSP)
689  {
690  qDebug("PlutoSDRInput::applySettings: forward change to self");
691 
692  int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
694  m_fileSink->handleMessage(*notif); // forward to file sink
696  }
697 
698  return true;
699 }
PlutoSDRInputThread * m_plutoSDRInputThread
void setSampleRate(uint32_t sampleRate)
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void setLog2Decimation(unsigned int log2_decim)
FileRecord * m_fileSink
bool m_threadWasRunning
flag to know if thread needs to be resumed after suspend
bool m_lpfFIREnable
enable digital lowpass FIR filter
quint32 m_lpfFIRlog2Decim
digital lowpass FIR filter log2 of decimation factor (0..2)
const std::vector< DeviceAPI * > & getSinkBuddies() const
Definition: deviceapi.h:166
DevicePlutoSDRBox::SampleRates m_deviceSampleRates
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
static void translateRFPath(RFPath path, QString &s)
ThreadInterface * m_thread
holds the thread address if started else 0
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
bool m_hwRFDCBlock
Hardware RF DC blocking.
uint32_t m_hb3Rate
Rate of the HB3/(DEC3 or INT3) filter (Rx: out, Tx: in) - this is the HB2 working sample rate...
static MsgCrossReportToBuddy * create(uint64_t devSampleRate, bool lpfFIREnable, uint32_t lpfFIRlog2Interp, uint32_t lpfFIRBW, int32_t loPPMTenths)
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const PlutoSDRInputSettings &settings, bool force)
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
Definition: filerecord.cpp:128
PlutoSDRInputSettings m_settings
DeviceAPI * m_deviceAPI
void setFIREnable(bool enable)
bool m_hwIQCorrection
Hardware IQ correction.
void setLOPPMTenths(int ppmTenths)
bool getRxSampleRates(SampleRates &sampleRates)
void setFIR(uint32_t sampleRate, uint32_t intdec, DeviceUse use, uint32_t bw, int gain)
quint64 m_devSampleRate
Host interface sample rate.
quint32 m_lpfBW
analog lowpass filter bandwidth (Hz)
virtual bool isRunning()
quint32 m_gain
"hardware" gain
static void translateGainMode(GainMode mod, QString &s)
uint32_t m_firRate
Rate of FIR filter (Rx: out, Tx: in) - this is the host/device communication sample rate...
DevicePlutoSDRBox * getBox()
uint32_t m_hb2Rate
Rate of the HB2 filter (Rx: out, Tx: in) - this is the HB1 working sample rate.
qint32 m_LOppmTenths
XO correction.
DevicePlutoSDRShared m_deviceShared
uint32_t m_hb1Rate
Rate of the HB1 filter (Rx: out, Tx: in) - this is the FIR working sample rate.
bool m_hwBBDCBlock
Hardware baseband DC blocking.
uint32_t m_bbRateHz
Baseband PLL rate (Hz) - used internally.
quint32 m_lpfFIRBW
digital lowpass FIR filter bandwidth (Hz)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
uint32_t m_addaConnvRate
A/D or D/A converter rat - this is the HB3 working sample rate.
void set_params(DeviceType devType, const std::vector< std::string > &params)
int m_lpfFIRGain
digital lowpass FIR filter gain (dB)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeDevice()

void PlutoSDRInput::closeDevice ( )
private

Definition at line 315 of file plutosdrinput.cpp.

References DevicePlutoSDRParams::close(), DevicePlutoSDRParams::getBox(), DeviceAPI::getSinkBuddies(), m_deviceAPI, DevicePlutoSDRShared::m_deviceParams, and m_deviceShared.

Referenced by ~PlutoSDRInput().

316 {
317  if (m_deviceShared.m_deviceParams->getBox() == 0) { // was never open
318  return;
319  }
320 
321  if (m_deviceAPI->getSinkBuddies().size() == 0)
322  {
326  }
327 }
const std::vector< DeviceAPI * > & getSinkBuddies() const
Definition: deviceapi.h:166
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
DeviceAPI * m_deviceAPI
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

bool PlutoSDRInput::deserialize ( const QByteArray &  data)
virtual

Implements DeviceSampleSource.

Definition at line 133 of file plutosdrinput.cpp.

References PlutoSDRInput::MsgConfigurePlutoSDR::create(), PlutoSDRInputSettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and PlutoSDRInputSettings::resetToDefaults().

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

134 {
135  bool success = true;
136 
137  if (!m_settings.deserialize(data))
138  {
140  success = false;
141  }
142 
143  MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(m_settings, true);
144  m_inputMessageQueue.push(message);
145 
146  if (m_guiMessageQueue)
147  {
148  MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(m_settings, true);
149  m_guiMessageQueue->push(messageToGUI);
150  }
151 
152  return success;
153 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigurePlutoSDR * create(const PlutoSDRInputSettings &settings, bool force)
Definition: plutosdrinput.h:48
MessageQueue m_inputMessageQueue
Input queue to the source.
PlutoSDRInputSettings m_settings
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool deserialize(const QByteArray &data)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void PlutoSDRInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 81 of file plutosdrinput.cpp.

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

82 {
83  delete this;
84 }
+ Here is the caller graph for this function:

◆ fetchTemperature()

bool PlutoSDRInput::fetchTemperature ( )

Definition at line 739 of file plutosdrinput.cpp.

References DevicePlutoSDRBox::fetchTemp(), DevicePlutoSDRParams::getBox(), DevicePlutoSDRShared::m_deviceParams, and m_deviceShared.

Referenced by getFIRSampleRate(), and webapiFormatDeviceReport().

740 {
742  return plutoBox->fetchTemp();
743 }
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADCSampleRate()

uint32_t PlutoSDRInput::getADCSampleRate ( ) const
inline

Definition at line 145 of file plutosdrinput.h.

References DevicePlutoSDRBox::SampleRates::m_addaConnvRate, and m_deviceSampleRates.

Referenced by webapiFormatDeviceReport().

DevicePlutoSDRBox::SampleRates m_deviceSampleRates
uint32_t m_addaConnvRate
A/D or D/A converter rat - this is the HB3 working sample rate.
+ Here is the caller graph for this function:

◆ getbbLPRange()

void PlutoSDRInput::getbbLPRange ( quint32 &  minLimit,
quint32 &  maxLimit 
)

Definition at line 720 of file plutosdrinput.cpp.

References DevicePlutoSDRBox::getbbLPRxRange(), DevicePlutoSDRParams::getBox(), DevicePlutoSDRShared::m_deviceParams, m_deviceShared, leansdr::max(), and leansdr::min().

Referenced by getFIRSampleRate().

721 {
722  uint32_t min, max;
724 
725  plutoBox->getbbLPRxRange(min, max);
726  minLimit = min;
727  maxLimit = max;
728 }
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
void getbbLPRxRange(uint32_t &minLimit, uint32_t &maxLimit)
unsigned int uint32_t
Definition: rtptypes_win.h:46
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
T max(const T &x, const T &y)
Definition: framework.h:446
T min(const T &x, const T &y)
Definition: framework.h:440
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 PlutoSDRInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 164 of file plutosdrinput.cpp.

References PlutoSDRInputSettings::m_centerFrequency, and m_settings.

Referenced by setSampleRate().

165 {
167 }
PlutoSDRInputSettings m_settings
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & PlutoSDRInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 155 of file plutosdrinput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

156 {
157  return m_deviceDescription;
158 }
QString m_deviceDescription
+ Here is the caller graph for this function:

◆ getFIRSampleRate()

uint32_t PlutoSDRInput::getFIRSampleRate ( ) const
inline

Definition at line 146 of file plutosdrinput.h.

References fetchTemperature(), getbbLPRange(), getGain(), getLORange(), getRSSI(), getTemperature(), m_deviceSampleRates, and DevicePlutoSDRBox::SampleRates::m_hb1Rate.

146 { return m_deviceSampleRates.m_hb1Rate; }
DevicePlutoSDRBox::SampleRates m_deviceSampleRates
uint32_t m_hb1Rate
Rate of the HB1 filter (Rx: out, Tx: in) - this is the FIR working sample rate.
+ Here is the call graph for this function:

◆ getGain()

void PlutoSDRInput::getGain ( int &  gainStr)

Definition at line 730 of file plutosdrinput.cpp.

References DevicePlutoSDRParams::getBox(), DevicePlutoSDRBox::getRxGain(), DevicePlutoSDRShared::m_deviceParams, and m_deviceShared.

Referenced by getFIRSampleRate(), and webapiFormatDeviceReport().

731 {
733 
734  if (!plutoBox->getRxGain(gaindB, 0)) {
735  gaindB = 0;
736  }
737 }
bool getRxGain(int &gaindB, unsigned int chan)
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLORange()

void PlutoSDRInput::getLORange ( qint64 &  minLimit,
qint64 &  maxLimit 
)

Definition at line 710 of file plutosdrinput.cpp.

References DevicePlutoSDRParams::getBox(), DevicePlutoSDRBox::getRxLORange(), DevicePlutoSDRShared::m_deviceParams, m_deviceShared, leansdr::max(), and leansdr::min().

Referenced by getFIRSampleRate().

711 {
712  uint64_t min, max;
714 
715  plutoBox->getRxLORange(min, max);
716  minLimit = min;
717  maxLimit = max;
718 }
void getRxLORange(uint64_t &minLimit, uint64_t &maxLimit)
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
T max(const T &x, const T &y)
Definition: framework.h:446
T min(const T &x, const T &y)
Definition: framework.h:440
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRSSI()

void PlutoSDRInput::getRSSI ( std::string &  rssiStr)

Definition at line 701 of file plutosdrinput.cpp.

References DevicePlutoSDRParams::getBox(), DevicePlutoSDRBox::getRxRSSI(), DevicePlutoSDRShared::m_deviceParams, and m_deviceShared.

Referenced by getFIRSampleRate(), and webapiFormatDeviceReport().

702 {
704 
705  if (!plutoBox->getRxRSSI(rssiStr, 0)) {
706  rssiStr = "xxx dB";
707  }
708 }
bool getRxRSSI(std::string &rssiStr, unsigned int chan)
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSampleRate()

int PlutoSDRInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 159 of file plutosdrinput.cpp.

References PlutoSDRInputSettings::m_devSampleRate, PlutoSDRInputSettings::m_log2Decim, and m_settings.

Referenced by setMessageQueueToGUI().

160 {
162 }
PlutoSDRInputSettings m_settings
quint64 m_devSampleRate
Host interface sample rate.
+ Here is the caller graph for this function:

◆ getTemperature()

float PlutoSDRInput::getTemperature ( )

Definition at line 745 of file plutosdrinput.cpp.

References DevicePlutoSDRParams::getBox(), DevicePlutoSDRBox::getTemp(), DevicePlutoSDRShared::m_deviceParams, and m_deviceShared.

Referenced by getFIRSampleRate(), and webapiFormatDeviceReport().

746 {
748  return plutoBox->getTemp();
749 }
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
float getTemp() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleMessage()

bool PlutoSDRInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 184 of file plutosdrinput.cpp.

References applySettings(), FileRecord::genUniqueFileName(), DeviceAPI::getDeviceUID(), DevicePlutoSDRShared::MsgCrossReportToBuddy::getDevSampleRate(), PlutoSDRInput::MsgConfigurePlutoSDR::getForce(), DevicePlutoSDRShared::MsgCrossReportToBuddy::getLoPPMTenths(), DevicePlutoSDRShared::MsgCrossReportToBuddy::getLpfFirbw(), DevicePlutoSDRShared::MsgCrossReportToBuddy::getLpfFiRlog2IntDec(), PlutoSDRInput::MsgConfigurePlutoSDR::getSettings(), PlutoSDRInput::MsgFileRecord::getStartStop(), PlutoSDRInput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), DevicePlutoSDRShared::MsgCrossReportToBuddy::isLpfFirEnable(), m_deviceAPI, PlutoSDRInputSettings::m_devSampleRate, PlutoSDRInputSettings::m_fileRecordName, m_fileSink, PlutoSDRInputSettings::m_LOppmTenths, PlutoSDRInputSettings::m_lpfFIRBW, PlutoSDRInputSettings::m_lpfFIREnable, PlutoSDRInputSettings::m_lpfFIRlog2Decim, m_settings, PlutoSDRInputSettings::m_useReverseAPI, Message::match(), FileRecord::setFileName(), DeviceAPI::startDeviceEngine(), FileRecord::startRecording(), DeviceAPI::stopDeviceEngine(), FileRecord::stopRecording(), and webapiReverseSendStartStop().

Referenced by setSampleRate().

185 {
186  if (MsgConfigurePlutoSDR::match(message))
187  {
188  MsgConfigurePlutoSDR& conf = (MsgConfigurePlutoSDR&) message;
189  qDebug() << "PlutoSDRInput::handleMessage: MsgConfigurePlutoSDR";
190 
191  if (!applySettings(conf.getSettings(), conf.getForce()))
192  {
193  qDebug("PlutoSDRInput::handleMessage config error");
194  }
195 
196  return true;
197  }
198  else if (MsgFileRecord::match(message))
199  {
200  MsgFileRecord& conf = (MsgFileRecord&) message;
201  qDebug() << "PlutoSDRInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
202 
203  if (conf.getStartStop())
204  {
205  if (m_settings.m_fileRecordName.size() != 0) {
207  } else {
209  }
210 
212  }
213  else
214  {
216  }
217 
218  return true;
219  }
220  else if (MsgStartStop::match(message))
221  {
222  MsgStartStop& cmd = (MsgStartStop&) message;
223  qDebug() << "PlutoSDRInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
224 
225  if (cmd.getStartStop())
226  {
228  {
230  }
231  }
232  else
233  {
235  }
236 
238  webapiReverseSendStartStop(cmd.getStartStop());
239  }
240 
241  return true;
242  }
243  else if (DevicePlutoSDRShared::MsgCrossReportToBuddy::match(message)) // message from buddy
244  {
250  PlutoSDRInputSettings newSettings = m_settings;
251  newSettings.m_lpfFIREnable = conf.isLpfFirEnable();
252  applySettings(newSettings);
253 
254  return true;
255  }
256  else
257  {
258  return false;
259  }
260 }
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
FileRecord * m_fileSink
void setFileName(const QString &filename)
Definition: filerecord.cpp:59
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
bool m_lpfFIREnable
enable digital lowpass FIR filter
quint32 m_lpfFIRlog2Decim
digital lowpass FIR filter log2 of decimation factor (0..2)
void startRecording()
Definition: filerecord.cpp:105
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
bool applySettings(const PlutoSDRInputSettings &settings, bool force=false)
PlutoSDRInputSettings m_settings
DeviceAPI * m_deviceAPI
void genUniqueFileName(uint deviceUID, int istream=-1)
Definition: filerecord.cpp:67
quint64 m_devSampleRate
Host interface sample rate.
void stopRecording()
Definition: filerecord.cpp:117
static bool match(const Message *message)
Definition: message.cpp:45
void webapiReverseSendStartStop(bool start)
qint32 m_LOppmTenths
XO correction.
quint32 m_lpfFIRBW
digital lowpass FIR filter bandwidth (Hz)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void PlutoSDRInput::init ( )
virtual

initializations to be done when all collaborating objects are created and possibly connected

Implements DeviceSampleSource.

Definition at line 86 of file plutosdrinput.cpp.

References applySettings(), and m_settings.

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

87 {
89 }
bool applySettings(const PlutoSDRInputSettings &settings, bool force=false)
PlutoSDRInputSettings m_settings
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void PlutoSDRInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 1080 of file plutosdrinput.cpp.

Referenced by ~PlutoSDRInput().

1081 {
1082  QNetworkReply::NetworkError replyError = reply->error();
1083 
1084  if (replyError)
1085  {
1086  qWarning() << "PlutoSDRInput::networkManagerFinished:"
1087  << " error(" << (int) replyError
1088  << "): " << replyError
1089  << ": " << reply->errorString();
1090  return;
1091  }
1092 
1093  QString answer = reply->readAll();
1094  answer.chop(1); // remove last \n
1095  qDebug("PlutoSDRInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
1096 }
+ Here is the caller graph for this function:

◆ openDevice()

bool PlutoSDRInput::openDevice ( )
private

Definition at line 262 of file plutosdrinput.cpp.

References DevicePlutoSDRBox::createRxBuffer(), DevicePlutoSDRParams::getBox(), DeviceAPI::getBuddySharedPtr(), DeviceAPI::getSamplingDeviceSerial(), DeviceAPI::getSinkBuddies(), m_deviceAPI, DevicePlutoSDRShared::m_deviceParams, m_deviceShared, m_plutoRxBuffer, DeviceSampleSource::m_sampleFifo, DevicePlutoSDRParams::open(), DevicePlutoSDRBox::openRx(), PLUTOSDR_BLOCKSIZE_SAMPLES, DeviceAPI::setBuddySharedPtr(), and SampleSinkFifo::setSize().

263 {
265  {
266  qCritical("PlutoSDRInput::openDevice: could not allocate SampleFifo");
267  return false;
268  }
269  else
270  {
271  qDebug("PlutoSDRInput::openDevice: allocated SampleFifo");
272  }
273 
274  // look for Tx buddy and get reference to common parameters
275  if (m_deviceAPI->getSinkBuddies().size() > 0) // then sink
276  {
277  qDebug("PlutoSDRInput::openDevice: look at Tx buddy");
278 
279  DeviceAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
280  DevicePlutoSDRShared* buddySharedPtr = (DevicePlutoSDRShared*) sinkBuddy->getBuddySharedPtr();
281  m_deviceShared.m_deviceParams = buddySharedPtr->m_deviceParams;
282 
284  {
285  qCritical("PlutoSDRInput::openDevice: cannot get device parameters from Tx buddy");
286  return false; // the device params should have been created by the buddy
287  }
288  else
289  {
290  qDebug("PlutoSDRInput::openDevice: getting device parameters from Tx buddy");
291  }
292  }
293  // There is no buddy then create the first PlutoSDR common parameters
294  // open the device this will also populate common fields
295  else
296  {
297  qDebug("PlutoSDRInput::openDevice: open device here");
298 
300  char serial[256];
301  strcpy(serial, qPrintable(m_deviceAPI->getSamplingDeviceSerial()));
303  }
304 
305  m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
306 
307  // acquire the channel
309  plutoBox->openRx();
311 
312  return true;
313 }
struct iio_buffer * m_plutoRxBuffer
const std::vector< DeviceAPI * > & getSinkBuddies() const
Definition: deviceapi.h:166
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
bool open(const std::string &serial)
SampleSinkFifo m_sampleFifo
bool setSize(int size)
#define PLUTOSDR_BLOCKSIZE_SAMPLES
DeviceAPI * m_deviceAPI
void * getBuddySharedPtr() const
Definition: deviceapi.h:161
struct iio_buffer * createRxBuffer(unsigned int size, bool cyclic)
void setBuddySharedPtr(void *ptr)
Definition: deviceapi.h:162
DevicePlutoSDRBox * getBox()
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:

◆ resumeBuddies()

void PlutoSDRInput::resumeBuddies ( )
private

Definition at line 344 of file plutosdrinput.cpp.

References DeviceAPI::getBuddySharedPtr(), DeviceAPI::getSinkBuddies(), i, m_deviceAPI, DevicePlutoSDRShared::m_thread, and DevicePlutoSDRShared::ThreadInterface::startWork().

Referenced by ~PlutoSDRInput().

345 {
346  // resume Tx buddy's thread
347 
348  for (unsigned int i = 0; i < m_deviceAPI->getSinkBuddies().size(); i++)
349  {
350  DeviceAPI *buddy = m_deviceAPI->getSinkBuddies()[i];
351  DevicePlutoSDRShared *buddyShared = (DevicePlutoSDRShared *) buddy->getBuddySharedPtr();
352 
353  if (buddyShared->m_thread) {
354  buddyShared->m_thread->startWork();
355  }
356  }
357 }
const std::vector< DeviceAPI * > & getSinkBuddies() const
Definition: deviceapi.h:166
ThreadInterface * m_thread
holds the thread address if started else 0
DeviceAPI * m_deviceAPI
void * getBuddySharedPtr() const
Definition: deviceapi.h:161
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray PlutoSDRInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 128 of file plutosdrinput.cpp.

References m_settings, and PlutoSDRInputSettings::serialize().

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

129 {
130  return m_settings.serialize();
131 }
QByteArray serialize() const
PlutoSDRInputSettings m_settings
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void PlutoSDRInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 169 of file plutosdrinput.cpp.

References PlutoSDRInput::MsgConfigurePlutoSDR::create(), PlutoSDRInputSettings::m_centerFrequency, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, and MessageQueue::push().

Referenced by setSampleRate().

170 {
172  settings.m_centerFrequency = centerFrequency;
173 
174  MsgConfigurePlutoSDR* message = MsgConfigurePlutoSDR::create(settings, false);
175  m_inputMessageQueue.push(message);
176 
177  if (m_guiMessageQueue)
178  {
179  MsgConfigurePlutoSDR* messageToGUI = MsgConfigurePlutoSDR::create(settings, false);
180  m_guiMessageQueue->push(messageToGUI);
181  }
182 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigurePlutoSDR * create(const PlutoSDRInputSettings &settings, bool force)
Definition: plutosdrinput.h:48
MessageQueue m_inputMessageQueue
Input queue to the source.
PlutoSDRInputSettings m_settings
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

virtual void PlutoSDRInput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSource.

Definition at line 113 of file plutosdrinput.h.

References getDeviceDescription(), getSampleRate(), and DeviceSampleSource::m_guiMessageQueue.

113 { m_guiMessageQueue = queue; }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ setSampleRate()

virtual void PlutoSDRInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 116 of file plutosdrinput.h.

References getCenterFrequency(), handleMessage(), setCenterFrequency(), webapiReportGet(), webapiRun(), webapiRunGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

116 { (void) sampleRate; }
+ Here is the call graph for this function:

◆ start()

bool PlutoSDRInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 91 of file plutosdrinput.cpp.

References applySettings(), DevicePlutoSDRParams::getBox(), DevicePlutoSDRShared::m_deviceParams, m_deviceShared, PlutoSDRInputSettings::m_log2Decim, m_plutoSDRInputThread, m_running, DeviceSampleSource::m_sampleFifo, m_settings, DevicePlutoSDRShared::m_thread, PLUTOSDR_BLOCKSIZE_SAMPLES, PlutoSDRInputThread::setLog2Decimation(), PlutoSDRInputThread::startWork(), and stop().

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop().

92 {
94  return false;
95  }
96 
97  if (m_running) stop();
98 
99  // start / stop streaming is done in the thread.
100 
102  qDebug("PlutoSDRInput::start: thread created");
103 
104  applySettings(m_settings, true);
105 
108 
110  m_running = true;
111 
112  return true;
113 }
PlutoSDRInputThread * m_plutoSDRInputThread
void setLog2Decimation(unsigned int log2_decim)
ThreadInterface * m_thread
holds the thread address if started else 0
DevicePlutoSDRParams * m_deviceParams
unique hardware device parameters
bool applySettings(const PlutoSDRInputSettings &settings, bool force=false)
SampleSinkFifo m_sampleFifo
#define PLUTOSDR_BLOCKSIZE_SAMPLES
PlutoSDRInputSettings m_settings
virtual void stop()
DevicePlutoSDRBox * getBox()
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void PlutoSDRInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 115 of file plutosdrinput.cpp.

References m_deviceShared, m_plutoSDRInputThread, m_running, DevicePlutoSDRShared::m_thread, and PlutoSDRInputThread::stopWork().

Referenced by PlutoSDRInput::MsgStartStop::MsgStartStop(), and start().

116 {
117  if (m_plutoSDRInputThread != 0)
118  {
120  delete m_plutoSDRInputThread;
122  }
123 
125  m_running = false;
126 }
PlutoSDRInputThread * m_plutoSDRInputThread
ThreadInterface * m_thread
holds the thread address if started else 0
DevicePlutoSDRShared m_deviceShared
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ suspendBuddies()

void PlutoSDRInput::suspendBuddies ( )
private

Definition at line 329 of file plutosdrinput.cpp.

References DeviceAPI::getBuddySharedPtr(), DeviceAPI::getSinkBuddies(), i, m_deviceAPI, DevicePlutoSDRShared::m_thread, and DevicePlutoSDRShared::ThreadInterface::stopWork().

Referenced by ~PlutoSDRInput().

330 {
331  // suspend Tx buddy's thread
332 
333  for (unsigned int i = 0; i < m_deviceAPI->getSinkBuddies().size(); i++)
334  {
335  DeviceAPI *buddy = m_deviceAPI->getSinkBuddies()[i];
336  DevicePlutoSDRShared *buddyShared = (DevicePlutoSDRShared *) buddy->getBuddySharedPtr();
337 
338  if (buddyShared->m_thread) {
339  buddyShared->m_thread->stopWork();
340  }
341  }
342 }
const std::vector< DeviceAPI * > & getSinkBuddies() const
Definition: deviceapi.h:166
ThreadInterface * m_thread
holds the thread address if started else 0
DeviceAPI * m_deviceAPI
void * getBuddySharedPtr() const
Definition: deviceapi.h:161
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

void PlutoSDRInput::webapiFormatDeviceReport ( SWGSDRangel::SWGDeviceReport response)
private

Definition at line 946 of file plutosdrinput.cpp.

References fetchTemperature(), getADCSampleRate(), getGain(), SWGSDRangel::SWGDeviceReport::getPlutoSdrInputReport(), getRSSI(), getTemperature(), SWGSDRangel::SWGPlutoSdrInputReport::setAdcRate(), SWGSDRangel::SWGPlutoSdrInputReport::setGainDb(), SWGSDRangel::SWGPlutoSdrInputReport::setRssi(), and SWGSDRangel::SWGPlutoSdrInputReport::setTemperature().

Referenced by webapiReportGet().

947 {
949  std::string rssiStr;
950  getRSSI(rssiStr);
951  response.getPlutoSdrInputReport()->setRssi(new QString(rssiStr.c_str()));
952  int gainDB;
953  getGain(gainDB);
954  response.getPlutoSdrInputReport()->setGainDb(gainDB);
957 }
bool fetchTemperature()
float getTemperature()
void getRSSI(std::string &rssiStr)
SWGPlutoSdrInputReport * getPlutoSdrInputReport()
void getGain(int &gainStr)
uint32_t getADCSampleRate() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void PlutoSDRInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const PlutoSDRInputSettings settings 
)
private

Definition at line 905 of file plutosdrinput.cpp.

References SWGSDRangel::SWGPlutoSdrInputSettings::getFileRecordName(), SWGSDRangel::SWGDeviceSettings::getPlutoSdrInputSettings(), SWGSDRangel::SWGPlutoSdrInputSettings::getReverseApiAddress(), PlutoSDRInputSettings::m_antennaPath, PlutoSDRInputSettings::m_centerFrequency, PlutoSDRInputSettings::m_dcBlock, PlutoSDRInputSettings::m_devSampleRate, PlutoSDRInputSettings::m_fcPos, PlutoSDRInputSettings::m_fileRecordName, PlutoSDRInputSettings::m_gain, PlutoSDRInputSettings::m_gainMode, PlutoSDRInputSettings::m_hwBBDCBlock, PlutoSDRInputSettings::m_hwIQCorrection, PlutoSDRInputSettings::m_hwRFDCBlock, PlutoSDRInputSettings::m_iqCorrection, PlutoSDRInputSettings::m_log2Decim, PlutoSDRInputSettings::m_LOppmTenths, PlutoSDRInputSettings::m_lpfBW, PlutoSDRInputSettings::m_lpfFIRBW, PlutoSDRInputSettings::m_lpfFIREnable, PlutoSDRInputSettings::m_lpfFIRGain, PlutoSDRInputSettings::m_lpfFIRlog2Decim, PlutoSDRInputSettings::m_reverseAPIAddress, PlutoSDRInputSettings::m_reverseAPIDeviceIndex, PlutoSDRInputSettings::m_reverseAPIPort, m_settings, PlutoSDRInputSettings::m_transverterDeltaFrequency, PlutoSDRInputSettings::m_transverterMode, PlutoSDRInputSettings::m_useReverseAPI, SWGSDRangel::SWGPlutoSdrInputSettings::setAntennaPath(), SWGSDRangel::SWGPlutoSdrInputSettings::setCenterFrequency(), SWGSDRangel::SWGPlutoSdrInputSettings::setDcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::setDevSampleRate(), SWGSDRangel::SWGPlutoSdrInputSettings::setFcPos(), SWGSDRangel::SWGPlutoSdrInputSettings::setFileRecordName(), SWGSDRangel::SWGPlutoSdrInputSettings::setGain(), SWGSDRangel::SWGPlutoSdrInputSettings::setGainMode(), SWGSDRangel::SWGPlutoSdrInputSettings::setHwBbdcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::setHwIqCorrection(), SWGSDRangel::SWGPlutoSdrInputSettings::setHwRfdcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::setIqCorrection(), SWGSDRangel::SWGPlutoSdrInputSettings::setLog2Decim(), SWGSDRangel::SWGPlutoSdrInputSettings::setLOppmTenths(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfBw(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFirbw(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFirEnable(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFirGain(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFiRlog2Decim(), SWGSDRangel::SWGPlutoSdrInputSettings::setReverseApiAddress(), SWGSDRangel::SWGPlutoSdrInputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGPlutoSdrInputSettings::setReverseApiPort(), SWGSDRangel::SWGPlutoSdrInputSettings::setTransverterDeltaFrequency(), SWGSDRangel::SWGPlutoSdrInputSettings::setTransverterMode(), and SWGSDRangel::SWGPlutoSdrInputSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

906 {
910  response.getPlutoSdrInputSettings()->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0);
911  response.getPlutoSdrInputSettings()->setLpfFirbw(settings.m_lpfFIRBW);
914  response.getPlutoSdrInputSettings()->setFcPos((int) settings.m_fcPos);
915  response.getPlutoSdrInputSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
916  response.getPlutoSdrInputSettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
917  response.getPlutoSdrInputSettings()->setHwBbdcBlock(settings.m_hwBBDCBlock ? 1 : 0);
918  response.getPlutoSdrInputSettings()->setHwRfdcBlock(settings.m_hwRFDCBlock ? 1 : 0);
919  response.getPlutoSdrInputSettings()->setHwIqCorrection(settings.m_hwIQCorrection ? 1 : 0);
920  response.getPlutoSdrInputSettings()->setLog2Decim(settings.m_log2Decim);
921  response.getPlutoSdrInputSettings()->setLpfBw(settings.m_lpfBW);
922  response.getPlutoSdrInputSettings()->setGain(settings.m_gain);
924  response.getPlutoSdrInputSettings()->setGainMode((int) settings.m_gainMode);
926  response.getPlutoSdrInputSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
927 
928  if (response.getPlutoSdrInputSettings()->getFileRecordName()) {
930  } else {
931  response.getPlutoSdrInputSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
932  }
933 
934  response.getPlutoSdrInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
935 
938  } else {
939  response.getPlutoSdrInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
940  }
941 
944 }
bool m_lpfFIREnable
enable digital lowpass FIR filter
quint32 m_lpfFIRlog2Decim
digital lowpass FIR filter log2 of decimation factor (0..2)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiAddress(QString *reverse_api_address)
void setHwIqCorrection(qint32 hw_iq_correction)
bool m_hwRFDCBlock
Hardware RF DC blocking.
PlutoSDRInputSettings m_settings
void setLpfFiRlog2Decim(qint32 lpf_fi_rlog2_decim)
bool m_hwIQCorrection
Hardware IQ correction.
void setReverseApiPort(qint32 reverse_api_port)
quint64 m_devSampleRate
Host interface sample rate.
void setFileRecordName(QString *file_record_name)
quint32 m_lpfBW
analog lowpass filter bandwidth (Hz)
quint32 m_gain
"hardware" gain
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
qint32 m_LOppmTenths
XO correction.
void setCenterFrequency(qint64 center_frequency)
bool m_hwBBDCBlock
Hardware baseband DC blocking.
quint32 m_lpfFIRBW
digital lowpass FIR filter bandwidth (Hz)
SWGPlutoSdrInputSettings * getPlutoSdrInputSettings()
void setTransverterMode(qint32 transverter_mode)
int m_lpfFIRGain
digital lowpass FIR filter gain (dB)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

int PlutoSDRInput::webapiReportGet ( SWGSDRangel::SWGDeviceReport response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 894 of file plutosdrinput.cpp.

References SWGSDRangel::SWGDeviceReport::getPlutoSdrInputReport(), SWGSDRangel::SWGPlutoSdrInputReport::init(), SWGSDRangel::SWGDeviceReport::setPlutoSdrInputReport(), and webapiFormatDeviceReport().

Referenced by setSampleRate().

897 {
898  (void) errorMessage;
900  response.getPlutoSdrInputReport()->init();
901  webapiFormatDeviceReport(response);
902  return 200;
903 }
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
SWGPlutoSdrInputReport * getPlutoSdrInputReport()
void setPlutoSdrInputReport(SWGPlutoSdrInputReport *pluto_sdr_input_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

void PlutoSDRInput::webapiReverseSendSettings ( QList< QString > &  deviceSettingsKeys,
const PlutoSDRInputSettings settings,
bool  force 
)
private

Definition at line 959 of file plutosdrinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getPlutoSdrInputSettings(), PlutoSDRInputSettings::m_antennaPath, PlutoSDRInputSettings::m_centerFrequency, PlutoSDRInputSettings::m_dcBlock, m_deviceAPI, PlutoSDRInputSettings::m_devSampleRate, PlutoSDRInputSettings::m_fcPos, PlutoSDRInputSettings::m_fileRecordName, PlutoSDRInputSettings::m_gain, PlutoSDRInputSettings::m_gainMode, PlutoSDRInputSettings::m_hwBBDCBlock, PlutoSDRInputSettings::m_hwIQCorrection, PlutoSDRInputSettings::m_hwRFDCBlock, PlutoSDRInputSettings::m_iqCorrection, PlutoSDRInputSettings::m_log2Decim, PlutoSDRInputSettings::m_LOppmTenths, PlutoSDRInputSettings::m_lpfBW, PlutoSDRInputSettings::m_lpfFIRBW, PlutoSDRInputSettings::m_lpfFIREnable, PlutoSDRInputSettings::m_lpfFIRGain, PlutoSDRInputSettings::m_lpfFIRlog2Decim, m_networkManager, m_networkRequest, PlutoSDRInputSettings::m_reverseAPIAddress, PlutoSDRInputSettings::m_reverseAPIDeviceIndex, PlutoSDRInputSettings::m_reverseAPIPort, PlutoSDRInputSettings::m_transverterDeltaFrequency, PlutoSDRInputSettings::m_transverterMode, SWGSDRangel::SWGPlutoSdrInputSettings::setAntennaPath(), SWGSDRangel::SWGPlutoSdrInputSettings::setCenterFrequency(), SWGSDRangel::SWGPlutoSdrInputSettings::setDcBlock(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGPlutoSdrInputSettings::setDevSampleRate(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGPlutoSdrInputSettings::setFcPos(), SWGSDRangel::SWGPlutoSdrInputSettings::setFileRecordName(), SWGSDRangel::SWGPlutoSdrInputSettings::setGain(), SWGSDRangel::SWGPlutoSdrInputSettings::setGainMode(), SWGSDRangel::SWGPlutoSdrInputSettings::setHwBbdcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::setHwIqCorrection(), SWGSDRangel::SWGPlutoSdrInputSettings::setHwRfdcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::setIqCorrection(), SWGSDRangel::SWGPlutoSdrInputSettings::setLog2Decim(), SWGSDRangel::SWGPlutoSdrInputSettings::setLOppmTenths(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfBw(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFirbw(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFirEnable(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFirGain(), SWGSDRangel::SWGPlutoSdrInputSettings::setLpfFiRlog2Decim(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), SWGSDRangel::SWGDeviceSettings::setPlutoSdrInputSettings(), SWGSDRangel::SWGPlutoSdrInputSettings::setTransverterDeltaFrequency(), and SWGSDRangel::SWGPlutoSdrInputSettings::setTransverterMode().

Referenced by applySettings().

960 {
962  swgDeviceSettings->setDirection(0); // single Rx
963  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
964  swgDeviceSettings->setDeviceHwType(new QString("PlutoSDR"));
966  SWGSDRangel::SWGPlutoSdrInputSettings *swgPlutoSdrInputSettings = swgDeviceSettings->getPlutoSdrInputSettings();
967 
968  // transfer data that has been modified. When force is on transfer all data except reverse API data
969 
970  if (deviceSettingsKeys.contains("centerFrequency") || force) {
971  swgPlutoSdrInputSettings->setCenterFrequency(settings.m_centerFrequency);
972  }
973  if (deviceSettingsKeys.contains("devSampleRate") || force) {
974  swgPlutoSdrInputSettings->setDevSampleRate(settings.m_devSampleRate);
975  }
976  if (deviceSettingsKeys.contains("LOppmTenths") || force) {
977  swgPlutoSdrInputSettings->setLOppmTenths(settings.m_LOppmTenths);
978  }
979  if (deviceSettingsKeys.contains("lpfFIREnable") || force) {
980  swgPlutoSdrInputSettings->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0);
981  }
982  if (deviceSettingsKeys.contains("lpfFIRBW") || force) {
983  swgPlutoSdrInputSettings->setLpfFirbw(settings.m_lpfFIRBW);
984  }
985  if (deviceSettingsKeys.contains("lpfFIRlog2Decim") || force) {
986  swgPlutoSdrInputSettings->setLpfFiRlog2Decim(settings.m_lpfFIRlog2Decim);
987  }
988  if (deviceSettingsKeys.contains("lpfFIRGain") || force) {
989  swgPlutoSdrInputSettings->setLpfFirGain(settings.m_lpfFIRGain);
990  }
991  if (deviceSettingsKeys.contains("fcPos") || force) {
992  swgPlutoSdrInputSettings->setFcPos((int) settings.m_fcPos);
993  }
994  if (deviceSettingsKeys.contains("dcBlock") || force) {
995  swgPlutoSdrInputSettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
996  }
997  if (deviceSettingsKeys.contains("iqCorrection") || force) {
998  swgPlutoSdrInputSettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
999  }
1000  if (deviceSettingsKeys.contains("hwBBDCBlock") || force) {
1001  swgPlutoSdrInputSettings->setHwBbdcBlock(settings.m_hwBBDCBlock ? 1 : 0);
1002  }
1003  if (deviceSettingsKeys.contains("hwRFDCBlock") || force) {
1004  swgPlutoSdrInputSettings->setHwRfdcBlock(settings.m_hwRFDCBlock ? 1 : 0);
1005  }
1006  if (deviceSettingsKeys.contains("hwIQCorrection") || force) {
1007  swgPlutoSdrInputSettings->setHwIqCorrection(settings.m_hwIQCorrection ? 1 : 0);
1008  }
1009  if (deviceSettingsKeys.contains("log2Decim") || force) {
1010  swgPlutoSdrInputSettings->setLog2Decim(settings.m_log2Decim);
1011  }
1012  if (deviceSettingsKeys.contains("lpfBW") || force) {
1013  swgPlutoSdrInputSettings->setLpfBw(settings.m_lpfBW);
1014  }
1015  if (deviceSettingsKeys.contains("gain") || force) {
1016  swgPlutoSdrInputSettings->setGain(settings.m_gain);
1017  }
1018  if (deviceSettingsKeys.contains("antennaPath") || force) {
1019  swgPlutoSdrInputSettings->setAntennaPath((int) settings.m_antennaPath);
1020  }
1021  if (deviceSettingsKeys.contains("gainMode") || force) {
1022  swgPlutoSdrInputSettings->setGainMode((int) settings.m_gainMode);
1023  }
1024  if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
1025  swgPlutoSdrInputSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
1026  }
1027  if (deviceSettingsKeys.contains("transverterMode") || force) {
1028  swgPlutoSdrInputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
1029  }
1030  if (deviceSettingsKeys.contains("fileRecordName") || force) {
1031  swgPlutoSdrInputSettings->setFileRecordName(new QString(settings.m_fileRecordName));
1032  }
1033 
1034  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
1035  .arg(settings.m_reverseAPIAddress)
1036  .arg(settings.m_reverseAPIPort)
1037  .arg(settings.m_reverseAPIDeviceIndex);
1038  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
1039  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
1040 
1041  QBuffer *buffer=new QBuffer();
1042  buffer->open((QBuffer::ReadWrite));
1043  buffer->write(swgDeviceSettings->asJson().toUtf8());
1044  buffer->seek(0);
1045 
1046  // Always use PATCH to avoid passing reverse API settings
1047  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
1048 
1049  delete swgDeviceSettings;
1050 }
bool m_lpfFIREnable
enable digital lowpass FIR filter
quint32 m_lpfFIRlog2Decim
digital lowpass FIR filter log2 of decimation factor (0..2)
virtual QString asJson() override
QNetworkAccessManager * m_networkManager
void setHwIqCorrection(qint32 hw_iq_correction)
void setOriginatorIndex(qint32 originator_index)
bool m_hwRFDCBlock
Hardware RF DC blocking.
DeviceAPI * m_deviceAPI
void setLpfFiRlog2Decim(qint32 lpf_fi_rlog2_decim)
bool m_hwIQCorrection
Hardware IQ correction.
int getDeviceSetIndex() const
Definition: deviceapi.h:131
quint64 m_devSampleRate
Host interface sample rate.
void setFileRecordName(QString *file_record_name)
quint32 m_lpfBW
analog lowpass filter bandwidth (Hz)
quint32 m_gain
"hardware" gain
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
qint32 m_LOppmTenths
XO correction.
void setCenterFrequency(qint64 center_frequency)
bool m_hwBBDCBlock
Hardware baseband DC blocking.
quint32 m_lpfFIRBW
digital lowpass FIR filter bandwidth (Hz)
SWGPlutoSdrInputSettings * getPlutoSdrInputSettings()
void setPlutoSdrInputSettings(SWGPlutoSdrInputSettings *pluto_sdr_input_settings)
QNetworkRequest m_networkRequest
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
void setTransverterMode(qint32 transverter_mode)
int m_lpfFIRGain
digital lowpass FIR filter gain (dB)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void PlutoSDRInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 1052 of file plutosdrinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), m_deviceAPI, m_networkManager, m_networkRequest, PlutoSDRInputSettings::m_reverseAPIAddress, PlutoSDRInputSettings::m_reverseAPIDeviceIndex, PlutoSDRInputSettings::m_reverseAPIPort, m_settings, SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), and SWGSDRangel::SWGDeviceSettings::setOriginatorIndex().

Referenced by handleMessage().

1053 {
1055  swgDeviceSettings->setDirection(0); // single Rx
1056  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
1057  swgDeviceSettings->setDeviceHwType(new QString("PlutoSDR"));
1058 
1059  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
1063  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
1064  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
1065 
1066  QBuffer *buffer=new QBuffer();
1067  buffer->open((QBuffer::ReadWrite));
1068  buffer->write(swgDeviceSettings->asJson().toUtf8());
1069  buffer->seek(0);
1070 
1071  if (start) {
1072  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
1073  } else {
1074  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
1075  }
1076 
1077  delete swgDeviceSettings;
1078 }
virtual QString asJson() override
QNetworkAccessManager * m_networkManager
void setOriginatorIndex(qint32 originator_index)
PlutoSDRInputSettings m_settings
DeviceAPI * m_deviceAPI
int getDeviceSetIndex() const
Definition: deviceapi.h:131
virtual bool start()
QNetworkRequest m_networkRequest
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRun()

int PlutoSDRInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 760 of file plutosdrinput.cpp.

References PlutoSDRInput::MsgStartStop::create(), DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), m_deviceAPI, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, and MessageQueue::push().

Referenced by setSampleRate().

764 {
765  (void) errorMessage;
767  MsgStartStop *message = MsgStartStop::create(run);
768  m_inputMessageQueue.push(message);
769 
770  if (m_guiMessageQueue) // forward to GUI if any
771  {
772  MsgStartStop *msgToGUI = MsgStartStop::create(run);
773  m_guiMessageQueue->push(msgToGUI);
774  }
775 
776  return 200;
777 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
DeviceAPI * m_deviceAPI
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
static MsgStartStop * create(bool startStop)
Definition: plutosdrinput.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

int PlutoSDRInput::webapiRunGet ( SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 751 of file plutosdrinput.cpp.

References DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), and m_deviceAPI.

Referenced by setSampleRate().

754 {
755  (void) errorMessage;
757  return 200;
758 }
DeviceAPI * m_deviceAPI
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

int PlutoSDRInput::webapiSettingsGet ( SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 779 of file plutosdrinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getPlutoSdrInputSettings(), SWGSDRangel::SWGPlutoSdrInputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setPlutoSdrInputSettings(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

782 {
783  (void) errorMessage;
785  response.getPlutoSdrInputSettings()->init();
787  return 200;
788 }
PlutoSDRInputSettings m_settings
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PlutoSDRInputSettings &settings)
SWGPlutoSdrInputSettings * getPlutoSdrInputSettings()
void setPlutoSdrInputSettings(SWGPlutoSdrInputSettings *pluto_sdr_input_settings)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

int PlutoSDRInput::webapiSettingsPutPatch ( bool  force,
const QStringList &  deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 790 of file plutosdrinput.cpp.

References PlutoSDRInput::MsgConfigurePlutoSDR::create(), PlutoSDRInputSettings::GAIN_END, SWGSDRangel::SWGPlutoSdrInputSettings::getAntennaPath(), SWGSDRangel::SWGPlutoSdrInputSettings::getCenterFrequency(), SWGSDRangel::SWGPlutoSdrInputSettings::getDcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::getDevSampleRate(), SWGSDRangel::SWGPlutoSdrInputSettings::getFcPos(), SWGSDRangel::SWGPlutoSdrInputSettings::getFileRecordName(), SWGSDRangel::SWGPlutoSdrInputSettings::getGain(), SWGSDRangel::SWGPlutoSdrInputSettings::getGainMode(), SWGSDRangel::SWGPlutoSdrInputSettings::getHwBbdcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::getHwIqCorrection(), SWGSDRangel::SWGPlutoSdrInputSettings::getHwRfdcBlock(), SWGSDRangel::SWGPlutoSdrInputSettings::getIqCorrection(), SWGSDRangel::SWGPlutoSdrInputSettings::getLog2Decim(), SWGSDRangel::SWGPlutoSdrInputSettings::getLOppmTenths(), SWGSDRangel::SWGPlutoSdrInputSettings::getLpfBw(), SWGSDRangel::SWGPlutoSdrInputSettings::getLpfFirbw(), SWGSDRangel::SWGPlutoSdrInputSettings::getLpfFirEnable(), SWGSDRangel::SWGPlutoSdrInputSettings::getLpfFirGain(), SWGSDRangel::SWGPlutoSdrInputSettings::getLpfFiRlog2Decim(), SWGSDRangel::SWGDeviceSettings::getPlutoSdrInputSettings(), SWGSDRangel::SWGPlutoSdrInputSettings::getReverseApiAddress(), SWGSDRangel::SWGPlutoSdrInputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGPlutoSdrInputSettings::getReverseApiPort(), SWGSDRangel::SWGPlutoSdrInputSettings::getTransverterDeltaFrequency(), SWGSDRangel::SWGPlutoSdrInputSettings::getTransverterMode(), SWGSDRangel::SWGPlutoSdrInputSettings::getUseReverseApi(), PlutoSDRInputSettings::m_antennaPath, PlutoSDRInputSettings::m_centerFrequency, PlutoSDRInputSettings::m_dcBlock, PlutoSDRInputSettings::m_devSampleRate, PlutoSDRInputSettings::m_fcPos, PlutoSDRInputSettings::m_fileRecordName, PlutoSDRInputSettings::m_gain, PlutoSDRInputSettings::m_gainMode, DeviceSampleSource::m_guiMessageQueue, PlutoSDRInputSettings::m_hwBBDCBlock, DeviceSampleSource::m_inputMessageQueue, PlutoSDRInputSettings::m_iqCorrection, PlutoSDRInputSettings::m_log2Decim, PlutoSDRInputSettings::m_LOppmTenths, PlutoSDRInputSettings::m_lpfBW, PlutoSDRInputSettings::m_lpfFIRBW, PlutoSDRInputSettings::m_lpfFIREnable, PlutoSDRInputSettings::m_lpfFIRGain, PlutoSDRInputSettings::m_lpfFIRlog2Decim, PlutoSDRInputSettings::m_reverseAPIAddress, PlutoSDRInputSettings::m_reverseAPIDeviceIndex, PlutoSDRInputSettings::m_reverseAPIPort, m_settings, PlutoSDRInputSettings::m_transverterDeltaFrequency, PlutoSDRInputSettings::m_transverterMode, PlutoSDRInputSettings::m_useReverseAPI, MessageQueue::push(), PlutoSDRInputSettings::RFPATH_END, and webapiFormatDeviceSettings().

Referenced by setSampleRate().

795 {
796  (void) errorMessage;
798 
799  if (deviceSettingsKeys.contains("centerFrequency")) {
801  }
802  if (deviceSettingsKeys.contains("devSampleRate")) {
804  }
805  if (deviceSettingsKeys.contains("LOppmTenths")) {
806  settings.m_LOppmTenths = response.getPlutoSdrInputSettings()->getLOppmTenths();
807  }
808  if (deviceSettingsKeys.contains("lpfFIREnable")) {
809  settings.m_lpfFIREnable = response.getPlutoSdrInputSettings()->getLpfFirEnable() != 0;
810  }
811  if (deviceSettingsKeys.contains("lpfFIRBW")) {
812  settings.m_lpfFIRBW = response.getPlutoSdrInputSettings()->getLpfFirbw();
813  }
814  if (deviceSettingsKeys.contains("lpfFIRlog2Decim")) {
816  }
817  if (deviceSettingsKeys.contains("lpfFIRGain")) {
818  settings.m_lpfFIRGain = response.getPlutoSdrInputSettings()->getLpfFirGain();
819  }
820  if (deviceSettingsKeys.contains("fcPos")) {
821  int fcPos = response.getPlutoSdrInputSettings()->getFcPos();
822  fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
823  settings.m_fcPos = (PlutoSDRInputSettings::fcPos_t) fcPos;
824  }
825  if (deviceSettingsKeys.contains("dcBlock")) {
826  settings.m_dcBlock = response.getPlutoSdrInputSettings()->getDcBlock() != 0;
827  }
828  if (deviceSettingsKeys.contains("iqCorrection")) {
829  settings.m_iqCorrection = response.getPlutoSdrInputSettings()->getIqCorrection() != 0;
830  }
831  if (deviceSettingsKeys.contains("hwBBDCBlock")) {
832  settings.m_hwBBDCBlock = response.getPlutoSdrInputSettings()->getHwBbdcBlock() != 0;
833  }
834  if (deviceSettingsKeys.contains("hwRFDCBlock")) {
835  settings.m_hwBBDCBlock = response.getPlutoSdrInputSettings()->getHwRfdcBlock() != 0;
836  }
837  if (deviceSettingsKeys.contains("hwIQCorrection")) {
838  settings.m_hwBBDCBlock = response.getPlutoSdrInputSettings()->getHwIqCorrection() != 0;
839  }
840  if (deviceSettingsKeys.contains("log2Decim")) {
841  settings.m_log2Decim = response.getPlutoSdrInputSettings()->getLog2Decim();
842  }
843  if (deviceSettingsKeys.contains("lpfBW")) {
844  settings.m_lpfBW = response.getPlutoSdrInputSettings()->getLpfBw();
845  }
846  if (deviceSettingsKeys.contains("gain")) {
847  settings.m_gain = response.getPlutoSdrInputSettings()->getGain();
848  }
849  if (deviceSettingsKeys.contains("antennaPath")) {
850  int antennaPath = response.getPlutoSdrInputSettings()->getAntennaPath();
851  antennaPath = antennaPath < 0 ? 0 : antennaPath >= PlutoSDRInputSettings::RFPATH_END ? PlutoSDRInputSettings::RFPATH_END-1 : antennaPath;
852  settings.m_antennaPath = (PlutoSDRInputSettings::RFPath) antennaPath;
853  }
854  if (deviceSettingsKeys.contains("gainMode")) {
855  int gainMode = response.getPlutoSdrInputSettings()->getGainMode();
856  gainMode = gainMode < 0 ? 0 : gainMode >= PlutoSDRInputSettings::GAIN_END ? PlutoSDRInputSettings::GAIN_END-1 : gainMode;
857  settings.m_gainMode = (PlutoSDRInputSettings::GainMode) gainMode;
858  }
859  if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
861  }
862  if (deviceSettingsKeys.contains("transverterMode")) {
863  settings.m_transverterMode = response.getPlutoSdrInputSettings()->getTransverterMode() != 0;
864  }
865  if (deviceSettingsKeys.contains("fileRecordName")) {
867  }
868  if (deviceSettingsKeys.contains("useReverseAPI")) {
869  settings.m_useReverseAPI = response.getPlutoSdrInputSettings()->getUseReverseApi() != 0;
870  }
871  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
873  }
874  if (deviceSettingsKeys.contains("reverseAPIPort")) {
876  }
877  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
879  }
880 
881  MsgConfigurePlutoSDR *msg = MsgConfigurePlutoSDR::create(settings, force);
883 
884  if (m_guiMessageQueue) // forward to GUI if any
885  {
886  MsgConfigurePlutoSDR *msgToGUI = MsgConfigurePlutoSDR::create(settings, force);
887  m_guiMessageQueue->push(msgToGUI);
888  }
889 
890  webapiFormatDeviceSettings(response, settings);
891  return 200;
892 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
bool m_lpfFIREnable
enable digital lowpass FIR filter
quint32 m_lpfFIRlog2Decim
digital lowpass FIR filter log2 of decimation factor (0..2)
static MsgConfigurePlutoSDR * create(const PlutoSDRInputSettings &settings, bool force)
Definition: plutosdrinput.h:48
MessageQueue m_inputMessageQueue
Input queue to the source.
PlutoSDRInputSettings m_settings
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PlutoSDRInputSettings &settings)
quint64 m_devSampleRate
Host interface sample rate.
quint32 m_lpfBW
analog lowpass filter bandwidth (Hz)
quint32 m_gain
"hardware" gain
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
qint32 m_LOppmTenths
XO correction.
bool m_hwBBDCBlock
Hardware baseband DC blocking.
quint32 m_lpfFIRBW
digital lowpass FIR filter bandwidth (Hz)
SWGPlutoSdrInputSettings * getPlutoSdrInputSettings()
int m_lpfFIRGain
digital lowpass FIR filter gain (dB)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_deviceAPI

DeviceAPI* PlutoSDRInput::m_deviceAPI
private

◆ m_deviceDescription

QString PlutoSDRInput::m_deviceDescription
private

Definition at line 157 of file plutosdrinput.h.

Referenced by getDeviceDescription().

◆ m_deviceSampleRates

DevicePlutoSDRBox::SampleRates PlutoSDRInput::m_deviceSampleRates
private

Definition at line 163 of file plutosdrinput.h.

Referenced by applySettings(), getADCSampleRate(), and getFIRSampleRate().

◆ m_deviceShared

DevicePlutoSDRShared PlutoSDRInput::m_deviceShared
private

◆ m_fileSink

FileRecord* PlutoSDRInput::m_fileSink
private

Definition at line 156 of file plutosdrinput.h.

Referenced by applySettings(), handleMessage(), and ~PlutoSDRInput().

◆ m_mutex

QMutex PlutoSDRInput::m_mutex
private

Definition at line 164 of file plutosdrinput.h.

◆ m_networkManager

QNetworkAccessManager* PlutoSDRInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest PlutoSDRInput::m_networkRequest
private

Definition at line 166 of file plutosdrinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_plutoRxBuffer

struct iio_buffer* PlutoSDRInput::m_plutoRxBuffer
private

Definition at line 161 of file plutosdrinput.h.

Referenced by openDevice().

◆ m_plutoSDRInputThread

PlutoSDRInputThread* PlutoSDRInput::m_plutoSDRInputThread
private

Definition at line 162 of file plutosdrinput.h.

Referenced by applySettings(), start(), and stop().

◆ m_running

bool PlutoSDRInput::m_running
private

Definition at line 159 of file plutosdrinput.h.

Referenced by start(), and stop().

◆ m_settings

PlutoSDRInputSettings PlutoSDRInput::m_settings
private

The documentation for this class was generated from the following files: