2017-04-17 20:12:15 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 //
|
2019-04-11 00:57:41 -04:00
|
|
|
// (at your option) any later version. //
|
2017-04-17 20:12:15 -04:00
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <string.h>
|
2018-12-18 17:37:26 -05:00
|
|
|
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
#include "lime/LimeSuite.h"
|
|
|
|
|
2017-12-08 09:11:16 -05:00
|
|
|
#include "SWGDeviceSettings.h"
|
|
|
|
#include "SWGLimeSdrInputSettings.h"
|
2017-12-09 19:57:50 -05:00
|
|
|
#include "SWGDeviceState.h"
|
2018-05-26 16:16:59 -04:00
|
|
|
#include "SWGDeviceReport.h"
|
|
|
|
#include "SWGLimeSdrInputReport.h"
|
2017-12-08 09:11:16 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2017-04-17 20:12:15 -04:00
|
|
|
#include "dsp/dspcommands.h"
|
2017-09-04 18:00:33 -04:00
|
|
|
#include "dsp/filerecord.h"
|
2017-12-09 19:57:50 -05:00
|
|
|
#include "dsp/dspengine.h"
|
2017-04-17 20:12:15 -04:00
|
|
|
#include "limesdrinput.h"
|
|
|
|
#include "limesdrinputthread.h"
|
|
|
|
#include "limesdr/devicelimesdrparam.h"
|
2017-04-22 21:36:10 -04:00
|
|
|
#include "limesdr/devicelimesdrshared.h"
|
2017-04-20 12:21:01 -04:00
|
|
|
#include "limesdr/devicelimesdr.h"
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgConfigureLimeSDR, Message)
|
2017-04-19 12:41:55 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetStreamInfo, Message)
|
2017-07-03 07:42:11 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetDeviceInfo, Message)
|
2017-04-19 12:41:55 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message)
|
2017-09-04 18:00:33 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgFileRecord, Message)
|
2017-12-14 12:02:49 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgStartStop, Message)
|
2017-04-17 20:12:15 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
LimeSDRInput::LimeSDRInput(DeviceAPI *deviceAPI) :
|
2017-04-17 20:12:15 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
|
|
|
m_settings(),
|
|
|
|
m_limeSDRInputThread(0),
|
2017-09-18 17:29:55 -04:00
|
|
|
m_deviceDescription("LimeSDRInput"),
|
2017-10-25 18:48:50 -04:00
|
|
|
m_running(false),
|
|
|
|
m_channelAcquired(false)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2017-04-20 17:32:08 -04:00
|
|
|
m_streamId.handle = 0;
|
2017-09-30 14:07:08 -04:00
|
|
|
suspendRxBuddies();
|
|
|
|
suspendTxBuddies();
|
2017-04-17 20:12:15 -04:00
|
|
|
openDevice();
|
2017-09-30 14:07:08 -04:00
|
|
|
resumeTxBuddies();
|
|
|
|
resumeRxBuddies();
|
2017-09-04 18:00:33 -04:00
|
|
|
|
2018-05-08 05:03:09 -04:00
|
|
|
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
2019-05-20 18:27:08 -04:00
|
|
|
m_deviceAPI->setNbSourceStreams(1);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->addAncillarySink(m_fileSink);
|
2018-12-18 17:37:26 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
|
|
|
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
LimeSDRInput::~LimeSDRInput()
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
|
|
|
delete m_networkManager;
|
|
|
|
|
|
|
|
if (m_running) {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->removeAncillarySink(m_fileSink);
|
2017-09-04 18:00:33 -04:00
|
|
|
delete m_fileSink;
|
2017-09-30 14:07:08 -04:00
|
|
|
suspendRxBuddies();
|
|
|
|
suspendTxBuddies();
|
2017-04-17 20:12:15 -04:00
|
|
|
closeDevice();
|
2017-09-30 14:07:08 -04:00
|
|
|
resumeTxBuddies();
|
|
|
|
resumeRxBuddies();
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2017-09-14 20:32:30 -04:00
|
|
|
void LimeSDRInput::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
bool LimeSDRInput::openDevice()
|
|
|
|
{
|
2017-04-18 16:22:21 -04:00
|
|
|
if (!m_sampleFifo.setSize(96000 * 4))
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::openDevice: could not allocate SampleFifo");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::openDevice: allocated SampleFifo");
|
|
|
|
}
|
|
|
|
|
2019-05-20 18:27:08 -04:00
|
|
|
int requestedChannel = m_deviceAPI->getDeviceItemIndex();
|
2017-11-02 05:30:07 -04:00
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
// look for Rx buddies and get reference to common parameters
|
|
|
|
// if there is a channel left take the first available
|
|
|
|
if (m_deviceAPI->getSourceBuddies().size() > 0) // look source sibling first
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qDebug("LimeSDRInput::openDevice: look in Rx buddies");
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0];
|
2018-01-07 18:19:12 -05:00
|
|
|
//m_deviceShared = *((DeviceLimeSDRShared *) sourceBuddy->getBuddySharedPtr()); // copy shared data
|
|
|
|
DeviceLimeSDRShared *deviceLimeSDRShared = (DeviceLimeSDRShared*) sourceBuddy->getBuddySharedPtr();
|
2018-09-23 13:56:24 -04:00
|
|
|
|
|
|
|
if (deviceLimeSDRShared == 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::openDevice: the source buddy shared pointer is null");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-07 18:19:12 -05:00
|
|
|
m_deviceShared.m_deviceParams = deviceLimeSDRShared->m_deviceParams;
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
DeviceLimeSDRParams *deviceParams = m_deviceShared.m_deviceParams; // get device parameters
|
|
|
|
|
|
|
|
if (deviceParams == 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::openDevice: cannot get device parameters from Rx buddy");
|
|
|
|
return false; // the device params should have been created by the buddy
|
|
|
|
}
|
2017-04-18 19:04:57 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::openDevice: getting device parameters from Rx buddy");
|
|
|
|
}
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
if (m_deviceAPI->getSourceBuddies().size() == deviceParams->m_nbRxChannels)
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qCritical("LimeSDRInput::openDevice: no more Rx channels available in device");
|
2017-04-17 20:12:15 -04:00
|
|
|
return false; // no more Rx channels available in device
|
|
|
|
}
|
2017-04-18 19:04:57 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::openDevice: at least one more Rx channel is available in device");
|
|
|
|
}
|
|
|
|
|
2017-11-02 05:30:07 -04:00
|
|
|
// check if the requested channel is busy and abort if so (should not happen if device management is working correctly)
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
for (unsigned int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[i];
|
2017-04-17 20:12:15 -04:00
|
|
|
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
|
2017-08-13 21:32:51 -04:00
|
|
|
|
2017-11-02 05:30:07 -04:00
|
|
|
if (buddyShared->m_channel == requestedChannel)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::openDevice: cannot open busy channel %u", requestedChannel);
|
|
|
|
return false;
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-02 05:30:07 -04:00
|
|
|
m_deviceShared.m_channel = requestedChannel; // acknowledge the requested channel
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
// look for Tx buddies and get reference to common parameters
|
|
|
|
// take the first Rx channel
|
|
|
|
else if (m_deviceAPI->getSinkBuddies().size() > 0) // then sink
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qDebug("LimeSDRInput::openDevice: look in Tx buddies");
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
|
2018-01-07 18:19:12 -05:00
|
|
|
//m_deviceShared = *((DeviceLimeSDRShared *) sinkBuddy->getBuddySharedPtr()); // copy parameters
|
|
|
|
DeviceLimeSDRShared *deviceLimeSDRShared = (DeviceLimeSDRShared*) sinkBuddy->getBuddySharedPtr();
|
2018-09-23 13:56:24 -04:00
|
|
|
|
|
|
|
if (deviceLimeSDRShared == 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::openDevice: the sink buddy shared pointer is null");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-07 18:19:12 -05:00
|
|
|
m_deviceShared.m_deviceParams = deviceLimeSDRShared->m_deviceParams;
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
if (m_deviceShared.m_deviceParams == 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::openDevice: cannot get device parameters from Tx buddy");
|
|
|
|
return false; // the device params should have been created by the buddy
|
|
|
|
}
|
2017-04-18 19:04:57 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::openDevice: getting device parameters from Tx buddy");
|
|
|
|
}
|
2017-04-17 20:12:15 -04:00
|
|
|
|
2017-11-02 05:30:07 -04:00
|
|
|
m_deviceShared.m_channel = requestedChannel; // acknowledge the requested channel
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
// There are no buddies then create the first LimeSDR common parameters
|
|
|
|
// open the device this will also populate common fields
|
|
|
|
// take the first Rx channel
|
|
|
|
else
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qDebug("LimeSDRInput::openDevice: open device here");
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
m_deviceShared.m_deviceParams = new DeviceLimeSDRParams();
|
|
|
|
char serial[256];
|
2019-05-08 16:11:53 -04:00
|
|
|
strcpy(serial, qPrintable(m_deviceAPI->getSamplingDeviceSerial()));
|
2017-04-17 20:12:15 -04:00
|
|
|
m_deviceShared.m_deviceParams->open(serial);
|
2017-11-02 05:30:07 -04:00
|
|
|
m_deviceShared.m_channel = requestedChannel; // acknowledge the requested channel
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
|
|
|
|
|
2017-04-22 22:01:00 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
void LimeSDRInput::suspendRxBuddies()
|
2017-04-22 22:01:00 -04:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2017-04-19 19:39:05 -04:00
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
qDebug("LimeSDRInput::suspendRxBuddies (%lu)", sourceBuddies.size());
|
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
2017-04-19 19:39:05 -04:00
|
|
|
{
|
2017-09-30 14:07:08 -04:00
|
|
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
2017-04-19 19:39:05 -04:00
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
if (buddySharedPtr->m_thread && buddySharedPtr->m_thread->isRunning())
|
|
|
|
{
|
|
|
|
buddySharedPtr->m_thread->stopWork();
|
|
|
|
buddySharedPtr->m_threadWasRunning = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buddySharedPtr->m_threadWasRunning = false;
|
2017-04-19 19:39:05 -04:00
|
|
|
}
|
|
|
|
}
|
2017-09-30 14:07:08 -04:00
|
|
|
}
|
2017-04-19 19:39:05 -04:00
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
void LimeSDRInput::suspendTxBuddies()
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
|
2017-04-17 20:12:15 -04:00
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
qDebug("LimeSDRInput::suspendTxBuddies (%lu)", sinkBuddies.size());
|
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
2017-04-22 22:01:00 -04:00
|
|
|
{
|
2017-09-30 14:07:08 -04:00
|
|
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
2017-04-22 22:01:00 -04:00
|
|
|
|
2018-01-07 18:19:12 -05:00
|
|
|
if ((buddySharedPtr->m_thread) && buddySharedPtr->m_thread->isRunning())
|
|
|
|
{
|
2017-09-30 14:07:08 -04:00
|
|
|
buddySharedPtr->m_thread->stopWork();
|
|
|
|
buddySharedPtr->m_threadWasRunning = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buddySharedPtr->m_threadWasRunning = false;
|
2017-04-22 22:01:00 -04:00
|
|
|
}
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
2017-04-22 22:01:00 -04:00
|
|
|
}
|
2017-04-17 20:12:15 -04:00
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
void LimeSDRInput::resumeRxBuddies()
|
2017-04-22 22:01:00 -04:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2017-04-19 19:39:05 -04:00
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
qDebug("LimeSDRInput::resumeRxBuddies (%lu)", sourceBuddies.size());
|
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
2017-04-19 19:39:05 -04:00
|
|
|
{
|
2017-09-30 14:07:08 -04:00
|
|
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
2017-04-19 19:39:05 -04:00
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
if (buddySharedPtr->m_threadWasRunning) {
|
|
|
|
buddySharedPtr->m_thread->startWork();
|
2017-04-19 19:39:05 -04:00
|
|
|
}
|
|
|
|
}
|
2017-09-30 14:07:08 -04:00
|
|
|
}
|
2017-04-19 19:39:05 -04:00
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
void LimeSDRInput::resumeTxBuddies()
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
|
2017-04-22 22:01:00 -04:00
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
qDebug("LimeSDRInput::resumeTxBuddies (%lu)", sinkBuddies.size());
|
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
2017-04-22 22:01:00 -04:00
|
|
|
{
|
2017-09-30 14:07:08 -04:00
|
|
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
2017-04-22 22:01:00 -04:00
|
|
|
|
2017-09-30 14:07:08 -04:00
|
|
|
if (buddySharedPtr->m_threadWasRunning) {
|
|
|
|
buddySharedPtr->m_thread->startWork();
|
2017-04-22 22:01:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInput::closeDevice()
|
|
|
|
{
|
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() == 0) { // was never open
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-30 13:05:16 -04:00
|
|
|
if (m_running) { stop(); }
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
m_deviceShared.m_channel = -1;
|
|
|
|
|
|
|
|
// No buddies so effectively close the device
|
|
|
|
|
|
|
|
if ((m_deviceAPI->getSinkBuddies().size() == 0) && (m_deviceAPI->getSourceBuddies().size() == 0))
|
|
|
|
{
|
|
|
|
m_deviceShared.m_deviceParams->close();
|
|
|
|
delete m_deviceShared.m_deviceParams;
|
|
|
|
m_deviceShared.m_deviceParams = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
bool LimeSDRInput::acquireChannel()
|
|
|
|
{
|
|
|
|
suspendRxBuddies();
|
|
|
|
suspendTxBuddies();
|
|
|
|
|
|
|
|
// acquire the channel
|
|
|
|
|
|
|
|
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, true) != 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::acquireChannel: cannot enable Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::acquireChannel: Rx channel %d enabled", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set up the stream
|
|
|
|
|
|
|
|
m_streamId.channel = m_deviceShared.m_channel; // channel number
|
|
|
|
m_streamId.fifoSize = 1024 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
|
|
|
|
m_streamId.throughputVsLatency = 0.5; // optimize for min latency
|
|
|
|
m_streamId.isTx = false; // RX channel
|
|
|
|
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
|
|
|
|
|
|
|
|
if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::acquireChannel: cannot setup the stream on Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
resumeTxBuddies();
|
|
|
|
resumeRxBuddies();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::acquireChannel: stream set up on Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
resumeTxBuddies();
|
|
|
|
resumeRxBuddies();
|
|
|
|
|
|
|
|
m_channelAcquired = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInput::releaseChannel()
|
|
|
|
{
|
|
|
|
suspendRxBuddies();
|
|
|
|
suspendTxBuddies();
|
|
|
|
|
|
|
|
// destroy the stream
|
|
|
|
if (LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
|
|
|
{
|
|
|
|
qWarning("LimeSDRInput::releaseChannel: cannot destroy the stream on Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::releaseChannel: stream destroyed on Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_streamId.handle = 0;
|
|
|
|
|
|
|
|
// release the channel
|
|
|
|
|
|
|
|
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0)
|
|
|
|
{
|
|
|
|
qWarning("LimeSDRInput::releaseChannel: cannot disable Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::releaseChannel: Rx channel %d disabled", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
resumeTxBuddies();
|
|
|
|
resumeRxBuddies();
|
|
|
|
|
2017-11-02 05:30:07 -04:00
|
|
|
// The channel will be effectively released to be reused in another device set only at close time
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
m_channelAcquired = false;
|
|
|
|
}
|
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
void LimeSDRInput::init()
|
|
|
|
{
|
|
|
|
applySettings(m_settings, true, false);
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
bool LimeSDRInput::start()
|
|
|
|
{
|
|
|
|
if (!m_deviceShared.m_deviceParams->getDevice()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-30 13:05:16 -04:00
|
|
|
if (m_running) { stop(); }
|
2017-04-17 20:12:15 -04:00
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (!acquireChannel())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
// start / stop streaming is done in the thread.
|
|
|
|
|
2018-02-24 04:29:27 -05:00
|
|
|
m_limeSDRInputThread = new LimeSDRInputThread(&m_streamId, &m_sampleFifo);
|
|
|
|
qDebug("LimeSDRInput::start: thread created");
|
|
|
|
|
|
|
|
applySettings(m_settings, true);
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim);
|
|
|
|
|
|
|
|
m_limeSDRInputThread->startWork();
|
|
|
|
|
2017-04-22 04:40:57 -04:00
|
|
|
m_deviceShared.m_thread = m_limeSDRInputThread;
|
2017-04-17 20:12:15 -04:00
|
|
|
m_running = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInput::stop()
|
|
|
|
{
|
2017-10-25 18:48:50 -04:00
|
|
|
qDebug("LimeSDRInput::stop");
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
if (m_limeSDRInputThread != 0)
|
|
|
|
{
|
|
|
|
m_limeSDRInputThread->stopWork();
|
|
|
|
delete m_limeSDRInputThread;
|
|
|
|
m_limeSDRInputThread = 0;
|
|
|
|
}
|
|
|
|
|
2017-04-19 18:01:11 -04:00
|
|
|
m_deviceShared.m_thread = 0;
|
2017-04-17 20:12:15 -04:00
|
|
|
m_running = false;
|
2017-10-25 18:48:50 -04:00
|
|
|
|
|
|
|
releaseChannel();
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
QByteArray LimeSDRInput::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LimeSDRInput::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgConfigureLimeSDR* message = MsgConfigureLimeSDR::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
|
|
|
MsgConfigureLimeSDR* messageToGUI = MsgConfigureLimeSDR::create(m_settings, true);
|
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
const QString& LimeSDRInput::getDeviceDescription() const
|
|
|
|
{
|
|
|
|
return m_deviceDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
int LimeSDRInput::getSampleRate() const
|
|
|
|
{
|
|
|
|
int rate = m_settings.m_devSampleRate;
|
2017-04-18 18:00:47 -04:00
|
|
|
return (rate / (1<<m_settings.m_log2SoftDecim));
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
quint64 LimeSDRInput::getCenterFrequency() const
|
|
|
|
{
|
2018-03-29 06:15:33 -04:00
|
|
|
return m_settings.m_centerFrequency + (m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
void LimeSDRInput::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
LimeSDRInputSettings settings = m_settings;
|
2018-03-29 06:15:33 -04:00
|
|
|
settings.m_centerFrequency = centerFrequency - (m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0);
|
2017-12-27 21:21:48 -05:00
|
|
|
|
|
|
|
MsgConfigureLimeSDR* message = MsgConfigureLimeSDR::create(settings, false);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
|
|
|
MsgConfigureLimeSDR* messageToGUI = MsgConfigureLimeSDR::create(settings, false);
|
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
std::size_t LimeSDRInput::getChannelIndex()
|
|
|
|
{
|
|
|
|
return m_deviceShared.m_channel;
|
|
|
|
}
|
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
void LimeSDRInput::getLORange(float& minF, float& maxF) const
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
lms_range_t range = m_deviceShared.m_deviceParams->m_loRangeRx;
|
|
|
|
minF = range.min;
|
|
|
|
maxF = range.max;
|
2018-03-14 06:03:22 -04:00
|
|
|
qDebug("LimeSDRInput::getLORange: min: %f max: %f", range.min, range.max);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
void LimeSDRInput::getSRRange(float& minF, float& maxF) const
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
lms_range_t range = m_deviceShared.m_deviceParams->m_srRangeRx;
|
|
|
|
minF = range.min;
|
|
|
|
maxF = range.max;
|
2018-03-14 06:03:22 -04:00
|
|
|
qDebug("LimeSDRInput::getSRRange: min: %f max: %f", range.min, range.max);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
void LimeSDRInput::getLPRange(float& minF, float& maxF) const
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx;
|
|
|
|
minF = range.min;
|
|
|
|
maxF = range.max;
|
2018-03-14 06:03:22 -04:00
|
|
|
qDebug("LimeSDRInput::getLPRange: min: %f max: %f", range.min, range.max);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t LimeSDRInput::getHWLog2Decim() const
|
|
|
|
{
|
|
|
|
return m_deviceShared.m_deviceParams->m_log2OvSRRx;
|
|
|
|
}
|
|
|
|
|
2019-04-20 19:06:23 -04:00
|
|
|
DeviceLimeSDRParams::LimeType LimeSDRInput::getLimeType() const
|
|
|
|
{
|
|
|
|
if (m_deviceShared.m_deviceParams) {
|
|
|
|
return m_deviceShared.m_deviceParams->m_type;
|
|
|
|
} else {
|
|
|
|
return DeviceLimeSDRParams::LimeUndefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
bool LimeSDRInput::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (MsgConfigureLimeSDR::match(message))
|
|
|
|
{
|
|
|
|
MsgConfigureLimeSDR& conf = (MsgConfigureLimeSDR&) message;
|
|
|
|
qDebug() << "LimeSDRInput::handleMessage: MsgConfigureLimeSDR";
|
|
|
|
|
2017-10-14 00:48:09 -04:00
|
|
|
if (!applySettings(conf.getSettings(), conf.getForce()))
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::handleMessage config error");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-24 19:38:39 -04:00
|
|
|
else if (DeviceLimeSDRShared::MsgReportBuddyChange::match(message))
|
2017-10-23 20:20:57 -04:00
|
|
|
{
|
2017-10-24 19:38:39 -04:00
|
|
|
DeviceLimeSDRShared::MsgReportBuddyChange& report = (DeviceLimeSDRShared::MsgReportBuddyChange&) message;
|
2017-10-23 20:20:57 -04:00
|
|
|
|
|
|
|
if (report.getRxElseTx())
|
|
|
|
{
|
2017-10-24 19:38:39 -04:00
|
|
|
m_settings.m_devSampleRate = report.getDevSampleRate();
|
|
|
|
m_settings.m_log2HardDecim = report.getLog2HardDecimInterp();
|
|
|
|
m_settings.m_centerFrequency = report.getCenterFrequency();
|
2017-10-23 20:20:57 -04:00
|
|
|
}
|
2018-01-07 19:15:17 -05:00
|
|
|
else if (m_running)
|
2017-10-23 20:20:57 -04:00
|
|
|
{
|
2017-10-25 19:47:43 -04:00
|
|
|
double host_Hz;
|
|
|
|
double rf_Hz;
|
|
|
|
|
|
|
|
if (LMS_GetSampleRate(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
|
|
|
&host_Hz,
|
|
|
|
&rf_Hz) < 0)
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::handleMessage: MsgReportBuddyChange: LMS_GetSampleRate() failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.m_devSampleRate = roundf(host_Hz);
|
|
|
|
int hard = roundf(rf_Hz) / m_settings.m_devSampleRate;
|
|
|
|
m_settings.m_log2HardDecim = log2(hard);
|
|
|
|
|
|
|
|
qDebug() << "LimeSDRInput::handleMessage: MsgReportBuddyChange:"
|
|
|
|
<< " host_Hz: " << host_Hz
|
|
|
|
<< " rf_Hz: " << rf_Hz
|
|
|
|
<< " m_devSampleRate: " << m_settings.m_devSampleRate
|
|
|
|
<< " log2Hard: " << hard
|
|
|
|
<< " m_log2HardDecim: " << m_settings.m_log2HardDecim;
|
|
|
|
// int adcdac_rate = report.getDevSampleRate() * (1<<report.getLog2HardDecimInterp());
|
|
|
|
// m_settings.m_devSampleRate = adcdac_rate / (1<<m_settings.m_log2HardDecim); // new device to host sample rate
|
|
|
|
}
|
2017-10-23 20:20:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_settings.m_ncoEnable) // need to reset NCO after sample rate change
|
|
|
|
{
|
|
|
|
applySettings(m_settings, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0;
|
|
|
|
|
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(
|
|
|
|
m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim),
|
|
|
|
m_settings.m_centerFrequency + ncoShift);
|
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
|
|
|
|
2018-09-24 02:43:16 -04:00
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportBuddyChange *reportToGUI = DeviceLimeSDRShared::MsgReportBuddyChange::create(
|
|
|
|
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
|
|
|
|
getMessageQueueToGUI()->push(reportToGUI);
|
|
|
|
}
|
2017-10-23 20:20:57 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-11-03 21:18:16 -04:00
|
|
|
else if (DeviceLimeSDRShared::MsgReportClockSourceChange::match(message))
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportClockSourceChange& report = (DeviceLimeSDRShared::MsgReportClockSourceChange&) message;
|
|
|
|
|
|
|
|
m_settings.m_extClock = report.getExtClock();
|
|
|
|
m_settings.m_extClockFreq = report.getExtClockFeq();
|
|
|
|
|
2018-09-24 02:43:16 -04:00
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportClockSourceChange *reportToGUI = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
|
|
|
|
m_settings.m_extClock, m_settings.m_extClockFreq);
|
|
|
|
getMessageQueueToGUI()->push(reportToGUI);
|
|
|
|
}
|
2017-11-03 21:18:16 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-28 19:21:44 -05:00
|
|
|
else if (DeviceLimeSDRShared::MsgReportGPIOChange::match(message))
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportGPIOChange& report = (DeviceLimeSDRShared::MsgReportGPIOChange&) message;
|
|
|
|
|
|
|
|
m_settings.m_gpioDir = report.getGPIODir();
|
|
|
|
m_settings.m_gpioPins = report.getGPIOPins();
|
|
|
|
|
|
|
|
// no GUI for the moment only REST API
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-04-19 12:41:55 -04:00
|
|
|
else if (MsgGetStreamInfo::match(message))
|
|
|
|
{
|
2017-04-19 18:48:00 -04:00
|
|
|
// qDebug() << "LimeSDRInput::handleMessage: MsgGetStreamInfo";
|
2017-04-19 12:41:55 -04:00
|
|
|
lms_stream_status_t status;
|
|
|
|
|
2017-04-20 18:14:55 -04:00
|
|
|
if (m_streamId.handle && (LMS_GetStreamStatus(&m_streamId, &status) == 0))
|
2017-04-19 12:41:55 -04:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if (m_deviceAPI->getSamplingDeviceGUIMessageQueue())
|
2017-09-17 11:35:03 -04:00
|
|
|
{
|
|
|
|
MsgReportStreamInfo *report = MsgReportStreamInfo::create(
|
|
|
|
true, // Success
|
|
|
|
status.active,
|
|
|
|
status.fifoFilledCount,
|
|
|
|
status.fifoSize,
|
|
|
|
status.underrun,
|
|
|
|
status.overrun,
|
|
|
|
status.droppedPackets,
|
|
|
|
status.linkRate,
|
|
|
|
status.timestamp);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->getSamplingDeviceGUIMessageQueue()->push(report);
|
2017-09-17 11:35:03 -04:00
|
|
|
}
|
2017-04-19 12:41:55 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if (m_deviceAPI->getSamplingDeviceGUIMessageQueue())
|
2017-09-17 11:35:03 -04:00
|
|
|
{
|
|
|
|
MsgReportStreamInfo *report = MsgReportStreamInfo::create(
|
|
|
|
false, // Success
|
|
|
|
false, // status.active,
|
|
|
|
0, // status.fifoFilledCount,
|
|
|
|
16384, // status.fifoSize,
|
|
|
|
0, // status.underrun,
|
|
|
|
0, // status.overrun,
|
|
|
|
0, // status.droppedPackets,
|
|
|
|
0, // status.linkRate,
|
|
|
|
0); // status.timestamp);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->getSamplingDeviceGUIMessageQueue()->push(report);
|
2017-09-17 11:35:03 -04:00
|
|
|
}
|
2017-04-19 12:41:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-07-03 07:42:11 -04:00
|
|
|
else if (MsgGetDeviceInfo::match(message))
|
|
|
|
{
|
2017-07-03 17:26:06 -04:00
|
|
|
double temp = 0.0;
|
2018-11-29 17:37:34 -05:00
|
|
|
uint8_t gpioPins = 0;
|
2017-07-03 17:26:06 -04:00
|
|
|
|
2018-11-29 07:57:04 -05:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GetChipTemperature(m_deviceShared.m_deviceParams->getDevice(), 0, &temp) != 0)) {
|
2018-11-29 17:37:34 -05:00
|
|
|
qDebug("LimeSDRInput::handleMessage: MsgGetDeviceInfo: cannot get temperature");
|
2017-07-03 17:26:06 -04:00
|
|
|
}
|
2018-11-29 07:57:04 -05:00
|
|
|
|
2018-11-29 17:37:34 -05:00
|
|
|
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
|
|
|
|
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
|
|
|
|
{
|
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GPIORead(m_deviceShared.m_deviceParams->getDevice(), &gpioPins, 1) != 0)) {
|
|
|
|
qDebug("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get GPIO pins values");
|
|
|
|
}
|
2017-07-03 17:26:06 -04:00
|
|
|
}
|
2017-07-03 07:42:11 -04:00
|
|
|
|
2017-07-03 17:26:06 -04:00
|
|
|
// send to oneself
|
2019-05-08 16:11:53 -04:00
|
|
|
if (m_deviceAPI->getSamplingDeviceGUIMessageQueue())
|
2018-11-29 07:57:04 -05:00
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportDeviceInfo *report = DeviceLimeSDRShared::MsgReportDeviceInfo::create(temp, gpioPins);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->getSamplingDeviceGUIMessageQueue()->push(report);
|
2017-09-17 11:35:03 -04:00
|
|
|
}
|
2017-07-03 07:42:11 -04:00
|
|
|
|
2017-07-03 17:26:06 -04:00
|
|
|
// send to source buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2017-07-03 07:42:11 -04:00
|
|
|
|
2017-07-03 17:26:06 -04:00
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if ((*itSource)->getSamplingDeviceGUIMessageQueue())
|
2017-09-17 11:35:03 -04:00
|
|
|
{
|
2018-11-29 07:57:04 -05:00
|
|
|
DeviceLimeSDRShared::MsgReportDeviceInfo *report = DeviceLimeSDRShared::MsgReportDeviceInfo::create(temp, gpioPins);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSource)->getSamplingDeviceGUIMessageQueue()->push(report);
|
2017-09-17 11:35:03 -04:00
|
|
|
}
|
2017-07-03 17:26:06 -04:00
|
|
|
}
|
2017-07-03 07:42:11 -04:00
|
|
|
|
2017-07-03 17:26:06 -04:00
|
|
|
// send to sink buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
|
2017-07-03 07:42:11 -04:00
|
|
|
|
2017-07-03 17:26:06 -04:00
|
|
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if ((*itSink)->getSamplingDeviceGUIMessageQueue())
|
2017-09-17 11:35:03 -04:00
|
|
|
{
|
2018-11-29 07:57:04 -05:00
|
|
|
DeviceLimeSDRShared::MsgReportDeviceInfo *report = DeviceLimeSDRShared::MsgReportDeviceInfo::create(temp, gpioPins);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSink)->getSamplingDeviceGUIMessageQueue()->push(report);
|
2017-09-17 11:35:03 -04:00
|
|
|
}
|
2017-07-03 07:42:11 -04:00
|
|
|
}
|
2017-07-03 16:35:08 -04:00
|
|
|
|
|
|
|
return true;
|
2017-07-03 07:42:11 -04:00
|
|
|
}
|
2017-09-04 18:00:33 -04:00
|
|
|
else if (MsgFileRecord::match(message))
|
|
|
|
{
|
|
|
|
MsgFileRecord& conf = (MsgFileRecord&) message;
|
|
|
|
qDebug() << "LimeSDRInput::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 {
|
2018-05-11 03:08:20 -04:00
|
|
|
m_fileSink->genUniqueFileName(m_deviceAPI->getDeviceUID());
|
2018-05-09 11:39:48 -04:00
|
|
|
}
|
|
|
|
|
2017-09-04 18:00:33 -04:00
|
|
|
m_fileSink->startRecording();
|
2018-05-09 11:39:48 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-04 18:00:33 -04:00
|
|
|
m_fileSink->stopRecording();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-14 12:02:49 -05:00
|
|
|
else if (MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
MsgStartStop& cmd = (MsgStartStop&) message;
|
|
|
|
qDebug() << "LimeSDRInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
|
|
|
|
|
|
|
if (cmd.getStartStop())
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if (m_deviceAPI->initDeviceEngine())
|
2017-12-14 12:02:49 -05:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->startDeviceEngine();
|
2017-12-14 12:02:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->stopDeviceEngine();
|
2017-12-14 12:02:49 -05:00
|
|
|
}
|
|
|
|
|
2018-12-18 17:37:26 -05:00
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendStartStop(cmd.getStartStop());
|
|
|
|
}
|
|
|
|
|
2017-12-14 12:02:49 -05:00
|
|
|
return true;
|
|
|
|
}
|
2017-04-17 20:12:15 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-23 20:20:57 -04:00
|
|
|
bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool force, bool forceNCOFrequency)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
bool forwardChangeOwnDSP = false;
|
|
|
|
bool forwardChangeRxDSP = false;
|
|
|
|
bool forwardChangeAllDSP = false;
|
2017-11-03 21:18:16 -04:00
|
|
|
bool forwardClockSource = false;
|
2018-11-28 19:21:44 -05:00
|
|
|
bool forwardGPIOChange = false;
|
2017-08-13 21:32:51 -04:00
|
|
|
bool ownThreadWasRunning = false;
|
2017-04-18 07:50:28 -04:00
|
|
|
bool doCalibration = false;
|
2017-11-09 11:31:32 -05:00
|
|
|
bool doLPCalibration = false;
|
2017-04-23 10:23:01 -04:00
|
|
|
bool setAntennaAuto = false;
|
2017-10-26 17:57:56 -04:00
|
|
|
double clockGenFreq = 0.0;
|
2018-12-18 17:37:26 -05:00
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
|
2018-04-16 18:25:19 -04:00
|
|
|
qint64 deviceCenterFrequency = settings.m_centerFrequency;
|
|
|
|
deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
|
|
|
|
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
|
|
|
|
|
2017-10-26 17:57:56 -04:00
|
|
|
if (LMS_GetClockFreq(m_deviceShared.m_deviceParams->getDevice(), LMS_CLOCK_CGEN, &clockGenFreq) != 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could not get clock gen frequency");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "LimeSDRInput::applySettings: clock gen frequency: " << clockGenFreq;
|
|
|
|
}
|
|
|
|
|
2017-04-19 18:01:11 -04:00
|
|
|
// apply settings
|
2017-04-19 02:34:27 -04:00
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("dcBlock");
|
2017-10-26 17:57:56 -04:00
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("iqCorrection");
|
2017-10-26 17:57:56 -04:00
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2017-07-04 18:45:37 -04:00
|
|
|
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("gainMode");
|
|
|
|
|
2017-10-26 17:57:56 -04:00
|
|
|
if (settings.m_gainMode == LimeSDRInputSettings::GAIN_AUTO)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
|
|
|
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_gain) < 0)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: LMS_SetGaindB() failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: Gain (auto) set to " << settings.m_gain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
|
|
|
if (DeviceLimeSDR::SetRFELNA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_lnaGain))
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: LNA gain (manual) set to " << settings.m_lnaGain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: DeviceLimeSDR::SetRFELNA_dB() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DeviceLimeSDR::SetRFETIA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_tiaGain))
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: TIA gain (manual) set to " << settings.m_tiaGain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: DeviceLimeSDR::SetRFETIA_dB() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DeviceLimeSDR::SetRBBPGA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_pgaGain))
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: PGA gain (manual) set to " << settings.m_pgaGain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: DeviceLimeSDR::SetRBBPGA_dB() failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_gainMode == LimeSDRInputSettings::GAIN_AUTO) && (m_settings.m_gain != settings.m_gain))
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("gain");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_gain) < 0)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: LMS_SetGaindB() failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: Gain (auto) set to " << settings.m_gain;
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-04 18:45:37 -04:00
|
|
|
if ((m_settings.m_gainMode == LimeSDRInputSettings::GAIN_MANUAL) && (m_settings.m_lnaGain != settings.m_lnaGain))
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("lnaGain");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
|
|
|
if (DeviceLimeSDR::SetRFELNA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_lnaGain))
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: LNA gain (manual) set to " << settings.m_lnaGain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: DeviceLimeSDR::SetRFELNA_dB() failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_gainMode == LimeSDRInputSettings::GAIN_MANUAL) && (m_settings.m_tiaGain != settings.m_tiaGain))
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("tiaGain");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
|
|
|
if (DeviceLimeSDR::SetRFETIA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_tiaGain))
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: TIA gain (manual) set to " << settings.m_tiaGain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: DeviceLimeSDR::SetRFETIA_dB() failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_gainMode == LimeSDRInputSettings::GAIN_MANUAL) && (m_settings.m_pgaGain != settings.m_pgaGain))
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("pgaGain");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
|
|
|
if (DeviceLimeSDR::SetRBBPGA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_pgaGain))
|
2017-07-04 18:45:37 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
doCalibration = true;
|
2017-11-29 06:51:05 -05:00
|
|
|
qDebug() << "LimeSDRInput::applySettings: PGA gain (manual) set to " << settings.m_pgaGain;
|
2017-07-04 18:45:37 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: DeviceLimeSDR::SetRBBPGA_dB() failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
if ((m_settings.m_devSampleRate != settings.m_devSampleRate)
|
|
|
|
|| (m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("devSampleRate");
|
|
|
|
reverseAPIKeys.append("log2HardDecim");
|
2017-10-23 20:20:57 -04:00
|
|
|
forwardChangeAllDSP = true; //m_settings.m_devSampleRate != settings.m_devSampleRate;
|
2017-04-17 20:12:15 -04:00
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
if (LMS_SetSampleRateDir(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_devSampleRate,
|
|
|
|
1<<settings.m_log2HardDecim) < 0)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could not set sample rate to %d with oversampling of %d",
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_devSampleRate,
|
|
|
|
1<<settings.m_log2HardDecim);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
m_deviceShared.m_deviceParams->m_log2OvSRRx = settings.m_log2HardDecim;
|
|
|
|
m_deviceShared.m_deviceParams->m_sampleRate = settings.m_devSampleRate;
|
|
|
|
//doCalibration = true;
|
2017-08-04 04:31:54 -04:00
|
|
|
forceNCOFrequency = true;
|
2017-04-17 20:12:15 -04:00
|
|
|
qDebug("LimeSDRInput::applySettings: set sample rate set to %d with oversampling of %d",
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_devSampleRate,
|
|
|
|
1<<settings.m_log2HardDecim);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("lpfBW");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2017-11-09 11:31:32 -05:00
|
|
|
doLPCalibration = true;
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) ||
|
|
|
|
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("lpfFIRBW");
|
|
|
|
reverseAPIKeys.append("lpfFIREnable");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_lpfFIREnable,
|
|
|
|
settings.m_lpfFIRBW) < 0)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could %s and set LPF FIR to %f Hz",
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_lpfFIREnable ? "enable" : "disable",
|
|
|
|
settings.m_lpfFIRBW);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
//doCalibration = true;
|
2017-04-17 20:12:15 -04:00
|
|
|
qDebug("LimeSDRInput::applySettings: %sd and set LPF FIR to %f Hz",
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_lpfFIREnable ? "enable" : "disable",
|
|
|
|
settings.m_lpfFIRBW);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-20 12:21:01 -04:00
|
|
|
if ((m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
|
2017-08-04 04:31:54 -04:00
|
|
|
(m_settings.m_ncoEnable != settings.m_ncoEnable) || force || forceNCOFrequency)
|
2017-04-20 12:21:01 -04:00
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("ncoFrequency");
|
|
|
|
reverseAPIKeys.append("ncoEnable");
|
2017-12-24 04:09:32 -05:00
|
|
|
forwardChangeOwnDSP = true;
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-20 12:21:01 -04:00
|
|
|
{
|
|
|
|
if (DeviceLimeSDR::setNCOFrequency(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_ncoEnable,
|
|
|
|
settings.m_ncoFrequency))
|
2017-04-20 12:21:01 -04:00
|
|
|
{
|
2017-05-08 05:02:31 -04:00
|
|
|
//doCalibration = true;
|
2017-10-26 17:57:56 -04:00
|
|
|
m_deviceShared.m_ncoFrequency = settings.m_ncoEnable ? settings.m_ncoFrequency : 0; // for buddies
|
2017-04-20 14:18:50 -04:00
|
|
|
qDebug("LimeSDRInput::applySettings: %sd and set NCO to %d Hz",
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_ncoEnable ? "enable" : "disable",
|
|
|
|
settings.m_ncoFrequency);
|
2017-04-20 12:21:01 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-20 14:18:50 -04:00
|
|
|
qCritical("LimeSDRInput::applySettings: could not %s and set NCO to %d Hz",
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_ncoEnable ? "enable" : "disable",
|
|
|
|
settings.m_ncoFrequency);
|
2017-04-20 12:21:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
if ((m_settings.m_log2SoftDecim != settings.m_log2SoftDecim) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("log2SoftDecim");
|
2017-04-17 20:12:15 -04:00
|
|
|
forwardChangeOwnDSP = true;
|
2017-10-26 17:57:56 -04:00
|
|
|
m_deviceShared.m_log2Soft = settings.m_log2SoftDecim; // for buddies
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
if (m_limeSDRInputThread != 0)
|
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
m_limeSDRInputThread->setLog2Decimation(settings.m_log2SoftDecim);
|
|
|
|
qDebug() << "LimeSDRInput::applySettings: set soft decimation to " << (1<<settings.m_log2SoftDecim);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-23 10:23:01 -04:00
|
|
|
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
|
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("antennaPath");
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-23 10:23:01 -04:00
|
|
|
{
|
2017-05-06 19:47:31 -04:00
|
|
|
if (DeviceLimeSDR::setRxAntennaPath(m_deviceShared.m_deviceParams->getDevice(),
|
2017-04-23 10:23:01 -04:00
|
|
|
m_deviceShared.m_channel,
|
2017-10-26 17:57:56 -04:00
|
|
|
settings.m_antennaPath))
|
2017-04-23 10:23:01 -04:00
|
|
|
{
|
|
|
|
doCalibration = true;
|
2017-11-02 05:30:07 -04:00
|
|
|
//setAntennaAuto = (settings.m_antennaPath == 0);
|
|
|
|
qDebug("LimeSDRInput::applySettings: set antenna path to %d on channel %d",
|
|
|
|
(int) settings.m_antennaPath,
|
|
|
|
m_deviceShared.m_channel);
|
2017-04-23 10:23:01 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could not set antenna path to %d",
|
2017-10-26 17:57:56 -04:00
|
|
|
(int) settings.m_antennaPath);
|
2017-04-23 10:23:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-16 18:25:19 -04:00
|
|
|
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
2018-04-16 18:55:56 -04:00
|
|
|
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
|
|
|
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)
|
|
|
|
|| setAntennaAuto || force)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("centerFrequency");
|
|
|
|
reverseAPIKeys.append("transverterMode");
|
|
|
|
reverseAPIKeys.append("transverterDeltaFrequency");
|
2017-04-17 20:12:15 -04:00
|
|
|
forwardChangeRxDSP = true;
|
|
|
|
|
2017-10-25 18:48:50 -04:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2018-04-16 18:25:19 -04:00
|
|
|
if (LMS_SetClockFreq(m_deviceShared.m_deviceParams->getDevice(), LMS_CLOCK_SXR, deviceCenterFrequency) < 0)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2018-04-16 18:25:19 -04:00
|
|
|
qCritical("LimeSDRInput::applySettings: could not set frequency to %lld", deviceCenterFrequency);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-18 07:50:28 -04:00
|
|
|
doCalibration = true;
|
2018-04-16 18:25:19 -04:00
|
|
|
m_deviceShared.m_centerFrequency = deviceCenterFrequency; // for buddies
|
|
|
|
qDebug("LimeSDRInput::applySettings: frequency set to %lld", deviceCenterFrequency);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 21:18:16 -04:00
|
|
|
if ((m_settings.m_extClock != settings.m_extClock) ||
|
2017-11-05 04:31:41 -05:00
|
|
|
(settings.m_extClock && (m_settings.m_extClockFreq != settings.m_extClockFreq)) || force)
|
2017-11-03 21:18:16 -04:00
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("extClock");
|
|
|
|
reverseAPIKeys.append("extClockFreq");
|
2017-11-03 21:18:16 -04:00
|
|
|
|
|
|
|
if (DeviceLimeSDR::setClockSource(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
settings.m_extClock,
|
|
|
|
settings.m_extClockFreq))
|
|
|
|
{
|
|
|
|
forwardClockSource = true;
|
|
|
|
doCalibration = true;
|
|
|
|
qDebug("LimeSDRInput::applySettings: clock set to %s (Ext: %d Hz)",
|
|
|
|
settings.m_extClock ? "external" : "internal",
|
|
|
|
settings.m_extClockFreq);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could not set clock to %s (Ext: %d Hz)",
|
|
|
|
settings.m_extClock ? "external" : "internal",
|
|
|
|
settings.m_extClockFreq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-29 17:37:34 -05:00
|
|
|
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
|
|
|
|
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
|
2018-11-28 19:21:44 -05:00
|
|
|
{
|
2018-11-29 17:37:34 -05:00
|
|
|
if ((m_settings.m_gpioDir != settings.m_gpioDir) || force)
|
2018-11-28 19:21:44 -05:00
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("gpioDir");
|
|
|
|
|
2018-11-29 17:37:34 -05:00
|
|
|
if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
forwardGPIOChange = true;
|
|
|
|
qDebug("LimeSDROutput::applySettings: GPIO directions set to %u", settings.m_gpioDir);
|
|
|
|
}
|
2018-11-28 19:21:44 -05:00
|
|
|
}
|
|
|
|
|
2018-11-29 17:37:34 -05:00
|
|
|
if ((m_settings.m_gpioPins != settings.m_gpioPins) || force)
|
2018-11-28 19:21:44 -05:00
|
|
|
{
|
2018-12-18 17:37:26 -05:00
|
|
|
reverseAPIKeys.append("gpioPins");
|
|
|
|
|
2018-11-29 17:37:34 -05:00
|
|
|
if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
forwardGPIOChange = true;
|
|
|
|
qDebug("LimeSDROutput::applySettings: GPIO pins set to %u", settings.m_gpioPins);
|
|
|
|
}
|
2018-11-28 19:21:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-18 17:37:26 -05:00
|
|
|
if (settings.m_useReverseAPI)
|
|
|
|
{
|
|
|
|
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
|
|
|
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
|
|
|
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
|
|
|
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex);
|
|
|
|
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
|
|
|
}
|
|
|
|
|
2017-10-26 17:57:56 -04:00
|
|
|
m_settings = settings;
|
|
|
|
double clockGenFreqAfter;
|
|
|
|
|
|
|
|
if (LMS_GetClockFreq(m_deviceShared.m_deviceParams->getDevice(), LMS_CLOCK_CGEN, &clockGenFreqAfter) != 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could not get clock gen frequency");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "LimeSDRInput::applySettings: clock gen frequency after: " << clockGenFreqAfter;
|
|
|
|
doCalibration = doCalibration || (clockGenFreqAfter != clockGenFreq);
|
|
|
|
}
|
2017-04-20 12:21:01 -04:00
|
|
|
|
2017-11-09 11:31:32 -05:00
|
|
|
if (doCalibration || doLPCalibration)
|
2017-04-18 07:50:28 -04:00
|
|
|
{
|
2017-10-26 17:57:56 -04:00
|
|
|
if (m_limeSDRInputThread && m_limeSDRInputThread->isRunning())
|
|
|
|
{
|
|
|
|
m_limeSDRInputThread->stopWork();
|
|
|
|
ownThreadWasRunning = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
suspendRxBuddies();
|
|
|
|
suspendTxBuddies();
|
|
|
|
|
2017-11-09 11:31:32 -05:00
|
|
|
if (doCalibration)
|
2017-04-18 07:50:28 -04:00
|
|
|
{
|
2017-11-09 11:31:32 -05:00
|
|
|
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
|
|
|
m_settings.m_devSampleRate,
|
|
|
|
0) < 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: calibration failed on Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: calibration successful on Rx channel %d", m_deviceShared.m_channel);
|
|
|
|
}
|
2017-04-18 07:50:28 -04:00
|
|
|
}
|
2017-11-29 06:51:05 -05:00
|
|
|
|
|
|
|
if (doLPCalibration)
|
2017-04-18 07:50:28 -04:00
|
|
|
{
|
2017-11-09 11:31:32 -05:00
|
|
|
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(),
|
|
|
|
LMS_CH_RX,
|
|
|
|
m_deviceShared.m_channel,
|
|
|
|
m_settings.m_lpfBW) < 0)
|
|
|
|
{
|
|
|
|
qCritical("LimeSDRInput::applySettings: could not set LPF to %f Hz", m_settings.m_lpfBW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LimeSDRInput::applySettings: LPF set to %f Hz", m_settings.m_lpfBW);
|
|
|
|
}
|
2017-04-18 07:50:28 -04:00
|
|
|
}
|
2017-10-26 17:57:56 -04:00
|
|
|
|
|
|
|
resumeTxBuddies();
|
|
|
|
resumeRxBuddies();
|
|
|
|
|
|
|
|
if (ownThreadWasRunning) {
|
|
|
|
m_limeSDRInputThread->startWork();
|
|
|
|
}
|
2017-04-18 07:50:28 -04:00
|
|
|
}
|
|
|
|
|
2017-04-19 18:01:11 -04:00
|
|
|
// forward changes to buddies or oneself
|
2017-04-18 17:26:30 -04:00
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
if (forwardChangeAllDSP)
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qDebug("LimeSDRInput::applySettings: forward change to all buddies");
|
|
|
|
|
2017-04-20 17:02:06 -04:00
|
|
|
int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0;
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
// send to self first
|
2017-04-22 21:36:10 -04:00
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(
|
|
|
|
m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim),
|
|
|
|
m_settings.m_centerFrequency + ncoShift);
|
2017-09-13 17:40:06 -04:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
// send to source buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2017-04-22 00:37:36 -04:00
|
|
|
|
2017-04-17 20:12:15 -04:00
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
|
|
|
{
|
2017-10-24 19:38:39 -04:00
|
|
|
DeviceLimeSDRShared::MsgReportBuddyChange *report = DeviceLimeSDRShared::MsgReportBuddyChange::create(
|
|
|
|
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSource)->getSamplingDeviceInputMessageQueue()->push(report);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// send to sink buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
|
|
|
{
|
2017-10-24 19:38:39 -04:00
|
|
|
DeviceLimeSDRShared::MsgReportBuddyChange *report = DeviceLimeSDRShared::MsgReportBuddyChange::create(
|
|
|
|
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSink)->getSamplingDeviceInputMessageQueue()->push(report);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (forwardChangeRxDSP)
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qDebug("LimeSDRInput::applySettings: forward change to Rx buddies");
|
|
|
|
|
2017-04-18 07:33:33 -04:00
|
|
|
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim);
|
2017-04-20 17:02:06 -04:00
|
|
|
int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0;
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
// send to self first
|
2017-04-20 17:02:06 -04:00
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + ncoShift);
|
2017-09-13 17:40:06 -04:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
// send to source buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2017-04-22 00:37:36 -04:00
|
|
|
|
2017-04-20 17:43:24 -04:00
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
2017-04-17 20:12:15 -04:00
|
|
|
{
|
2017-10-24 19:38:39 -04:00
|
|
|
DeviceLimeSDRShared::MsgReportBuddyChange *report = DeviceLimeSDRShared::MsgReportBuddyChange::create(
|
|
|
|
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSource)->getSamplingDeviceInputMessageQueue()->push(report);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (forwardChangeOwnDSP)
|
|
|
|
{
|
2017-04-18 19:04:57 -04:00
|
|
|
qDebug("LimeSDRInput::applySettings: forward change to self only");
|
|
|
|
|
2017-04-18 07:33:33 -04:00
|
|
|
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim);
|
2017-04-20 17:02:06 -04:00
|
|
|
int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0;
|
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + ncoShift);
|
2017-09-04 18:00:33 -04:00
|
|
|
m_fileSink->handleMessage(*notif); // forward to file sink
|
2017-09-13 17:40:06 -04:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2017-04-17 20:12:15 -04:00
|
|
|
}
|
|
|
|
|
2017-11-03 21:18:16 -04:00
|
|
|
if (forwardClockSource)
|
|
|
|
{
|
|
|
|
// send to source buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2017-11-03 21:18:16 -04:00
|
|
|
|
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportClockSourceChange *report = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
|
|
|
|
m_settings.m_extClock, m_settings.m_extClockFreq);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSource)->getSamplingDeviceInputMessageQueue()->push(report);
|
2017-11-03 21:18:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// send to sink buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
|
2017-11-03 21:18:16 -04:00
|
|
|
|
|
|
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportClockSourceChange *report = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
|
|
|
|
m_settings.m_extClock, m_settings.m_extClockFreq);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSink)->getSamplingDeviceInputMessageQueue()->push(report);
|
2017-11-03 21:18:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-28 19:21:44 -05:00
|
|
|
if (forwardGPIOChange)
|
|
|
|
{
|
|
|
|
// send to source buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
2018-11-28 19:21:44 -05:00
|
|
|
|
|
|
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportClockSourceChange *report = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
|
|
|
|
m_settings.m_extClock, m_settings.m_extClockFreq);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSource)->getSamplingDeviceInputMessageQueue()->push(report);
|
2018-11-28 19:21:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// send to sink buddies
|
2019-05-08 16:11:53 -04:00
|
|
|
const std::vector<DeviceAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
|
|
|
std::vector<DeviceAPI*>::const_iterator itSink = sinkBuddies.begin();
|
2018-11-28 19:21:44 -05:00
|
|
|
|
|
|
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
|
|
|
{
|
|
|
|
DeviceLimeSDRShared::MsgReportClockSourceChange *report = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
|
|
|
|
m_settings.m_extClock, m_settings.m_extClockFreq);
|
2019-05-08 16:11:53 -04:00
|
|
|
(*itSink)->getSamplingDeviceInputMessageQueue()->push(report);
|
2018-11-28 19:21:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-30 04:58:20 -05:00
|
|
|
QLocale loc;
|
|
|
|
|
2018-01-02 04:02:44 -05:00
|
|
|
qDebug().noquote() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
|
2018-04-16 18:25:19 -04:00
|
|
|
<< " m_transverterMode: " << m_settings.m_transverterMode
|
|
|
|
<< " m_transverterDeltaFrequency: " << m_settings.m_transverterDeltaFrequency
|
|
|
|
<< " deviceCenterFrequency: " << deviceCenterFrequency
|
2017-12-30 04:58:20 -05:00
|
|
|
<< " device stream sample rate: " << loc.toString(m_settings.m_devSampleRate) << "S/s"
|
|
|
|
<< " sample rate with soft decimation: " << loc.toString( m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim)) << "S/s"
|
|
|
|
<< " ADC sample rate with hard decimation: " << loc.toString(m_settings.m_devSampleRate*(1<<m_settings.m_log2HardDecim)) << "S/s"
|
2017-12-30 04:17:30 -05:00
|
|
|
<< " m_log2HardDecim: " << m_settings.m_log2HardDecim
|
|
|
|
<< " m_log2SoftDecim: " << m_settings.m_log2SoftDecim
|
2017-08-04 11:19:15 -04:00
|
|
|
<< " m_gain: " << m_settings.m_gain
|
2017-12-30 12:15:17 -05:00
|
|
|
<< " m_lpfBW: " << loc.toString(static_cast<int>(m_settings.m_lpfBW))
|
|
|
|
<< " m_lpfFIRBW: " << loc.toString(static_cast<int>(m_settings.m_lpfFIRBW))
|
2017-08-04 11:19:15 -04:00
|
|
|
<< " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
|
|
|
|
<< " m_ncoEnable: " << m_settings.m_ncoEnable
|
2017-12-30 12:15:17 -05:00
|
|
|
<< " m_ncoFrequency: " << loc.toString(m_settings.m_ncoFrequency)
|
2017-11-03 21:18:16 -04:00
|
|
|
<< " m_antennaPath: " << m_settings.m_antennaPath
|
|
|
|
<< " m_extClock: " << m_settings.m_extClock
|
2017-12-30 12:15:17 -05:00
|
|
|
<< " m_extClockFreq: " << loc.toString(m_settings.m_extClockFreq)
|
2018-11-28 19:21:44 -05:00
|
|
|
<< " m_gpioDir: " << m_settings.m_gpioDir
|
|
|
|
<< " m_gpioPins: " << m_settings.m_gpioPins
|
2017-11-29 06:51:05 -05:00
|
|
|
<< " force: " << force
|
|
|
|
<< " forceNCOFrequency: " << forceNCOFrequency
|
|
|
|
<< " doCalibration: " << doCalibration
|
|
|
|
<< " doLPCalibration: " << doLPCalibration;
|
2017-04-17 20:12:15 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-08 09:11:16 -05:00
|
|
|
int LimeSDRInput::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-08 09:11:16 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-08 09:11:16 -05:00
|
|
|
response.setLimeSdrInputSettings(new SWGSDRangel::SWGLimeSdrInputSettings());
|
2018-02-21 07:50:50 -05:00
|
|
|
response.getLimeSdrInputSettings()->init();
|
2017-12-26 19:46:33 -05:00
|
|
|
webapiFormatDeviceSettings(response, m_settings);
|
2017-12-08 09:11:16 -05:00
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int LimeSDRInput::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
2017-12-26 19:46:33 -05:00
|
|
|
const QStringList& deviceSettingsKeys,
|
2017-12-08 09:11:16 -05:00
|
|
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-08 09:11:16 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-26 19:46:33 -05:00
|
|
|
LimeSDRInputSettings settings = m_settings;
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("antennaPath")) {
|
|
|
|
settings.m_antennaPath = (LimeSDRInputSettings::PathRFE) response.getLimeSdrInputSettings()->getAntennaPath();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("centerFrequency")) {
|
|
|
|
settings.m_centerFrequency = response.getLimeSdrInputSettings()->getCenterFrequency();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dcBlock")) {
|
|
|
|
settings.m_dcBlock = response.getLimeSdrInputSettings()->getDcBlock() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("devSampleRate")) {
|
|
|
|
settings.m_devSampleRate = response.getLimeSdrInputSettings()->getDevSampleRate();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("extClock")) {
|
|
|
|
settings.m_extClock = response.getLimeSdrInputSettings()->getExtClock() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("extClockFreq")) {
|
|
|
|
settings.m_extClockFreq = response.getLimeSdrInputSettings()->getExtClockFreq();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain")) {
|
|
|
|
settings.m_gain = response.getLimeSdrInputSettings()->getGain();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gainMode")) {
|
|
|
|
settings.m_gainMode = (LimeSDRInputSettings::GainMode) response.getLimeSdrInputSettings()->getGainMode();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("iqCorrection")) {
|
|
|
|
settings.m_iqCorrection = response.getLimeSdrInputSettings()->getIqCorrection() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaGain")) {
|
|
|
|
settings.m_lnaGain = response.getLimeSdrInputSettings()->getLnaGain();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("log2HardDecim")) {
|
|
|
|
settings.m_log2HardDecim = response.getLimeSdrInputSettings()->getLog2HardDecim();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("log2SoftDecim")) {
|
|
|
|
settings.m_log2SoftDecim = response.getLimeSdrInputSettings()->getLog2SoftDecim();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lpfBW")) {
|
|
|
|
settings.m_lpfBW = response.getLimeSdrInputSettings()->getLpfBw();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lpfFIREnable")) {
|
|
|
|
settings.m_lpfFIREnable = response.getLimeSdrInputSettings()->getLpfFirEnable() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lpfFIRBW")) {
|
|
|
|
settings.m_lpfFIRBW = response.getLimeSdrInputSettings()->getLpfFirbw();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("ncoEnable")) {
|
|
|
|
settings.m_ncoEnable = response.getLimeSdrInputSettings()->getNcoEnable() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("ncoFrequency")) {
|
|
|
|
settings.m_ncoFrequency = response.getLimeSdrInputSettings()->getNcoFrequency();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("pgaGain")) {
|
|
|
|
settings.m_pgaGain = response.getLimeSdrInputSettings()->getPgaGain();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("tiaGain")) {
|
|
|
|
settings.m_tiaGain = response.getLimeSdrInputSettings()->getTiaGain();
|
|
|
|
}
|
2018-04-16 18:25:19 -04:00
|
|
|
if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
|
|
|
|
settings.m_transverterDeltaFrequency = response.getLimeSdrInputSettings()->getTransverterDeltaFrequency();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("transverterMode")) {
|
|
|
|
settings.m_transverterMode = response.getLimeSdrInputSettings()->getTransverterMode() != 0;
|
|
|
|
}
|
2018-05-09 12:59:39 -04:00
|
|
|
if (deviceSettingsKeys.contains("fileRecordName")) {
|
|
|
|
settings.m_fileRecordName = *response.getLimeSdrInputSettings()->getFileRecordName();
|
|
|
|
}
|
2018-11-28 19:21:44 -05:00
|
|
|
if (deviceSettingsKeys.contains("gpioDir")) {
|
|
|
|
settings.m_gpioDir = response.getLimeSdrInputSettings()->getGpioDir() & 0xFF;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gpioPins")) {
|
|
|
|
settings.m_gpioPins = response.getLimeSdrInputSettings()->getGpioPins() & 0xFF;
|
|
|
|
}
|
2018-12-18 17:37:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getLimeSdrInputSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
2019-01-13 05:35:31 -05:00
|
|
|
settings.m_reverseAPIAddress = *response.getLimeSdrInputSettings()->getReverseApiAddress();
|
2018-12-18 17:37:26 -05:00
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getLimeSdrInputSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getLimeSdrInputSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
2017-12-08 09:11:16 -05:00
|
|
|
|
|
|
|
MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureLimeSDR *msgToGUI = MsgConfigureLimeSDR::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
2017-12-26 19:46:33 -05:00
|
|
|
webapiFormatDeviceSettings(response, settings);
|
2017-12-08 09:11:16 -05:00
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2017-12-26 19:46:33 -05:00
|
|
|
void LimeSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const LimeSDRInputSettings& settings)
|
|
|
|
{
|
|
|
|
response.getLimeSdrInputSettings()->setAntennaPath((int) settings.m_antennaPath);
|
|
|
|
response.getLimeSdrInputSettings()->setCenterFrequency(settings.m_centerFrequency);
|
|
|
|
response.getLimeSdrInputSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
|
|
|
response.getLimeSdrInputSettings()->setDevSampleRate(settings.m_devSampleRate);
|
|
|
|
response.getLimeSdrInputSettings()->setExtClock(settings.m_extClock ? 1 : 0);
|
|
|
|
response.getLimeSdrInputSettings()->setExtClockFreq(settings.m_extClockFreq);
|
|
|
|
response.getLimeSdrInputSettings()->setGain(settings.m_gain);
|
|
|
|
response.getLimeSdrInputSettings()->setGainMode((int) settings.m_gainMode);
|
|
|
|
response.getLimeSdrInputSettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
|
|
|
response.getLimeSdrInputSettings()->setLnaGain(settings.m_lnaGain);
|
|
|
|
response.getLimeSdrInputSettings()->setLog2HardDecim(settings.m_log2HardDecim);
|
|
|
|
response.getLimeSdrInputSettings()->setLog2SoftDecim(settings.m_log2SoftDecim);
|
|
|
|
response.getLimeSdrInputSettings()->setLpfBw(settings.m_lpfBW);
|
|
|
|
response.getLimeSdrInputSettings()->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0);
|
|
|
|
response.getLimeSdrInputSettings()->setLpfFirbw(settings.m_lpfFIRBW);
|
|
|
|
response.getLimeSdrInputSettings()->setNcoEnable(settings.m_ncoEnable ? 1 : 0);
|
|
|
|
response.getLimeSdrInputSettings()->setNcoFrequency(settings.m_ncoFrequency);
|
|
|
|
response.getLimeSdrInputSettings()->setPgaGain(settings.m_pgaGain);
|
|
|
|
response.getLimeSdrInputSettings()->setTiaGain(settings.m_tiaGain);
|
2018-04-16 18:25:19 -04:00
|
|
|
response.getLimeSdrInputSettings()->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
|
|
|
response.getLimeSdrInputSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
2018-05-09 12:59:39 -04:00
|
|
|
|
|
|
|
if (response.getLimeSdrInputSettings()->getFileRecordName()) {
|
|
|
|
*response.getLimeSdrInputSettings()->getFileRecordName() = settings.m_fileRecordName;
|
|
|
|
} else {
|
|
|
|
response.getLimeSdrInputSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
|
|
|
|
}
|
2018-11-28 19:21:44 -05:00
|
|
|
|
|
|
|
response.getLimeSdrInputSettings()->setGpioDir(settings.m_gpioDir);
|
|
|
|
response.getLimeSdrInputSettings()->setGpioPins(settings.m_gpioPins);
|
2018-12-18 17:37:26 -05:00
|
|
|
response.getLimeSdrInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getLimeSdrInputSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getLimeSdrInputSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getLimeSdrInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getLimeSdrInputSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getLimeSdrInputSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
2017-12-26 19:46:33 -05:00
|
|
|
}
|
|
|
|
|
2018-05-26 16:16:59 -04:00
|
|
|
int LimeSDRInput::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGDeviceReport& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2018-05-26 16:16:59 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2018-05-26 16:16:59 -04:00
|
|
|
response.setLimeSdrInputReport(new SWGSDRangel::SWGLimeSdrInputReport());
|
|
|
|
response.getLimeSdrInputReport()->init();
|
|
|
|
webapiFormatDeviceReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2017-12-09 19:57:50 -05:00
|
|
|
int LimeSDRInput::webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-09 19:57:50 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-09 19:57:50 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int LimeSDRInput::webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-09 19:57:50 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-14 17:29:12 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
2017-12-14 12:02:49 -05:00
|
|
|
MsgStartStop *message = MsgStartStop::create(run);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
2017-12-09 19:57:50 -05:00
|
|
|
{
|
2017-12-14 12:02:49 -05:00
|
|
|
MsgStartStop *msgToGUI = MsgStartStop::create(run);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
2017-12-09 19:57:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2018-05-26 16:16:59 -04:00
|
|
|
void LimeSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
double temp = 0.0;
|
2018-11-28 19:21:44 -05:00
|
|
|
uint8_t gpioDir = 0;
|
|
|
|
uint8_t gpioPins = 0;
|
2018-05-26 16:16:59 -04:00
|
|
|
lms_stream_status_t status;
|
|
|
|
status.active = false;
|
|
|
|
status.fifoFilledCount = 0;
|
|
|
|
status.fifoSize = 1;
|
|
|
|
status.underrun = 0;
|
|
|
|
status.overrun = 0;
|
|
|
|
status.droppedPackets = 0;
|
|
|
|
status.linkRate = 0.0;
|
|
|
|
status.timestamp = 0;
|
|
|
|
|
|
|
|
success = (m_streamId.handle && (LMS_GetStreamStatus(&m_streamId, &status) == 0));
|
|
|
|
|
|
|
|
response.getLimeSdrInputReport()->setSuccess(success ? 1 : 0);
|
|
|
|
response.getLimeSdrInputReport()->setStreamActive(status.active ? 1 : 0);
|
|
|
|
response.getLimeSdrInputReport()->setFifoSize(status.fifoSize);
|
|
|
|
response.getLimeSdrInputReport()->setFifoFill(status.fifoFilledCount);
|
|
|
|
response.getLimeSdrInputReport()->setUnderrunCount(status.underrun);
|
|
|
|
response.getLimeSdrInputReport()->setOverrunCount(status.overrun);
|
|
|
|
response.getLimeSdrInputReport()->setDroppedPacketsCount(status.droppedPackets);
|
|
|
|
response.getLimeSdrInputReport()->setLinkRate(status.linkRate);
|
|
|
|
response.getLimeSdrInputReport()->setHwTimestamp(status.timestamp);
|
|
|
|
|
2018-11-28 19:21:44 -05:00
|
|
|
if (m_deviceShared.m_deviceParams->getDevice())
|
|
|
|
{
|
2018-05-26 16:16:59 -04:00
|
|
|
LMS_GetChipTemperature(m_deviceShared.m_deviceParams->getDevice(), 0, &temp);
|
2018-11-28 19:21:44 -05:00
|
|
|
LMS_GPIODirRead(m_deviceShared.m_deviceParams->getDevice(), &gpioDir, 1);
|
|
|
|
LMS_GPIORead(m_deviceShared.m_deviceParams->getDevice(), &gpioPins, 1);
|
2018-05-26 16:16:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
response.getLimeSdrInputReport()->setTemperature(temp);
|
2018-11-28 19:21:44 -05:00
|
|
|
response.getLimeSdrInputReport()->setGpioDir(gpioDir);
|
|
|
|
response.getLimeSdrInputReport()->setGpioPins(gpioPins);
|
2018-05-26 16:16:59 -04:00
|
|
|
}
|
2018-12-18 17:37:26 -05:00
|
|
|
|
|
|
|
void LimeSDRInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LimeSDRInputSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgDeviceSettings->setDirection(0); // single Rx
|
2019-03-25 08:41:38 -04:00
|
|
|
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
2018-12-18 17:37:26 -05:00
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("LimeSDR"));
|
|
|
|
swgDeviceSettings->setLimeSdrInputSettings(new SWGSDRangel::SWGLimeSdrInputSettings());
|
|
|
|
SWGSDRangel::SWGLimeSdrInputSettings *swgLimeSdrInputSettings = swgDeviceSettings->getLimeSdrInputSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("antennaPath") || force) {
|
|
|
|
swgLimeSdrInputSettings->setAntennaPath((int) settings.m_antennaPath);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("centerFrequency") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setCenterFrequency(settings.m_centerFrequency);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("dcBlock") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("devSampleRate") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setDevSampleRate(settings.m_devSampleRate);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("extClock") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setExtClock(settings.m_extClock ? 1 : 0);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("extClockFreq") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setExtClockFreq(settings.m_extClockFreq);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("gain") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setGain(settings.m_gain);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("gainMode") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setGainMode((int) settings.m_gainMode);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("iqCorrection") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("lnaGain") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setLnaGain(settings.m_lnaGain);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("log2HardDecim") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setLog2HardDecim(settings.m_log2HardDecim);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("log2SoftDecim") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setLog2SoftDecim(settings.m_log2SoftDecim);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("lpfBW") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setLpfBw(settings.m_lpfBW);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("lpfFIREnable") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("lpfFIRBW") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setLpfFirbw(settings.m_lpfFIRBW);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("ncoEnable") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setNcoEnable(settings.m_ncoEnable ? 1 : 0);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("ncoFrequency") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setNcoFrequency(settings.m_ncoFrequency);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("pgaGain") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setPgaGain(settings.m_pgaGain);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("tiaGain") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setTiaGain(settings.m_tiaGain);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("transverterMode") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("fileRecordName") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setFileRecordName(new QString(settings.m_fileRecordName));
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("gpioDir") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setGpioDir(settings.m_gpioDir & 0xFF);
|
|
|
|
}
|
2018-12-19 16:01:26 -05:00
|
|
|
if (deviceSettingsKeys.contains("gpioPins") || force) {
|
2018-12-18 17:37:26 -05:00
|
|
|
swgLimeSdrInputSettings->setGpioPins(settings.m_gpioPins & 0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
|
|
|
.arg(settings.m_reverseAPIAddress)
|
|
|
|
.arg(settings.m_reverseAPIPort)
|
|
|
|
.arg(settings.m_reverseAPIDeviceIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
2018-12-19 02:52:50 -05:00
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
2018-12-18 17:37:26 -05:00
|
|
|
|
|
|
|
QBuffer *buffer=new QBuffer();
|
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
|
|
|
|
|
|
|
// Always use PATCH to avoid passing reverse API settings
|
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
|
|
|
|
|
|
|
delete swgDeviceSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInput::webapiReverseSendStartStop(bool start)
|
|
|
|
{
|
2019-03-25 10:21:17 -04:00
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgDeviceSettings->setDirection(0); // single Rx
|
2019-03-25 10:21:17 -04:00
|
|
|
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("LimeSDR"));
|
|
|
|
|
2018-12-18 17:37:26 -05:00
|
|
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
|
|
|
|
.arg(m_settings.m_reverseAPIAddress)
|
|
|
|
.arg(m_settings.m_reverseAPIPort)
|
|
|
|
.arg(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
|
|
|
|
QBuffer *buffer=new QBuffer();
|
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
2018-12-18 17:37:26 -05:00
|
|
|
|
|
|
|
if (start) {
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
|
2018-12-18 17:37:26 -05:00
|
|
|
} else {
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
|
2018-12-18 17:37:26 -05:00
|
|
|
}
|
2019-06-14 10:58:09 -04:00
|
|
|
|
|
|
|
delete swgDeviceSettings;
|
2018-12-18 17:37:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInput::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "LimeSDRInput::networkManagerFinished:"
|
|
|
|
<< " error(" << (int) replyError
|
|
|
|
<< "): " << replyError
|
|
|
|
<< ": " << reply->errorString();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString answer = reply->readAll();
|
2018-12-19 16:01:26 -05:00
|
|
|
answer.chop(1); // remove last \n
|
2018-12-18 17:37:26 -05:00
|
|
|
qDebug("LimeSDRInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
|
|
|
}
|