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
FCDProPlusInput Class Reference

#include <fcdproplusinput.h>

+ Inheritance diagram for FCDProPlusInput:
+ Collaboration diagram for FCDProPlusInput:

Classes

class  MsgConfigureFCDProPlus
 
class  MsgFileRecord
 
class  MsgStartStop
 

Public Member Functions

 FCDProPlusInput (DeviceAPI *deviceAPI)
 
virtual ~FCDProPlusInput ()
 
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)
 
void set_center_freq (double freq)
 
void set_bias_t (bool on)
 
void set_lna_gain (bool on)
 
void set_mixer_gain (bool on)
 
void set_if_gain (int gain)
 
void set_rf_filter (int filterIndex)
 
void set_if_filter (int filterIndex)
 
- Public Member Functions inherited from DeviceSampleSource
 DeviceSampleSource ()
 
virtual ~DeviceSampleSource ()
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

bool openDevice ()
 
void closeDevice ()
 
bool openFCDAudio (const char *filename)
 
void closeFCDAudio ()
 
void applySettings (const FCDProPlusSettings &settings, bool force)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const FCDProPlusSettings &settings)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const FCDProPlusSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
hid_devicem_dev
 
AudioInput m_fcdAudioInput
 
AudioFifo m_fcdFIFO
 
QMutex m_mutex
 
FCDProPlusSettings m_settings
 
FCDProPlusThreadm_FCDThread
 
QString m_deviceDescription
 
bool m_running
 
FileRecordm_fileSink
 File sink to record device I/Q output. More...
 
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 45 of file fcdproplusinput.h.

Constructor & Destructor Documentation

◆ FCDProPlusInput()

FCDProPlusInput::FCDProPlusInput ( DeviceAPI deviceAPI)

Definition at line 42 of file fcdproplusinput.cpp.

References arg().

42  :
43  m_deviceAPI(deviceAPI),
44  m_dev(0),
45  m_settings(),
46  m_FCDThread(0),
48  m_running(false)
49 {
51  openDevice();
52  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
55  m_networkManager = new QNetworkAccessManager();
56  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
57 }
FCDProPlusThread * m_FCDThread
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
QNetworkAccessManager * m_networkManager
DeviceAPI * m_deviceAPI
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
FileRecord * m_fileSink
File sink to record device I/Q output.
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
hid_device * m_dev
FCDProPlusSettings m_settings
bool setSize(uint32_t numSamples)
Definition: audiofifo.cpp:59
void networkManagerFinished(QNetworkReply *reply)
QString m_deviceDescription
+ Here is the call graph for this function:

◆ ~FCDProPlusInput()

FCDProPlusInput::~FCDProPlusInput ( )
virtual

Definition at line 59 of file fcdproplusinput.cpp.

References closeDevice(), m_deviceAPI, m_fileSink, m_networkManager, m_running, networkManagerFinished(), DeviceAPI::removeAncillarySink(), and stop().

60 {
61  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
62  delete m_networkManager;
63 
64  if (m_running) {
65  stop();
66  }
67 
69  delete m_fileSink;
70 
71  closeDevice();
72 }
QNetworkAccessManager * m_networkManager
DeviceAPI * m_deviceAPI
FileRecord * m_fileSink
File sink to record device I/Q output.
virtual void stop()
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:

Member Function Documentation

◆ applySettings()

void FCDProPlusInput::applySettings ( const FCDProPlusSettings settings,
bool  force 
)
private

Definition at line 325 of file fcdproplusinput.cpp.

References DeviceSampleSource::calculateDeviceCenterFrequency(), DeviceAPI::configureCorrections(), DeviceAPI::getDeviceEngineInputMessageQueue(), FileRecord::handleMessage(), FCDProPlusSettings::m_biasT, FCDProPlusSettings::m_centerFrequency, FCDProPlusSettings::m_dcBlock, m_dev, m_deviceAPI, m_FCDThread, FCDProPlusSettings::m_fcPos, m_fileSink, FCDProPlusSettings::m_ifFilterIndex, FCDProPlusSettings::m_ifGain, FCDProPlusSettings::m_iqImbalance, FCDProPlusSettings::m_lnaGain, FCDProPlusSettings::m_log2Decim, FCDProPlusSettings::m_LOppmTenths, FCDProPlusSettings::m_mixGain, FCDProPlusSettings::m_reverseAPIAddress, FCDProPlusSettings::m_reverseAPIDeviceIndex, FCDProPlusSettings::m_reverseAPIPort, FCDProPlusSettings::m_rfFilterIndex, m_settings, FCDProPlusSettings::m_transverterDeltaFrequency, FCDProPlusSettings::m_transverterMode, FCDProPlusSettings::m_useReverseAPI, MessageQueue::push(), set_bias_t(), set_center_freq(), set_if_filter(), set_if_gain(), set_lna_gain(), set_mixer_gain(), set_rf_filter(), FCDProPlusThread::setFcPos(), FCDProPlusThread::setLog2Decimation(), and webapiReverseSendSettings().

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

