From 258515b5de67c393b46af8e8c7dfcaac8cb1e6f6 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 19 Jul 2017 23:24:00 +0200 Subject: [PATCH] HackRF: switch over Rx / Tx with the start button --- plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp | 9 +++++++++ plugins/samplesource/hackrfinput/hackrfinputgui.cpp | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp index 2794c1fde..f108395df 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp @@ -26,6 +26,7 @@ #include "dsp/dspengine.h" #include "dsp/dspcommands.h" #include "device/devicesinkapi.h" +#include "device/devicesourceapi.h" #include "hackrf/devicehackrfvalues.h" #include "ui_hackrfoutputgui.h" @@ -269,6 +270,13 @@ void HackRFOutputGui::on_startStop_toggled(bool checked) { if (checked) { + // forcibly stop the Rx if present before starting + if (m_deviceAPI->getSourceBuddies().size() > 0) + { + DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[0]; + buddy->stopAcquisition(); + } + if (m_deviceAPI->initGeneration()) { m_deviceAPI->startGeneration(); @@ -303,6 +311,7 @@ void HackRFOutputGui::updateStatus() break; case DSPDeviceSinkEngine::StIdle: ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); + ui->startStop->setChecked(false); break; case DSPDeviceSinkEngine::StRunning: ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); diff --git a/plugins/samplesource/hackrfinput/hackrfinputgui.cpp b/plugins/samplesource/hackrfinput/hackrfinputgui.cpp index a7c7a8e65..d8d7e3e35 100644 --- a/plugins/samplesource/hackrfinput/hackrfinputgui.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinputgui.cpp @@ -25,8 +25,9 @@ #include "gui/glspectrum.h" #include "dsp/dspengine.h" #include "dsp/dspcommands.h" -#include -#include +#include "device/devicesourceapi.h" +#include "device/devicesinkapi.h" +#include "dsp/filerecord.h" #include "hackrf/devicehackrfvalues.h" #include "ui_hackrfinputgui.h" @@ -326,6 +327,13 @@ void HackRFInputGui::on_startStop_toggled(bool checked) { if (checked) { + // forcibly stop the Tx if present before starting + if (m_deviceAPI->getSinkBuddies().size() > 0) + { + DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[0]; + buddy->stopGeneration(); + } + if (m_deviceAPI->initAcquisition()) { m_deviceAPI->startAcquisition(); @@ -375,6 +383,7 @@ void HackRFInputGui::updateStatus() break; case DSPDeviceSourceEngine::StIdle: ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); + ui->startStop->setChecked(false); break; case DSPDeviceSourceEngine::StRunning: ui->startStop->setStyleSheet("QToolButton { background-color : green; }");