2015-09-02 21:57:54 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// FIXME: FCD is handled very badly!
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2017-12-14 12:15:27 -05:00
|
|
|
|
|
|
|
#include "SWGDeviceSettings.h"
|
|
|
|
#include "SWGDeviceState.h"
|
2016-05-12 17:35:30 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
#include "dsp/dspcommands.h"
|
2015-09-27 06:50:38 -04:00
|
|
|
#include "dsp/dspengine.h"
|
2017-09-04 17:35:57 -04:00
|
|
|
#include "dsp/filerecord.h"
|
2015-09-03 22:10:38 -04:00
|
|
|
#include "fcdproinput.h"
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
#include <device/devicesourceapi.h>
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
#include "fcdprogui.h"
|
|
|
|
#include "fcdprothread.h"
|
2015-09-04 23:50:29 -04:00
|
|
|
#include "fcdtraits.h"
|
2015-09-06 22:55:55 -04:00
|
|
|
#include "fcdproconst.h"
|
2015-09-03 22:10:38 -04:00
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgConfigureFCD, Message)
|
2017-12-14 12:02:49 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgStartStop, Message)
|
2017-09-04 17:35:57 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgFileRecord, Message)
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
FCDProInput::FCDProInput(DeviceSourceAPI *deviceAPI) :
|
2016-05-15 20:14:36 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2015-09-02 21:57:54 -04:00
|
|
|
m_dev(0),
|
|
|
|
m_settings(),
|
|
|
|
m_FCDThread(0),
|
2017-04-13 21:17:04 -04:00
|
|
|
m_deviceDescription(fcd_traits<Pro>::displayedName),
|
|
|
|
m_running(false)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-04-13 21:24:21 -04:00
|
|
|
openDevice();
|
2018-05-08 05:03:09 -04:00
|
|
|
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
2017-09-04 17:35:57 -04:00
|
|
|
m_deviceAPI->addSink(m_fileSink);
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
FCDProInput::~FCDProInput()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-04-13 21:24:21 -04:00
|
|
|
if (m_running) stop();
|
2017-09-04 17:35:57 -04:00
|
|
|
m_deviceAPI->removeSink(m_fileSink);
|
|
|
|
delete m_fileSink;
|
2017-04-13 21:24:21 -04:00
|
|
|
closeDevice();
|
|
|
|
}
|
|
|
|
|
2017-09-14 20:32:30 -04:00
|
|
|
void FCDProInput::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
bool FCDProInput::openDevice()
|
|
|
|
{
|
|
|
|
int device = m_deviceAPI->getSampleSourceSequence();
|
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
closeDevice();
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "FCDProInput::openDevice with device #" << device;
|
|
|
|
|
|
|
|
m_dev = fcdOpen(fcd_traits<Pro>::vendorId, fcd_traits<Pro>::productId, device);
|
|
|
|
|
|
|
|
if (m_dev == 0)
|
|
|
|
{
|
|
|
|
qCritical("FCDProInput::start: could not open FCD");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
void FCDProInput::init()
|
|
|
|
{
|
|
|
|
applySettings(m_settings, true);
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:40:45 -04:00
|
|
|
bool FCDProInput::start()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-04-13 21:24:21 -04:00
|
|
|
qDebug() << "FCDProInput::start";
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
if (!m_dev) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
if (m_running) stop();
|
2015-09-02 21:57:54 -04:00
|
|
|
|
|
|
|
/* Apply settings before streaming to avoid bus contention;
|
|
|
|
* there is very little spare bandwidth on a full speed USB device.
|
2015-09-03 02:39:57 -04:00
|
|
|
* Failure is harmless if no device is found
|
|
|
|
* ... This is rubbish...*/
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-03 02:39:57 -04:00
|
|
|
//applySettings(m_settings, true);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
|
|
|
if(!m_sampleFifo.setSize(96000*4))
|
|
|
|
{
|
|
|
|
qCritical("Could not allocate SampleFifo");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-24 04:29:27 -05:00
|
|
|
m_FCDThread = new FCDProThread(&m_sampleFifo);
|
2015-09-03 02:39:57 -04:00
|
|
|
m_FCDThread->startWork();
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
// mutexLocker.unlock();
|
2015-09-03 02:39:57 -04:00
|
|
|
applySettings(m_settings, true);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
qDebug("FCDProInput::started");
|
2017-04-13 21:24:21 -04:00
|
|
|
m_running = true;
|
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
void FCDProInput::closeDevice()
|
|
|
|
{
|
2017-04-17 06:00:13 -04:00
|
|
|
if (m_dev == 0) { // was never open
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
fcdClose(m_dev);
|
|
|
|
m_dev = 0;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProInput::stop()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-04-13 21:24:21 -04:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
|
|
|
if (m_FCDThread)
|
|
|
|
{
|
|
|
|
m_FCDThread->stopWork();
|
|
|
|
// wait for thread to quit ?
|
|
|
|
delete m_FCDThread;
|
|
|
|
m_FCDThread = 0;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
m_running = false;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
QByteArray FCDProInput::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FCDProInput::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgConfigureFCD* message = MsgConfigureFCD::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
|
|
|
MsgConfigureFCD* messageToGUI = MsgConfigureFCD::create(m_settings, true);
|
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
const QString& FCDProInput::getDeviceDescription() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
return m_deviceDescription;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
int FCDProInput::getSampleRate() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-04 23:50:29 -04:00
|
|
|
return fcd_traits<Pro>::sampleRate;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
quint64 FCDProInput::getCenterFrequency() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
return m_settings.m_centerFrequency;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
void FCDProInput::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
FCDProSettings settings = m_settings;
|
|
|
|
settings.m_centerFrequency = centerFrequency;
|
|
|
|
|
|
|
|
MsgConfigureFCD* message = MsgConfigureFCD::create(settings, false);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
|
|
|
MsgConfigureFCD* messageToGUI = MsgConfigureFCD::create(settings, false);
|
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
bool FCDProInput::handleMessage(const Message& message)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
if(MsgConfigureFCD::match(message))
|
|
|
|
{
|
2015-09-03 22:10:38 -04:00
|
|
|
qDebug() << "FCDProInput::handleMessage: MsgConfigureFCD";
|
2015-09-02 21:57:54 -04:00
|
|
|
MsgConfigureFCD& conf = (MsgConfigureFCD&) message;
|
2017-10-14 03:35:39 -04:00
|
|
|
applySettings(conf.getSettings(), conf.getForce());
|
2015-09-02 21:57:54 -04:00
|
|
|
return true;
|
|
|
|
}
|
2017-12-14 12:02:49 -05:00
|
|
|
else if (MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
MsgStartStop& cmd = (MsgStartStop&) message;
|
|
|
|
qDebug() << "FCDProInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
|
|
|
|
|
|
|
if (cmd.getStartStop())
|
|
|
|
{
|
|
|
|
if (m_deviceAPI->initAcquisition())
|
|
|
|
{
|
|
|
|
m_deviceAPI->startAcquisition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_deviceAPI->stopAcquisition();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-09-04 17:35:57 -04:00
|
|
|
else if (MsgFileRecord::match(message))
|
|
|
|
{
|
|
|
|
MsgFileRecord& conf = (MsgFileRecord&) message;
|
|
|
|
qDebug() << "FCDProInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
|
|
|
|
|
2018-05-09 11:39:48 -04:00
|
|
|
if (conf.getStartStop())
|
|
|
|
{
|
|
|
|
if (m_settings.m_fileRecordName.size() != 0) {
|
|
|
|
m_fileSink->setFileName(m_settings.m_fileRecordName);
|
|
|
|
} else {
|
|
|
|
m_fileSink->setFileName(QString("rec%1_%2.sdriq").arg(m_deviceAPI->getDeviceUID()).arg(QDateTime::currentDateTimeUtc().toString("yyyy-MM-ddThh:mm:ss")));
|
|
|
|
}
|
|
|
|
|
2017-09-04 17:35:57 -04:00
|
|
|
m_fileSink->startRecording();
|
2018-05-09 11:39:48 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-04 17:35:57 -04:00
|
|
|
m_fileSink->stopRecording();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
void FCDProInput::applySettings(const FCDProSettings& settings, bool force)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-12-24 05:05:16 -05:00
|
|
|
bool forwardChange = false;
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-09-25 14:16:25 -04:00
|
|
|
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
|
|
|
|
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
|
|
|
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency))
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-09-25 14:16:25 -04:00
|
|
|
qint64 deviceCenterFrequency = settings.m_centerFrequency;
|
|
|
|
deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
|
|
|
|
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-09-25 14:16:25 -04:00
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
set_center_freq((double) deviceCenterFrequency);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "FCDProInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz"
|
|
|
|
<< " device center freq: " << deviceCenterFrequency << " Hz";
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-12-24 05:05:16 -05:00
|
|
|
forwardChange = (m_settings.m_centerFrequency != settings.m_centerFrequency) || force;
|
|
|
|
|
2017-09-25 14:16:25 -04:00
|
|
|
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_lnaGainIndex != settings.m_lnaGainIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_lnaGainIndex = settings.m_lnaGainIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_lnaGain(settings.m_lnaGainIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_rfFilterIndex != settings.m_rfFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_rfFilterIndex = settings.m_rfFilterIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_rfFilter(settings.m_rfFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_lnaEnhanceIndex != settings.m_lnaEnhanceIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_lnaEnhanceIndex = settings.m_lnaEnhanceIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_lnaEnhance(settings.m_lnaEnhanceIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_bandIndex != settings.m_bandIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_bandIndex = settings.m_bandIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_band(settings.m_bandIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_mixerGainIndex != settings.m_mixerGainIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_mixerGainIndex = settings.m_mixerGainIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_mixerGain(settings.m_mixerGainIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_mixerFilterIndex != settings.m_mixerFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_mixerFilterIndex = settings.m_mixerFilterIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_mixerFilter(settings.m_mixerFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_biasCurrentIndex != settings.m_biasCurrentIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_biasCurrentIndex = settings.m_biasCurrentIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_biasCurrent(settings.m_biasCurrentIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_modeIndex != settings.m_modeIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_modeIndex = settings.m_modeIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_mode(settings.m_modeIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain1Index != settings.m_gain1Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_gain1Index = settings.m_gain1Index;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain1(settings.m_gain1Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_rcFilterIndex != settings.m_rcFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_rcFilterIndex = settings.m_rcFilterIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_rcFilter(settings.m_rcFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain2Index != settings.m_gain2Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_gain2Index = settings.m_gain2Index;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain2(settings.m_gain2Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain3Index != settings.m_gain3Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_gain3Index = settings.m_gain3Index;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain3(settings.m_gain3Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain4Index != settings.m_gain4Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_gain4Index = settings.m_gain4Index;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain4(settings.m_gain4Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_ifFilterIndex != settings.m_ifFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_ifFilterIndex = settings.m_ifFilterIndex;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_ifFilter(settings.m_ifFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain5Index != settings.m_gain5Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_gain5Index = settings.m_gain5Index;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain5(settings.m_gain5Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain6Index != settings.m_gain6Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_gain6Index = settings.m_gain6Index;
|
2015-09-06 23:35:01 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain6(settings.m_gain6Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
|
2015-09-07 19:27:18 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
m_settings.m_LOppmTenths = settings.m_LOppmTenths;
|
2015-09-07 19:27:18 -04:00
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
set_lo_ppm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
|
|
|
{
|
|
|
|
m_settings.m_dcBlock = settings.m_dcBlock;
|
2016-05-15 20:14:36 -04:00
|
|
|
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
|
2015-09-29 23:38:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
|
|
|
{
|
|
|
|
m_settings.m_iqCorrection = settings.m_iqCorrection;
|
2016-05-15 20:14:36 -04:00
|
|
|
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
|
2015-09-29 23:38:58 -04:00
|
|
|
}
|
|
|
|
|
2017-12-24 05:05:16 -05:00
|
|
|
if (forwardChange)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<Pro>::sampleRate, m_settings.m_centerFrequency);
|
2017-09-04 17:35:57 -04:00
|
|
|
m_fileSink->handleMessage(*notif); // forward to file sink
|
2017-09-13 17:40:06 -04:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProInput::set_center_freq(double freq)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
freq += freq*(((double) m_settings.m_LOppmTenths)/10000000.0);
|
2015-09-07 19:27:18 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
if (fcdAppSetFreq(m_dev, freq) == FCD_MODE_NONE)
|
|
|
|
{
|
|
|
|
qDebug("No FCD HID found for frquency change");
|
|
|
|
}
|
2015-09-07 19:27:18 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void FCDProInput::set_bias_t(bool on __attribute__((unused)))
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-05-25 14:13:34 -04:00
|
|
|
//quint8 cmd = on ? 1 : 0;
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-05 00:24:02 -04:00
|
|
|
// TODO: use FCD Pro controls
|
|
|
|
//fcdAppSetParam(m_dev, FCD_CMD_APP_SET_BIAS_TEE, &cmd, 1);
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
void FCDProInput::set_lnaGain(int index)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-06 22:55:55 -04:00
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_lna_gain_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
quint8 cmd_value = FCDProConstants::lna_gains[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_LNA_GAIN, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_lnaGain: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_rfFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_rf_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::rf_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_RF_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_rfFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_lnaEnhance(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_lna_enhance_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::lna_enhances[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_LNA_ENHANCE, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_lnaEnhance: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_band(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_band_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::bands[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_BAND, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_band: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_mixerGain(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_mixer_gain_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::mixer_gains[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_MIXER_GAIN, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_mixerGain: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_mixerFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_mixer_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::mixer_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_MIXER_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_mixerFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
void FCDProInput::set_biasCurrent(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_bias_current_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::bias_currents[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_BIAS_CURRENT, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_biasCurrent: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
void FCDProInput::set_mode(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain_mode_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gain_modes[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN_MODE, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_mode: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain1(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain1_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains1[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN1, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain1: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_rcFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_rc_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_rc_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_RC_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_rcFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain2(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain2_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains2[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN2, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain2: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain3(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain3_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains3[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN3, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain3: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain4(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain4_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains4[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN4, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain4: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_ifFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_ifFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain5(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain5_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains5[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN5, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain5: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain6(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain6_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains6[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN6, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain6: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
2015-09-07 19:27:18 -04:00
|
|
|
|
|
|
|
void FCDProInput::set_lo_ppm()
|
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
set_center_freq((double) m_settings.m_centerFrequency);
|
2015-09-07 19:27:18 -04:00
|
|
|
}
|
2017-12-14 12:15:27 -05:00
|
|
|
|
|
|
|
int FCDProInput::webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage __attribute__((unused)))
|
|
|
|
{
|
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FCDProInput::webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage __attribute__((unused)))
|
|
|
|
{
|
2017-12-14 17:29:12 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
2017-12-14 12:15:27 -05:00
|
|
|
MsgStartStop *message = MsgStartStop::create(run);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgStartStop *msgToGUI = MsgStartStop::create(run);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|