326 {
327  bool forwardChange = false;
328  QList<QString> reverseAPIKeys;
329 
330  if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) {
331  reverseAPIKeys.append("centerFrequency");
332  }
333  if (force || (m_settings.m_transverterMode != settings.m_transverterMode)) {
334  reverseAPIKeys.append("transverterMode");
335  }
337  reverseAPIKeys.append("transverterDeltaFrequency");
338  }
339  if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
340  reverseAPIKeys.append("LOppmTenths");
341  }
342 
343  if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
344  || (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
345  || (m_settings.m_fcPos != settings.m_fcPos)
346  || (m_settings.m_log2Decim != settings.m_log2Decim)
349  {
350  qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
351  settings.m_centerFrequency,
353  settings.m_log2Decim,
356  DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
357  settings.m_transverterMode);
358 
359  if (m_dev != 0) {
360  set_center_freq((double) deviceCenterFrequency);
361  }
362 
363  qDebug() << "FCDProPlusInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz"
364  << " device center freq: " << deviceCenterFrequency << " Hz";
365 
366  forwardChange = (m_settings.m_centerFrequency != settings.m_centerFrequency) || force;
367 
369  }
370 
371  if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
372  {
373  reverseAPIKeys.append("log2Decim");
374  forwardChange = true;
375 
376  if (m_FCDThread != 0)
377  {
379  qDebug() << "FCDProPlusInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
380  }
381  }
382 
383  if ((m_settings.m_fcPos != settings.m_fcPos) || force)
384  {
385  reverseAPIKeys.append("fcPos");
386 
387  if (m_FCDThread != 0) {
388  m_FCDThread->setFcPos((int) settings.m_fcPos);
389  }
390 
391  qDebug() << "FCDProPlusInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos;
392  }
393 
394  if ((m_settings.m_lnaGain != settings.m_lnaGain) || force)
395  {
396  reverseAPIKeys.append("lnaGain");
397 
398  if (m_dev != 0) {
399  set_lna_gain(settings.m_lnaGain);
400  }
401  }
402 
403  if ((m_settings.m_biasT != settings.m_biasT) || force)
404  {
405  reverseAPIKeys.append("biasT");
406 
407  if (m_dev != 0) {
408  set_bias_t(settings.m_biasT);
409  }
410  }
411 
412  if ((m_settings.m_mixGain != settings.m_mixGain) || force)
413  {
414  reverseAPIKeys.append("mixGain");
415 
416  if (m_dev != 0) {
417  set_mixer_gain(settings.m_mixGain);
418  }
419  }
420 
421  if ((m_settings.m_ifGain != settings.m_ifGain) || force)
422  {
423  reverseAPIKeys.append("ifGain");
424 
425  if (m_dev != 0) {
426  set_if_gain(settings.m_ifGain);
427  }
428  }
429 
430  if ((m_settings.m_ifFilterIndex != settings.m_ifFilterIndex) || force)
431  {
432  reverseAPIKeys.append("ifFilterIndex");
433 
434  if (m_dev != 0) {
435  set_if_filter(settings.m_ifFilterIndex);
436  }
437  }
438 
439  if ((m_settings.m_rfFilterIndex != settings.m_rfFilterIndex) || force)
440  {
441  reverseAPIKeys.append("rfFilterIndex");
442 
443  if (m_dev != 0) {
444  set_rf_filter(settings.m_rfFilterIndex);
445  }
446  }
447 
448  if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
449  {
450  reverseAPIKeys.append("dcBlock");
452  }
453 
454  if ((m_settings.m_iqImbalance != settings.m_iqImbalance) || force)
455  {
456  reverseAPIKeys.append("iqImbalance");
458  }
459 
460  if (settings.m_useReverseAPI)
461  {
462  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
466  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
467  }
468 
469  m_settings = settings;
470 
471  if (forwardChange)
472  {
474  m_fileSink->handleMessage(*notif); // forward to file sink
476  }
477 }
FCDProPlusThread * m_FCDThread
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.
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
void set_if_filter(int filterIndex)
DeviceAPI * m_deviceAPI
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const FCDProPlusSettings &settings, bool force)
void setFcPos(int fcPos)
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
Definition: filerecord.cpp:128
FileRecord * m_fileSink
File sink to record device I/Q output.
void setLog2Decimation(unsigned int log2_decim)
hid_device * m_dev
FCDProPlusSettings m_settings
void set_rf_filter(int filterIndex)
void set_center_freq(double freq)
void set_mixer_gain(bool on)
void set_if_gain(int gain)
void set_lna_gain(bool on)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
uint16_t m_reverseAPIDeviceIndex
void set_bias_t(bool on)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeDevice()

void FCDProPlusInput::closeDevice ( )
private

Definition at line 152 of file fcdproplusinput.cpp.

References closeFCDAudio(), fcdClose(), and m_dev.

Referenced by openDevice(), and ~FCDProPlusInput().

153 {
154  if (m_dev == 0) { // was never open
155  return;
156  }
157 
158  fcdClose(m_dev);
159  m_dev = 0;
160 
161  closeFCDAudio();
162 }
void fcdClose(hid_device *phd)
Close FCD HID device.
Definition: fcdhid.c:78
hid_device * m_dev
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeFCDAudio()

void FCDProPlusInput::closeFCDAudio ( )
private

Definition at line 187 of file fcdproplusinput.cpp.

References m_fcdAudioInput, m_fcdFIFO, AudioInput::removeFifo(), and AudioInput::stop().

Referenced by closeDevice().

188 {
191 }
void removeFifo(AudioFifo *audioFifo)
Definition: audioinput.cpp:149
void stop()
Definition: audioinput.cpp:121
AudioInput m_fcdAudioInput
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSource.

Definition at line 213 of file fcdproplusinput.cpp.

References FCDProPlusInput::MsgConfigureFCDProPlus::create(), FCDProPlusSettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and FCDProPlusSettings::resetToDefaults().

