2017-01-02 04:39:21 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 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 //
|
|
|
|
// //
|
|
|
|
// 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 <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "device/devicesinkapi.h"
|
|
|
|
#include "device/devicesourceapi.h"
|
2017-08-08 18:31:23 -04:00
|
|
|
#include "bladerf/devicebladerfshared.h"
|
2017-01-02 04:39:21 -05:00
|
|
|
|
|
|
|
#include "bladerfoutput.h"
|
|
|
|
#include "bladerfoutputgui.h"
|
|
|
|
#include "bladerfoutputthread.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(BladerfOutput::MsgConfigureBladerf, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(BladerfOutput::MsgReportBladerf, Message)
|
|
|
|
|
|
|
|
BladerfOutput::BladerfOutput(DeviceSinkAPI *deviceAPI) :
|
|
|
|
m_deviceAPI(deviceAPI),
|
|
|
|
m_settings(),
|
|
|
|
m_dev(0),
|
|
|
|
m_bladerfThread(0),
|
2017-04-13 15:26:36 -04:00
|
|
|
m_deviceDescription("BladeRFOutput"),
|
|
|
|
m_running(false)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-04-13 15:26:36 -04:00
|
|
|
openDevice();
|
2017-01-02 04:39:21 -05:00
|
|
|
m_deviceAPI->setBuddySharedPtr(&m_sharedParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
BladerfOutput::~BladerfOutput()
|
|
|
|
{
|
2017-04-13 15:26:36 -04:00
|
|
|
if (m_running) stop();
|
|
|
|
closeDevice();
|
2017-01-03 03:09:51 -05:00
|
|
|
m_deviceAPI->setBuddySharedPtr(0);
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
bool BladerfOutput::openDevice()
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-04-13 15:26:36 -04:00
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
closeDevice();
|
|
|
|
}
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
int res;
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-01-09 16:33:58 -05:00
|
|
|
m_sampleSourceFifo.resize(m_settings.m_devSampleRate/(1<<(m_settings.m_log2Interp <= 4 ? m_settings.m_log2Interp : 4)));
|
2017-01-02 04:39:21 -05:00
|
|
|
|
|
|
|
if (m_deviceAPI->getSourceBuddies().size() > 0)
|
|
|
|
{
|
2017-04-13 17:40:14 -04:00
|
|
|
DeviceSourceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0];
|
|
|
|
DeviceBladeRFParams *buddySharedParams = (DeviceBladeRFParams *) sourceBuddy->getBuddySharedPtr();
|
2017-01-02 04:39:21 -05:00
|
|
|
|
|
|
|
if (buddySharedParams == 0)
|
|
|
|
{
|
|
|
|
qCritical("BladerfOutput::start: could not get shared parameters from buddy");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-13 17:40:14 -04:00
|
|
|
if (buddySharedParams->m_dev == 0) // device is not opened by buddy
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-04-13 17:40:14 -04:00
|
|
|
qCritical("BladerfOutput::start: could not get BladeRF handle from buddy");
|
|
|
|
return false;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 17:40:14 -04:00
|
|
|
m_sharedParams = *(buddySharedParams); // copy parameters from buddy
|
|
|
|
m_dev = m_sharedParams.m_dev; // get BladeRF handle
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
2017-04-13 17:40:14 -04:00
|
|
|
else
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-04-13 19:59:09 -04:00
|
|
|
if (!DeviceBladeRF::open_bladerf(&m_dev, qPrintable(m_deviceAPI->getSampleSinkSerial())))
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-04-13 19:59:09 -04:00
|
|
|
qCritical("BladerfOutput::start: could not open BladeRF %s", qPrintable(m_deviceAPI->getSampleSinkSerial()));
|
2017-01-02 04:39:21 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sharedParams.m_dev = m_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: adjust USB transfer data according to sample rate
|
|
|
|
if ((res = bladerf_sync_config(m_dev, BLADERF_MODULE_TX, BLADERF_FORMAT_SC16_Q11, 64, 8192, 32, 10000)) < 0)
|
|
|
|
{
|
2017-04-13 15:26:36 -04:00
|
|
|
qCritical("BladerfOutput::start: bladerf_sync_config with return code %d", res);
|
|
|
|
return false;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((res = bladerf_enable_module(m_dev, BLADERF_MODULE_TX, true)) < 0)
|
|
|
|
{
|
2017-04-13 15:26:36 -04:00
|
|
|
qCritical("BladerfOutput::start: bladerf_enable_module with return code %d", res);
|
|
|
|
return false;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:44:49 -04:00
|
|
|
bool BladerfOutput::start()
|
2017-04-13 15:26:36 -04:00
|
|
|
{
|
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
|
|
|
|
if (!m_dev) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_running) stop();
|
|
|
|
|
2017-01-02 04:39:21 -05:00
|
|
|
if((m_bladerfThread = new BladerfOutputThread(m_dev, &m_sampleSourceFifo)) == 0)
|
|
|
|
{
|
|
|
|
qFatal("BladerfOutput::start: out of memory");
|
2017-04-13 15:26:36 -04:00
|
|
|
stop();
|
|
|
|
return false;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
2017-01-02 18:56:18 -05:00
|
|
|
// mutexLocker.unlock();
|
2017-01-02 04:39:21 -05:00
|
|
|
applySettings(m_settings, true);
|
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
m_bladerfThread->setLog2Interpolation(m_settings.m_log2Interp);
|
|
|
|
|
2017-01-09 16:33:58 -05:00
|
|
|
m_bladerfThread->startWork();
|
|
|
|
|
2017-01-02 04:39:21 -05:00
|
|
|
qDebug("BladerfOutput::start: started");
|
2017-04-13 15:26:36 -04:00
|
|
|
m_running = true;
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
return true;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
void BladerfOutput::closeDevice()
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-01-02 18:56:18 -05:00
|
|
|
int res;
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-04-17 06:00:13 -04:00
|
|
|
if (m_dev == 0) { // was never open
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-02 18:56:18 -05:00
|
|
|
if ((res = bladerf_enable_module(m_dev, BLADERF_MODULE_TX, false)) < 0)
|
|
|
|
{
|
2017-04-13 17:40:14 -04:00
|
|
|
qCritical("BladerfOutput::closeDevice: bladerf_enable_module with return code %d", res);
|
2017-01-02 18:56:18 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 17:40:14 -04:00
|
|
|
if (m_deviceAPI->getSourceBuddies().size() == 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-04-13 17:40:14 -04:00
|
|
|
qDebug("BladerfOutput::closeDevice: closing device since Rx side is not open");
|
2017-01-02 18:56:18 -05:00
|
|
|
|
2017-04-13 17:40:14 -04:00
|
|
|
if (m_dev != 0) // close BladeRF
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
|
|
|
bladerf_close(m_dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sharedParams.m_dev = 0;
|
2017-01-03 03:09:51 -05:00
|
|
|
m_dev = 0;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:26:36 -04:00
|
|
|
void BladerfOutput::stop()
|
|
|
|
{
|
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
if (m_bladerfThread != 0)
|
|
|
|
{
|
|
|
|
m_bladerfThread->stopWork();
|
|
|
|
delete m_bladerfThread;
|
|
|
|
m_bladerfThread = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_running = false;
|
|
|
|
}
|
|
|
|
|
2017-01-02 04:39:21 -05:00
|
|
|
const QString& BladerfOutput::getDeviceDescription() const
|
|
|
|
{
|
|
|
|
return m_deviceDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BladerfOutput::getSampleRate() const
|
|
|
|
{
|
|
|
|
int rate = m_settings.m_devSampleRate;
|
|
|
|
return (rate / (1<<m_settings.m_log2Interp));
|
|
|
|
}
|
|
|
|
|
|
|
|
quint64 BladerfOutput::getCenterFrequency() const
|
|
|
|
{
|
|
|
|
return m_settings.m_centerFrequency;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BladerfOutput::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (MsgConfigureBladerf::match(message))
|
|
|
|
{
|
|
|
|
MsgConfigureBladerf& conf = (MsgConfigureBladerf&) message;
|
|
|
|
qDebug() << "BladerfInput::handleMessage: MsgConfigureBladerf";
|
|
|
|
|
|
|
|
if (!applySettings(conf.getSettings(), false))
|
|
|
|
{
|
|
|
|
qDebug("BladeRF config error");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool force)
|
|
|
|
{
|
2017-08-08 17:09:51 -04:00
|
|
|
bool forwardChange = false;
|
|
|
|
bool suspendOwnThread = false;
|
|
|
|
bool threadWasRunning = false;
|
2017-01-02 18:56:18 -05:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
2017-01-02 04:39:21 -05:00
|
|
|
|
|
|
|
qDebug() << "BladerfOutput::applySettings: m_dev: " << m_dev;
|
|
|
|
|
2017-08-08 17:09:51 -04:00
|
|
|
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
|
|
|
|
(m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
|
|
|
{
|
|
|
|
suspendOwnThread = true;
|
|
|
|
}
|
2017-01-09 16:33:58 -05:00
|
|
|
|
2017-08-08 17:09:51 -04:00
|
|
|
if (suspendOwnThread)
|
|
|
|
{
|
|
|
|
if (m_bladerfThread)
|
|
|
|
{
|
|
|
|
if (m_bladerfThread->isRunning())
|
|
|
|
{
|
|
|
|
m_bladerfThread->stopWork();
|
|
|
|
threadWasRunning = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-09 16:33:58 -05:00
|
|
|
|
2017-08-08 17:09:51 -04:00
|
|
|
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
|
|
|
{
|
2017-08-08 18:31:23 -04:00
|
|
|
int fifoSize;
|
|
|
|
|
2017-08-09 16:59:46 -04:00
|
|
|
if (settings.m_log2Interp >= 5)
|
2017-08-08 18:31:23 -04:00
|
|
|
{
|
|
|
|
fifoSize = DeviceBladeRFShared::m_sampleFifoMinSize32;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fifoSize = std::max(
|
|
|
|
(int) ((settings.m_devSampleRate/(1<<settings.m_log2Interp)) * DeviceBladeRFShared::m_sampleFifoLengthInSeconds),
|
|
|
|
DeviceBladeRFShared::m_sampleFifoMinSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sampleSourceFifo.resize(fifoSize);
|
2017-01-09 16:33:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
|
|
|
{
|
|
|
|
forwardChange = true;
|
|
|
|
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
unsigned int actualSamplerate;
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-01-09 16:33:58 -05:00
|
|
|
if (bladerf_set_sample_rate(m_dev, BLADERF_MODULE_TX, settings.m_devSampleRate, &actualSamplerate) < 0)
|
|
|
|
{
|
|
|
|
qCritical("BladerfOutput::applySettings: could not set sample rate: %d", settings.m_devSampleRate);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "BladerfOutput::applySettings: bladerf_set_sample_rate(BLADERF_MODULE_TX) actual sample rate is " << actualSamplerate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
|
|
|
{
|
|
|
|
forwardChange = true;
|
|
|
|
|
|
|
|
if (m_bladerfThread != 0)
|
|
|
|
{
|
|
|
|
m_bladerfThread->setLog2Interpolation(settings.m_log2Interp);
|
|
|
|
qDebug() << "BladerfOutput::applySettings: set interpolation to " << (1<<settings.m_log2Interp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_vga1 != settings.m_vga1) || force)
|
|
|
|
{
|
2017-01-02 04:39:21 -05:00
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
if(bladerf_set_txvga1(m_dev, settings.m_vga1) != 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
|
|
|
qDebug("BladerfOutput::applySettings: bladerf_set_txvga1() failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
qDebug() << "BladerfOutput::applySettings: VGA1 gain set to " << settings.m_vga1;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_vga2 != settings.m_vga2) || force)
|
|
|
|
{
|
|
|
|
if(m_dev != 0)
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
if(bladerf_set_txvga2(m_dev, settings.m_vga2) != 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
|
|
|
qDebug("BladerfOutput::applySettings:bladerf_set_rxvga2() failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
qDebug() << "BladerfOutput::applySettings: VGA2 gain set to " << settings.m_vga2;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_xb200 != settings.m_xb200) || force)
|
|
|
|
{
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
bool changeSettings;
|
|
|
|
|
|
|
|
if (m_deviceAPI->getSourceBuddies().size() > 0)
|
|
|
|
{
|
|
|
|
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
|
|
|
|
|
|
|
|
if (buddy->getDeviceSourceEngine()->state() == DSPDeviceSourceEngine::StRunning) // Tx side running
|
|
|
|
{
|
|
|
|
changeSettings = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changeSettings = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // No Rx open
|
|
|
|
{
|
|
|
|
changeSettings = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changeSettings)
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
if (settings.m_xb200)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
|
|
|
if (bladerf_expansion_attach(m_dev, BLADERF_XB_200) != 0)
|
|
|
|
{
|
|
|
|
qDebug("BladerfOutput::applySettings: bladerf_expansion_attach(xb200) failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "BladerfOutput::applySettings: Attach XB200";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bladerf_expansion_attach(m_dev, BLADERF_XB_NONE) != 0)
|
|
|
|
{
|
|
|
|
qDebug("BladerfOutput::applySettings: bladerf_expansion_attach(none) failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "BladerfOutput::applySettings: Detach XB200";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-09 16:33:58 -05:00
|
|
|
m_sharedParams.m_xb200Attached = settings.m_xb200;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_xb200Path != settings.m_xb200Path) || force)
|
|
|
|
{
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
if(bladerf_xb200_set_path(m_dev, BLADERF_MODULE_TX, settings.m_xb200Path) != 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
|
|
|
qDebug("BladerfOutput::applySettings: bladerf_xb200_set_path(BLADERF_MODULE_TX) failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
qDebug() << "BladerfOutput::applySettings: set xb200 path to " << settings.m_xb200Path;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_xb200Filter != settings.m_xb200Filter) || force)
|
|
|
|
{
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
if(bladerf_xb200_set_filterbank(m_dev, BLADERF_MODULE_TX, settings.m_xb200Filter) != 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
|
|
|
qDebug("BladerfOutput::applySettings: bladerf_xb200_set_filterbank(BLADERF_MODULE_TX) failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
qDebug() << "BladerfOutput::applySettings: set xb200 filter to " << settings.m_xb200Filter;
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_bandwidth != settings.m_bandwidth) || force)
|
|
|
|
{
|
|
|
|
if(m_dev != 0)
|
|
|
|
{
|
|
|
|
unsigned int actualBandwidth;
|
|
|
|
|
2017-01-09 16:33:58 -05:00
|
|
|
if( bladerf_set_bandwidth(m_dev, BLADERF_MODULE_TX, settings.m_bandwidth, &actualBandwidth) < 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
qCritical("BladerfOutput::applySettings: could not set bandwidth: %d", settings.m_bandwidth);
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "BladerfOutput::applySettings: bladerf_set_bandwidth(BLADERF_MODULE_TX) actual bandwidth is " << actualBandwidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_settings.m_centerFrequency != settings.m_centerFrequency)
|
|
|
|
{
|
|
|
|
forwardChange = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_dev != NULL)
|
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
if (bladerf_set_frequency( m_dev, BLADERF_MODULE_TX, settings.m_centerFrequency ) != 0)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-01-09 16:33:58 -05:00
|
|
|
qDebug("BladerfOutput::applySettings: bladerf_set_frequency(%lld) failed", settings.m_centerFrequency);
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-08 17:09:51 -04:00
|
|
|
if (threadWasRunning)
|
|
|
|
{
|
|
|
|
m_bladerfThread->startWork();
|
|
|
|
}
|
|
|
|
|
2017-01-09 16:33:58 -05:00
|
|
|
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
|
|
|
m_settings.m_bandwidth = settings.m_bandwidth;
|
|
|
|
m_settings.m_xb200Filter = settings.m_xb200Filter;
|
|
|
|
m_settings.m_xb200 = settings.m_xb200;
|
|
|
|
m_settings.m_xb200Path = settings.m_xb200Path;
|
|
|
|
m_settings.m_vga2 = settings.m_vga2;
|
|
|
|
m_settings.m_vga1 = settings.m_vga1;
|
|
|
|
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
|
|
|
m_settings.m_log2Interp = settings.m_log2Interp;
|
|
|
|
|
2017-01-02 04:39:21 -05:00
|
|
|
if (forwardChange)
|
|
|
|
{
|
|
|
|
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp);
|
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
|
|
|
|
m_deviceAPI->getDeviceInputMessageQueue()->push(notif);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "BladerfOutput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
|
2017-04-01 22:34:58 -04:00
|
|
|
<< " device sample rate: " << m_settings.m_devSampleRate << "S/s"
|
|
|
|
<< " baseband sample rate: " << m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp) << "S/s"
|
2017-01-09 16:33:58 -05:00
|
|
|
<< " BW: " << m_settings.m_bandwidth << "Hz";
|
2017-01-02 04:39:21 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|