214 {
215  bool success = true;
216 
217  if (!m_settings.deserialize(data))
218  {
220  success = false;
221  }
222 
223  MsgConfigureFCDProPlus* message = MsgConfigureFCDProPlus::create(m_settings, true);
224  m_inputMessageQueue.push(message);
225 
226  if (m_guiMessageQueue)
227  {
228  MsgConfigureFCDProPlus* messageToGUI = MsgConfigureFCDProPlus::create(m_settings, true);
229  m_guiMessageQueue->push(messageToGUI);
230  }
231 
232  return success;
233 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgConfigureFCDProPlus * create(const FCDProPlusSettings &settings, bool force)
bool deserialize(const QByteArray &data)
FCDProPlusSettings m_settings
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ destroy()

void FCDProPlusInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 74 of file fcdproplusinput.cpp.

75 {
76  delete this;
77 }

◆ getCenterFrequency()

quint64 FCDProPlusInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 245 of file fcdproplusinput.cpp.

References FCDProPlusSettings::m_centerFrequency, and m_settings.

246 {
248 }
FCDProPlusSettings m_settings

◆ getDeviceDescription()

const QString & FCDProPlusInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 235 of file fcdproplusinput.cpp.

References m_deviceDescription.

236 {
237  return m_deviceDescription;
238 }
QString m_deviceDescription

◆ getSampleRate()

int FCDProPlusInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 240 of file fcdproplusinput.cpp.

References FCDProPlusSettings::m_log2Decim, and m_settings.

241 {
243 }
FCDProPlusSettings m_settings

◆ handleMessage()

bool FCDProPlusInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 265 of file fcdproplusinput.cpp.

References applySettings(), FileRecord::genUniqueFileName(), DeviceAPI::getDeviceUID(), FCDProPlusInput::MsgConfigureFCDProPlus::getForce(), FCDProPlusInput::MsgConfigureFCDProPlus::getSettings(), FCDProPlusInput::MsgStartStop::getStartStop(), FCDProPlusInput::MsgFileRecord::getStartStop(), DeviceAPI::initDeviceEngine(), m_deviceAPI, FCDProPlusSettings::m_fileRecordName, m_fileSink, m_settings, FCDProPlusSettings::m_useReverseAPI, Message::match(), FileRecord::setFileName(), DeviceAPI::startDeviceEngine(), FileRecord::startRecording(), DeviceAPI::stopDeviceEngine(), FileRecord::stopRecording(), and webapiReverseSendStartStop().

266 {
267  if(MsgConfigureFCDProPlus::match(message))
268  {
269  qDebug() << "FCDProPlusInput::handleMessage: MsgConfigureFCD";
270  MsgConfigureFCDProPlus& conf = (MsgConfigureFCDProPlus&) message;
271  applySettings(conf.getSettings(), conf.getForce());
272  return true;
273  }
274  else if (MsgStartStop::match(message))
275  {
276  MsgStartStop& cmd = (MsgStartStop&) message;
277  qDebug() << "FCDProPlusInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
278 
279  if (cmd.getStartStop())
280  {
282  {
284  }
285  }
286  else
287  {
289  }
290 
292  webapiReverseSendStartStop(cmd.getStartStop());
293  }
294 
295  return true;
296  }
297  else if (MsgFileRecord::match(message))
298  {
299  MsgFileRecord& conf = (MsgFileRecord&) message;
300  qDebug() << "FCDProPlusInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
301 
302  if (conf.getStartStop())
303  {
304  if (m_settings.m_fileRecordName.size() != 0) {
306  } else {
308  }
309 
311  }
312  else
313  {
315  }
316 
317  return true;
318  }
319  else
320  {
321  return false;
322  }
323 }
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
void setFileName(const QString &filename)
Definition: filerecord.cpp:59
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void startRecording()
Definition: filerecord.cpp:105
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
DeviceAPI * m_deviceAPI
FileRecord * m_fileSink
File sink to record device I/Q output.
void applySettings(const FCDProPlusSettings &settings, bool force)
void genUniqueFileName(uint deviceUID, int istream=-1)
Definition: filerecord.cpp:67
void webapiReverseSendStartStop(bool start)
void stopRecording()
Definition: filerecord.cpp:117
static bool match(const Message *message)
Definition: message.cpp:45
FCDProPlusSettings m_settings
+ Here is the call graph for this function:

◆ init()

void FCDProPlusInput::init ( )
virtual

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

Implements DeviceSampleSource.

Definition at line 108 of file fcdproplusinput.cpp.

References applySettings(), and m_settings.

109 {
110  applySettings(m_settings, true);
111 }
void applySettings(const FCDProPlusSettings &settings, bool force)
FCDProPlusSettings m_settings
+ Here is the call graph for this function:

◆ networkManagerFinished

void FCDProPlusInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 820 of file fcdproplusinput.cpp.

Referenced by ~FCDProPlusInput().

821 {
822  QNetworkReply::NetworkError replyError = reply->error();
823 
824  if (replyError)
825  {
826  qWarning() << "FCDProPlusInput::networkManagerFinished:"
827  << " error(" << (int) replyError
828  << "): " << replyError
829  << ": " << reply->errorString();
830  return;
831  }
832 
833  QString answer = reply->readAll();
834  answer.chop(1); // remove last \n
835  qDebug("FCDProPlusInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
836 }
+ Here is the caller graph for this function:

◆ openDevice()

bool FCDProPlusInput::openDevice ( )
private

Definition at line 79 of file fcdproplusinput.cpp.

References closeDevice(), fcdOpen(), DeviceAPI::getSamplingDeviceSequence(), m_dev, m_deviceAPI, and openFCDAudio().

80 {
81  if (m_dev != 0) {
82  closeDevice();
83  }
84 
85  int device = m_deviceAPI->getSamplingDeviceSequence();
86  qDebug() << "FCDProPlusInput::openDevice with device #" << device;
88 
89  if (m_dev == 0)
90  {
91  qCritical("FCDProPlusInput::start: could not open FCD");
92  return false;
93  }
94 
96  {
97  qCritical("FCDProPlusInput::start: could not open FCD audio source");
98  return false;
99  }
100  else
101  {
102  qDebug("FCDProPlusInput::start: FCD audio source opened");
103  }
104 
105  return true;
106 }
bool openFCDAudio(const char *filename)
DeviceAPI * m_deviceAPI
hid_device * fcdOpen(uint16_t usVID, uint16_t usPID, int whichdongle)
Open FCD device.
Definition: fcdhid.c:31
hid_device * m_dev
uint32_t getSamplingDeviceSequence() const
Definition: deviceapi.h:123
+ Here is the call graph for this function:

◆ openFCDAudio()

bool FCDProPlusInput::openFCDAudio ( const char *  filename)
private

Definition at line 164 of file fcdproplusinput.cpp.

References AudioInput::addFifo(), DSPEngine::getAudioDeviceManager(), AudioDeviceManager::getInputDeviceIndex(), AudioDeviceManager::getInputDevices(), AudioInput::getRate(), DSPEngine::instance(), m_fcdAudioInput, m_fcdFIFO, and AudioInput::start().

Referenced by openDevice().

165 {
167  const QList<QAudioDeviceInfo>& audioList = audioDeviceManager->getInputDevices();
168 
169  for (const auto &itAudio : audioList)
170  {
171  if (itAudio.deviceName().contains(QString(cardname)))
172  {
173  int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
175  int fcdSampleRate = m_fcdAudioInput.getRate();
176  qDebug("FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
177  itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
179  return true;
180  }
181  }
182 
183  qCritical("FCDProPlusInput::openFCDAudio: device with name %s not found", cardname);
184  return false;
185 }
const QList< QAudioDeviceInfo > & getInputDevices() const
static DSPEngine * instance()
Definition: dspengine.cpp:51
bool start(int device, int rate)
Definition: audioinput.cpp:49
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
int getInputDeviceIndex(const QString &deviceName) const
uint getRate() const
Definition: audioinput.h:45
AudioInput m_fcdAudioInput
void addFifo(AudioFifo *audioFifo)
Definition: audioinput.cpp:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray FCDProPlusInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 208 of file fcdproplusinput.cpp.

References m_settings, and FCDProPlusSettings::serialize().

209 {
210  return m_settings.serialize();
211 }
QByteArray serialize() const
FCDProPlusSettings m_settings
+ Here is the call graph for this function:

◆ set_bias_t()

void FCDProPlusInput::set_bias_t ( bool  on)

Definition at line 489 of file fcdproplusinput.cpp.

References fcdAppSetParam(), FCDPROPLUS_HID_CMD_SET_BIAS_TEE, and m_dev.

Referenced by applySettings().

490 {
491  quint8 cmd = on ? 1 : 0;
492 
494 }
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
Definition: fcdhid.c:826
#define FCDPROPLUS_HID_CMD_SET_BIAS_TEE
hid_device * m_dev
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_center_freq()

void FCDProPlusInput::set_center_freq ( double  freq)

Definition at line 479 of file fcdproplusinput.cpp.

References FCD_MODE_NONE, fcdAppSetFreq(), m_dev, FCDProPlusSettings::m_LOppmTenths, and m_settings.

Referenced by applySettings().

480 {
481  freq += freq*(((double) m_settings.m_LOppmTenths)/10000000.0);
482 
483  if (fcdAppSetFreq(m_dev, freq) == FCD_MODE_NONE)
484  {
485  qDebug("No FCD HID found for frquency change");
486  }
487 }
FCD_MODE_ENUM fcdAppSetFreq(hid_device *phd, int nFreq)
Set FCD frequency with Hz resolution.
Definition: fcdhid.c:450
hid_device * m_dev
FCDProPlusSettings m_settings
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_if_filter()

void FCDProPlusInput::set_if_filter ( int  filterIndex)

Definition at line 525 of file fcdproplusinput.cpp.

References FCD_MODE_APP, fcdAppSetParam(), FCDPROPLUS_HID_CMD_SET_IF_FILTER, FCDProPlusConstants::fcdproplus_if_filter_nb_values(), FCDProPlusConstants::if_filters, m_dev, and fcdproplus_if_filter::value.

Referenced by applySettings().

526 {
527  if ((filterIndex < 0) || (filterIndex >= FCDProPlusConstants::fcdproplus_if_filter_nb_values()))
528  {
529  return;
530  }
531 
532  quint8 cmd_value = FCDProPlusConstants::if_filters[filterIndex].value;
533 
535  {
536  qWarning() << "FCDProPlusInput::set_if_filter: failed to set at " << cmd_value;
537  }
538 }
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
Definition: fcdhid.c:826
static const fcdproplus_if_filter if_filters[]
static int fcdproplus_if_filter_nb_values()
hid_device * m_dev
fcdproplus_if_filter_value value
#define FCDPROPLUS_HID_CMD_SET_IF_FILTER
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_if_gain()

void FCDProPlusInput::set_if_gain ( int  gain)

Definition at line 510 of file fcdproplusinput.cpp.

References FCD_MODE_APP, fcdAppSetParam(), FCDPROPLUS_HID_CMD_SET_IF_GAIN, and m_dev.

Referenced by applySettings().

511 {
512  if (gain < 0)
513  {
514  return;
515  }
516 
517  quint8 cmd_value = gain;
518 
520  {
521  qWarning() << "FCDProPlusInput::set_if_gain: failed to set at " << cmd_value;
522  }
523 }
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
Definition: fcdhid.c:826
#define FCDPROPLUS_HID_CMD_SET_IF_GAIN
hid_device * m_dev
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_lna_gain()

void FCDProPlusInput::set_lna_gain ( bool  on)

Definition at line 496 of file fcdproplusinput.cpp.

References fcdAppSetParam(), FCDPROPLUS_HID_CMD_SET_LNA_GAIN, and m_dev.

Referenced by applySettings().

497 {
498  quint8 cmd = on ? 1 : 0;
499 
501 }
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
Definition: fcdhid.c:826
#define FCDPROPLUS_HID_CMD_SET_LNA_GAIN
hid_device * m_dev
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_mixer_gain()

void FCDProPlusInput::set_mixer_gain ( bool  on)

Definition at line 503 of file fcdproplusinput.cpp.

References fcdAppSetParam(), FCDPROPLUS_HID_CMD_SET_MIXER_GAIN, and m_dev.

Referenced by applySettings().

504 {
505  quint8 cmd = on ? 1 : 0;
506 
508 }
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
Definition: fcdhid.c:826
hid_device * m_dev
#define FCDPROPLUS_HID_CMD_SET_MIXER_GAIN
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_rf_filter()

void FCDProPlusInput::set_rf_filter ( int  filterIndex)

Definition at line 541 of file fcdproplusinput.cpp.

References FCD_MODE_APP, fcdAppSetParam(), FCDPROPLUS_HID_CMD_SET_RF_FILTER, FCDProPlusConstants::fcdproplus_rf_filter_nb_values(), m_dev, FCDProPlusConstants::rf_filters, and fcdproplus_rf_filter::value.

Referenced by applySettings().

542 {
543  if ((filterIndex < 0) || (filterIndex >= FCDProPlusConstants::fcdproplus_rf_filter_nb_values()))
544  {
545  return;
546  }
547 
548  quint8 cmd_value = FCDProPlusConstants::rf_filters[filterIndex].value;
549 
551  {
552  qWarning() << "FCDProPlusInput::set_rf_filter: failed to set at " << cmd_value;
553  }
554 }
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
Definition: fcdhid.c:826
static const fcdproplus_rf_filter rf_filters[]
#define FCDPROPLUS_HID_CMD_SET_RF_FILTER
static int fcdproplus_rf_filter_nb_values()
fcdproplus_rf_filter_value value
hid_device * m_dev
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void FCDProPlusInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 250 of file fcdproplusinput.cpp.

References FCDProPlusInput::MsgConfigureFCDProPlus::create(), FCDProPlusSettings::m_centerFrequency, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, and MessageQueue::push().

251 {
252  FCDProPlusSettings settings = m_settings;
253  settings.m_centerFrequency = centerFrequency;
254 
255  MsgConfigureFCDProPlus* message = MsgConfigureFCDProPlus::create(settings, false);
256  m_inputMessageQueue.push(message);
257 
258  if (m_guiMessageQueue)
259  {
260  MsgConfigureFCDProPlus* messageToGUI = MsgConfigureFCDProPlus::create(settings, false);
261  m_guiMessageQueue->push(messageToGUI);
262  }
263 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgConfigureFCDProPlus * create(const FCDProPlusSettings &settings, bool force)
FCDProPlusSettings m_settings
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ setMessageQueueToGUI()

virtual void FCDProPlusInput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSource.

Definition at line 120 of file fcdproplusinput.h.

120 { m_guiMessageQueue = queue; }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.

◆ setSampleRate()

virtual void FCDProPlusInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 123 of file fcdproplusinput.h.

123 { (void) sampleRate; }

◆ start()

bool FCDProPlusInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 113 of file fcdproplusinput.cpp.

References applySettings(), m_dev, m_fcdFIFO, m_FCDThread, m_running, DeviceSampleSource::m_sampleFifo, m_settings, SampleSinkFifo::setSize(), FCDProPlusThread::startWork(), and stop().

114 {
115 // QMutexLocker mutexLocker(&m_mutex);
116 
117  if (!m_dev) {
118  return false;
119  }
120 
121  if (m_running) {
122  stop();
123  }
124 
125  qDebug() << "FCDProPlusInput::start";
126 
127  /* Apply settings before streaming to avoid bus contention;
128  * there is very little spare bandwidth on a full speed USB device.
129  * Failure is harmless if no device is found
130  * ... This is rubbish...*/
131 
132  //applySettings(m_settings, true);
133 
134  if (!m_sampleFifo.setSize(96000*4))
135  {
136  qCritical("FCDProPlusInput::start: could not allocate SampleFifo");
137  return false;
138  }
139 
142 
143 // mutexLocker.unlock();
144  applySettings(m_settings, true);
145 
146  qDebug("FCDProPlusInput::started");
147  m_running = true;
148 
149  return true;
150 }
FCDProPlusThread * m_FCDThread
SampleSinkFifo m_sampleFifo
bool setSize(int size)
void applySettings(const FCDProPlusSettings &settings, bool force)
virtual void stop()
hid_device * m_dev
FCDProPlusSettings m_settings
+ Here is the call graph for this function:

◆ stop()

void FCDProPlusInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 193 of file fcdproplusinput.cpp.

References m_FCDThread, m_mutex, m_running, and FCDProPlusThread::stopWork().

Referenced by start(), and ~FCDProPlusInput().

194 {
195  QMutexLocker mutexLocker(&m_mutex);
196 
197  if (m_FCDThread)
198  {
200  // wait for thread to quit ?
201  delete m_FCDThread;
202  m_FCDThread = nullptr;
203  }
204 
205  m_running = false;
206 }
FCDProPlusThread * m_FCDThread
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void FCDProPlusInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const FCDProPlusSettings settings 
)
private

Definition at line 678 of file fcdproplusinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getFcdProPlusSettings(), SWGSDRangel::SWGFCDProPlusSettings::getFileRecordName(), SWGSDRangel::SWGFCDProPlusSettings::getReverseApiAddress(), FCDProPlusSettings::m_biasT, FCDProPlusSettings::m_centerFrequency, FCDProPlusSettings::m_dcBlock, FCDProPlusSettings::m_fcPos, FCDProPlusSettings::m_fileRecordName, FCDProPlusSettings::m_ifFilterIndex, FCDProPlusSettings::m_ifGain, FCDProPlusSettings::m_iqImbalance, FCDProPlusSettings::m_lnaGain, FCDProPlusSettings::m_log2Decim, FCDProPlusSettings::m_LOppmTenths, FCDProPlusSettings::m_mixGain, FCDProPlusSettings::m_rangeLow, FCDProPlusSettings::m_reverseAPIAddress, FCDProPlusSettings::m_reverseAPIDeviceIndex, FCDProPlusSettings::m_reverseAPIPort, FCDProPlusSettings::m_rfFilterIndex, FCDProPlusSettings::m_transverterDeltaFrequency, FCDProPlusSettings::m_transverterMode, FCDProPlusSettings::m_useReverseAPI, SWGSDRangel::SWGFCDProPlusSettings::setBiasT(), SWGSDRangel::SWGFCDProPlusSettings::setCenterFrequency(), SWGSDRangel::SWGFCDProPlusSettings::setDcBlock(), SWGSDRangel::SWGFCDProPlusSettings::setFcPos(), SWGSDRangel::SWGFCDProPlusSettings::setFileRecordName(), SWGSDRangel::SWGFCDProPlusSettings::setIfFilterIndex(), SWGSDRangel::SWGFCDProPlusSettings::setIfGain(), SWGSDRangel::SWGFCDProPlusSettings::setIqImbalance(), SWGSDRangel::SWGFCDProPlusSettings::setLnaGain(), SWGSDRangel::SWGFCDProPlusSettings::setLog2Decim(), SWGSDRangel::SWGFCDProPlusSettings::setLOppmTenths(), SWGSDRangel::SWGFCDProPlusSettings::setMixGain(), SWGSDRangel::SWGFCDProPlusSettings::setRangeLow(), SWGSDRangel::SWGFCDProPlusSettings::setReverseApiAddress(), SWGSDRangel::SWGFCDProPlusSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGFCDProPlusSettings::setReverseApiPort(), SWGSDRangel::SWGFCDProPlusSettings::setRfFilterIndex(), SWGSDRangel::SWGFCDProPlusSettings::setTransverterDeltaFrequency(), SWGSDRangel::SWGFCDProPlusSettings::setTransverterMode(), and SWGSDRangel::SWGFCDProPlusSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

679 {
681  response.getFcdProPlusSettings()->setLog2Decim(settings.m_log2Decim);
682  response.getFcdProPlusSettings()->setFcPos((int) settings.m_fcPos);
683  response.getFcdProPlusSettings()->setRangeLow(settings.m_rangeLow ? 1 : 0);
684  response.getFcdProPlusSettings()->setLnaGain(settings.m_lnaGain ? 1 : 0);
685  response.getFcdProPlusSettings()->setMixGain(settings.m_mixGain ? 1 : 0);
686  response.getFcdProPlusSettings()->setBiasT(settings.m_biasT ? 1 : 0);
687  response.getFcdProPlusSettings()->setIfGain(settings.m_ifGain);
690  response.getFcdProPlusSettings()->setLOppmTenths(settings.m_LOppmTenths);
691  response.getFcdProPlusSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
692  response.getFcdProPlusSettings()->setIqImbalance(settings.m_iqImbalance ? 1 : 0);
694  response.getFcdProPlusSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
695 
696  if (response.getFcdProPlusSettings()->getFileRecordName()) {
697  *response.getFcdProPlusSettings()->getFileRecordName() = settings.m_fileRecordName;
698  } else {
699  response.getFcdProPlusSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
700  }
701 
702  response.getFcdProPlusSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
703 
704  if (response.getFcdProPlusSettings()->getReverseApiAddress()) {
706  } else {
707  response.getFcdProPlusSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
708  }
709 
712 }
void setRfFilterIndex(qint32 rf_filter_index)
void setReverseApiPort(qint32 reverse_api_port)
void setCenterFrequency(qint64 center_frequency)
void setIfFilterIndex(qint32 if_filter_index)
void setTransverterMode(qint32 transverter_mode)
void setFileRecordName(QString *file_record_name)
void setLOppmTenths(qint32 l_oppm_tenths)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
SWGFCDProPlusSettings * getFcdProPlusSettings()
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
void setUseReverseApi(qint32 use_reverse_api)
uint16_t m_reverseAPIDeviceIndex
void setReverseApiAddress(QString *reverse_api_address)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 714 of file fcdproplusinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getFcdProPlusSettings(), FCDProPlusSettings::m_biasT, FCDProPlusSettings::m_centerFrequency, FCDProPlusSettings::m_dcBlock, m_deviceAPI, FCDProPlusSettings::m_fcPos, FCDProPlusSettings::m_fileRecordName, FCDProPlusSettings::m_ifFilterIndex, FCDProPlusSettings::m_ifGain, FCDProPlusSettings::m_iqImbalance, FCDProPlusSettings::m_lnaGain, FCDProPlusSettings::m_log2Decim, FCDProPlusSettings::m_LOppmTenths, FCDProPlusSettings::m_mixGain, m_networkManager, m_networkRequest, FCDProPlusSettings::m_rangeLow, FCDProPlusSettings::m_reverseAPIAddress, FCDProPlusSettings::m_reverseAPIDeviceIndex, FCDProPlusSettings::m_reverseAPIPort, FCDProPlusSettings::m_rfFilterIndex, FCDProPlusSettings::m_transverterDeltaFrequency, FCDProPlusSettings::m_transverterMode, SWGSDRangel::SWGFCDProPlusSettings::setBiasT(), SWGSDRangel::SWGFCDProPlusSettings::setCenterFrequency(), SWGSDRangel::SWGFCDProPlusSettings::setDcBlock(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGDeviceSettings::setFcdProPlusSettings(), SWGSDRangel::SWGFCDProPlusSettings::setFcPos(), SWGSDRangel::SWGFCDProPlusSettings::setFileRecordName(), SWGSDRangel::SWGFCDProPlusSettings::setIfFilterIndex(), SWGSDRangel::SWGFCDProPlusSettings::setIfGain(), SWGSDRangel::SWGFCDProPlusSettings::setIqImbalance(), SWGSDRangel::SWGFCDProPlusSettings::setLnaGain(), SWGSDRangel::SWGFCDProPlusSettings::setLog2Decim(), SWGSDRangel::SWGFCDProPlusSettings::setLOppmTenths(), SWGSDRangel::SWGFCDProPlusSettings::setMixGain(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), SWGSDRangel::SWGFCDProPlusSettings::setRangeLow(), SWGSDRangel::SWGFCDProPlusSettings::setRfFilterIndex(), SWGSDRangel::SWGFCDProPlusSettings::setTransverterDeltaFrequency(), and SWGSDRangel::SWGFCDProPlusSettings::setTransverterMode().

Referenced by applySettings().

715 {
717  swgDeviceSettings->setDirection(0); // single Rx
718  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
719  swgDeviceSettings->setDeviceHwType(new QString("FCDPro+"));
721  SWGSDRangel::SWGFCDProPlusSettings *swgFCDProPlusSettings = swgDeviceSettings->getFcdProPlusSettings();
722 
723  // transfer data that has been modified. When force is on transfer all data except reverse API data
724 
725  if (deviceSettingsKeys.contains("centerFrequency") || force) {
726  swgFCDProPlusSettings->setCenterFrequency(settings.m_centerFrequency);
727  }
728  if (deviceSettingsKeys.contains("log2Decim") || force) {
729  swgFCDProPlusSettings->setLog2Decim(settings.m_log2Decim);
730  }
731  if (deviceSettingsKeys.contains("fcPos") || force) {
732  swgFCDProPlusSettings->setFcPos((int) settings.m_fcPos);
733  }
734  if (deviceSettingsKeys.contains("rangeLow") || force) {
735  swgFCDProPlusSettings->setRangeLow(settings.m_rangeLow ? 1 : 0);
736  }
737  if (deviceSettingsKeys.contains("lnaGain") || force) {
738  swgFCDProPlusSettings->setLnaGain(settings.m_lnaGain ? 1 : 0);
739  }
740  if (deviceSettingsKeys.contains("mixGain") || force) {
741  swgFCDProPlusSettings->setMixGain(settings.m_mixGain ? 1 : 0);
742  }
743  if (deviceSettingsKeys.contains("biasT") || force) {
744  swgFCDProPlusSettings->setBiasT(settings.m_biasT ? 1 : 0);
745  }
746  if (deviceSettingsKeys.contains("ifGain") || force) {
747  swgFCDProPlusSettings->setIfGain(settings.m_ifGain);
748  }
749  if (deviceSettingsKeys.contains("ifFilterIndex") || force) {
750  swgFCDProPlusSettings->setIfFilterIndex(settings.m_ifFilterIndex);
751  }
752  if (deviceSettingsKeys.contains("rfFilterIndex") || force) {
753  swgFCDProPlusSettings->setRfFilterIndex(settings.m_rfFilterIndex);
754  }
755  if (deviceSettingsKeys.contains("LOppmTenths") || force) {
756  swgFCDProPlusSettings->setLOppmTenths(settings.m_LOppmTenths);
757  }
758  if (deviceSettingsKeys.contains("dcBlock") || force) {
759  swgFCDProPlusSettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
760  }
761  if (deviceSettingsKeys.contains("iqImbalance") || force) {
762  swgFCDProPlusSettings->setIqImbalance(settings.m_iqImbalance ? 1 : 0);
763  }
764  if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
765  swgFCDProPlusSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
766  }
767  if (deviceSettingsKeys.contains("transverterMode") || force) {
768  swgFCDProPlusSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
769  }
770  if (deviceSettingsKeys.contains("fileRecordName") || force) {
771  swgFCDProPlusSettings->setFileRecordName(new QString(settings.m_fileRecordName));
772  }
773 
774  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
775  .arg(settings.m_reverseAPIAddress)
776  .arg(settings.m_reverseAPIPort)
777  .arg(settings.m_reverseAPIDeviceIndex);
778  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
779  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
780 
781  QBuffer *buffer=new QBuffer();
782  buffer->open((QBuffer::ReadWrite));
783  buffer->write(swgDeviceSettings->asJson().toUtf8());
784  buffer->seek(0);
785 
786  // Always use PATCH to avoid passing reverse API settings
787  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
788 
789  delete swgDeviceSettings;
790 }
void setRfFilterIndex(qint32 rf_filter_index)
virtual QString asJson() override
QNetworkAccessManager * m_networkManager
void setOriginatorIndex(qint32 originator_index)
DeviceAPI * m_deviceAPI
void setCenterFrequency(qint64 center_frequency)
void setIfFilterIndex(qint32 if_filter_index)
void setTransverterMode(qint32 transverter_mode)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setFileRecordName(QString *file_record_name)
void setLOppmTenths(qint32 l_oppm_tenths)
SWGFCDProPlusSettings * getFcdProPlusSettings()
QNetworkRequest m_networkRequest
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
void setFcdProPlusSettings(SWGFCDProPlusSettings *fcd_pro_plus_settings)
void setDirection(qint32 direction)
uint16_t m_reverseAPIDeviceIndex
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void FCDProPlusInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 792 of file fcdproplusinput.cpp.

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

Referenced by handleMessage().

793 {
795  swgDeviceSettings->setDirection(0); // single Rx
796  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
797  swgDeviceSettings->setDeviceHwType(new QString("FCDPro+"));
798 
799  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
803  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
804  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
805 
806  QBuffer *buffer=new QBuffer();
807  buffer->open((QBuffer::ReadWrite));
808  buffer->write(swgDeviceSettings->asJson().toUtf8());
809  buffer->seek(0);
810 
811  if (start) {
812  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
813  } else {
814  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
815  }
816 
817  delete swgDeviceSettings;
818 }
virtual QString asJson() override
QNetworkAccessManager * m_networkManager
void setOriginatorIndex(qint32 originator_index)
DeviceAPI * m_deviceAPI
int getDeviceSetIndex() const
Definition: deviceapi.h:131
virtual bool start()
QNetworkRequest m_networkRequest
FCDProPlusSettings m_settings
void setDirection(qint32 direction)
uint16_t m_reverseAPIDeviceIndex
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRun()

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

Reimplemented from DeviceSampleSource.

Definition at line 565 of file fcdproplusinput.cpp.

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

569 {
570  (void) errorMessage;
572  MsgStartStop *message = MsgStartStop::create(run);
573  m_inputMessageQueue.push(message);
574 
575  if (m_guiMessageQueue) // forward to GUI if any
576  {
577  MsgStartStop *msgToGUI = MsgStartStop::create(run);
578  m_guiMessageQueue->push(msgToGUI);
579  }
580 
581  return 200;
582 }
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)
+ Here is the call graph for this function:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 556 of file fcdproplusinput.cpp.

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

559 {
560  (void) errorMessage;
562  return 200;
563 }
DeviceAPI * m_deviceAPI
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 584 of file fcdproplusinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getFcdProPlusSettings(), SWGSDRangel::SWGFCDProPlusSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setFcdProPlusSettings(), and webapiFormatDeviceSettings().

587 {
588  (void) errorMessage;
590  response.getFcdProPlusSettings()->init();
592  return 200;
593 }
SWGFCDProPlusSettings * getFcdProPlusSettings()
FCDProPlusSettings m_settings
void setFcdProPlusSettings(SWGFCDProPlusSettings *fcd_pro_plus_settings)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const FCDProPlusSettings &settings)
+ Here is the call graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSource.

Definition at line 595 of file fcdproplusinput.cpp.

References FCDProPlusInput::MsgConfigureFCDProPlus::create(), SWGSDRangel::SWGFCDProPlusSettings::getBiasT(), SWGSDRangel::SWGFCDProPlusSettings::getCenterFrequency(), SWGSDRangel::SWGFCDProPlusSettings::getDcBlock(), SWGSDRangel::SWGDeviceSettings::getFcdProPlusSettings(), SWGSDRangel::SWGFCDProPlusSettings::getFcPos(), SWGSDRangel::SWGFCDProPlusSettings::getFileRecordName(), SWGSDRangel::SWGFCDProPlusSettings::getIfFilterIndex(), SWGSDRangel::SWGFCDProPlusSettings::getIfGain(), SWGSDRangel::SWGFCDProPlusSettings::getIqImbalance(), SWGSDRangel::SWGFCDProPlusSettings::getLnaGain(), SWGSDRangel::SWGFCDProPlusSettings::getLog2Decim(), SWGSDRangel::SWGFCDProPlusSettings::getLOppmTenths(), SWGSDRangel::SWGFCDProPlusSettings::getMixGain(), SWGSDRangel::SWGFCDProPlusSettings::getRangeLow(), SWGSDRangel::SWGFCDProPlusSettings::getReverseApiAddress(), SWGSDRangel::SWGFCDProPlusSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGFCDProPlusSettings::getReverseApiPort(), SWGSDRangel::SWGFCDProPlusSettings::getRfFilterIndex(), SWGSDRangel::SWGFCDProPlusSettings::getTransverterDeltaFrequency(), SWGSDRangel::SWGFCDProPlusSettings::getTransverterMode(), SWGSDRangel::SWGFCDProPlusSettings::getUseReverseApi(), FCDProPlusSettings::m_biasT, FCDProPlusSettings::m_centerFrequency, FCDProPlusSettings::m_dcBlock, FCDProPlusSettings::m_fcPos, FCDProPlusSettings::m_fileRecordName, DeviceSampleSource::m_guiMessageQueue, FCDProPlusSettings::m_ifFilterIndex, FCDProPlusSettings::m_ifGain, DeviceSampleSource::m_inputMessageQueue, FCDProPlusSettings::m_iqImbalance, FCDProPlusSettings::m_lnaGain, FCDProPlusSettings::m_log2Decim, FCDProPlusSettings::m_LOppmTenths, FCDProPlusSettings::m_mixGain, FCDProPlusSettings::m_rangeLow, FCDProPlusSettings::m_reverseAPIAddress, FCDProPlusSettings::m_reverseAPIDeviceIndex, FCDProPlusSettings::m_reverseAPIPort, FCDProPlusSettings::m_rfFilterIndex, m_settings, FCDProPlusSettings::m_transverterDeltaFrequency, FCDProPlusSettings::m_transverterMode, FCDProPlusSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatDeviceSettings().

600 {
601  (void) errorMessage;
602  FCDProPlusSettings settings = m_settings;
603 
604  if (deviceSettingsKeys.contains("centerFrequency")) {
606  }
607  if (deviceSettingsKeys.contains("log2Decim")) {
608  settings.m_log2Decim = response.getFcdProPlusSettings()->getLog2Decim();
609  }
610  if (deviceSettingsKeys.contains("fcPos")) {
612  }
613  if (deviceSettingsKeys.contains("rangeLow")) {
614  settings.m_rangeLow = response.getFcdProPlusSettings()->getRangeLow() != 0;
615  }
616  if (deviceSettingsKeys.contains("lnaGain")) {
617  settings.m_lnaGain = response.getFcdProPlusSettings()->getLnaGain() != 0;
618  }
619  if (deviceSettingsKeys.contains("mixGain")) {
620  settings.m_mixGain = response.getFcdProPlusSettings()->getMixGain() != 0;
621  }
622  if (deviceSettingsKeys.contains("biasT")) {
623  settings.m_biasT = response.getFcdProPlusSettings()->getBiasT() != 0;
624  }
625  if (deviceSettingsKeys.contains("ifGain")) {
626  settings.m_ifGain = response.getFcdProPlusSettings()->getIfGain();
627  }
628  if (deviceSettingsKeys.contains("ifFilterIndex")) {
629  settings.m_ifFilterIndex = response.getFcdProPlusSettings()->getIfFilterIndex();
630  }
631  if (deviceSettingsKeys.contains("rfFilterIndex")) {
632  settings.m_rfFilterIndex = response.getFcdProPlusSettings()->getRfFilterIndex();
633  }
634  if (deviceSettingsKeys.contains("LOppmTenths")) {
635  settings.m_LOppmTenths = response.getFcdProPlusSettings()->getLOppmTenths();
636  }
637  if (deviceSettingsKeys.contains("dcBlock")) {
638  settings.m_dcBlock = response.getFcdProPlusSettings()->getDcBlock() != 0;
639  }
640  if (deviceSettingsKeys.contains("iqImbalance")) {
641  settings.m_iqImbalance = response.getFcdProPlusSettings()->getIqImbalance() != 0;
642  }
643  if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
645  }
646  if (deviceSettingsKeys.contains("transverterMode")) {
647  settings.m_transverterMode = response.getFcdProPlusSettings()->getTransverterMode() != 0;
648  }
649  if (deviceSettingsKeys.contains("fileRecordName")) {
650  settings.m_fileRecordName = *response.getFcdProPlusSettings()->getFileRecordName();
651  }
652  if (deviceSettingsKeys.contains("useReverseAPI")) {
653  settings.m_useReverseAPI = response.getFcdProPlusSettings()->getUseReverseApi() != 0;
654  }
655  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
657  }
658  if (deviceSettingsKeys.contains("reverseAPIPort")) {
660  }
661  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
663  }
664 
665  MsgConfigureFCDProPlus *msg = MsgConfigureFCDProPlus::create(settings, force);
667 
668  if (m_guiMessageQueue) // forward to GUI if any
669  {
670  MsgConfigureFCDProPlus *msgToGUI = MsgConfigureFCDProPlus::create(settings, force);
671  m_guiMessageQueue->push(msgToGUI);
672  }
673 
674  webapiFormatDeviceSettings(response, settings);
675  return 200;
676 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgConfigureFCDProPlus * create(const FCDProPlusSettings &settings, bool force)
SWGFCDProPlusSettings * getFcdProPlusSettings()
FCDProPlusSettings m_settings
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const FCDProPlusSettings &settings)
uint16_t m_reverseAPIDeviceIndex
+ Here is the call graph for this function:

Member Data Documentation

◆ m_dev

hid_device* FCDProPlusInput::m_dev
private

◆ m_deviceAPI

DeviceAPI* FCDProPlusInput::m_deviceAPI
private

◆ m_deviceDescription

QString FCDProPlusInput::m_deviceDescription
private

Definition at line 164 of file fcdproplusinput.h.

Referenced by getDeviceDescription().

◆ m_fcdAudioInput

AudioInput FCDProPlusInput::m_fcdAudioInput
private

Definition at line 159 of file fcdproplusinput.h.

Referenced by closeFCDAudio(), and openFCDAudio().

◆ m_fcdFIFO

AudioFifo FCDProPlusInput::m_fcdFIFO
private

Definition at line 160 of file fcdproplusinput.h.

Referenced by closeFCDAudio(), openFCDAudio(), and start().

◆ m_FCDThread

FCDProPlusThread* FCDProPlusInput::m_FCDThread
private

Definition at line 163 of file fcdproplusinput.h.

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

◆ m_fileSink

FileRecord* FCDProPlusInput::m_fileSink
private

File sink to record device I/Q output.

Definition at line 166 of file fcdproplusinput.h.

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

◆ m_mutex

QMutex FCDProPlusInput::m_mutex
private

Definition at line 161 of file fcdproplusinput.h.

Referenced by stop().

◆ m_networkManager

QNetworkAccessManager* FCDProPlusInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest FCDProPlusInput::m_networkRequest
private

Definition at line 168 of file fcdproplusinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_running

bool FCDProPlusInput::m_running
private

Definition at line 165 of file fcdproplusinput.h.

Referenced by start(), stop(), and ~FCDProPlusInput().

◆ m_settings

FCDProPlusSettings FCDProPlusInput::m_settings
private

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