From 1235f713884c9b83a8bb82bf94c58a489f97f663 Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 5 Nov 2024 10:09:09 +0000 Subject: [PATCH] Freuqency Scanner: Add multiplex mode. --- plugins/channelrx/freqscanner/freqscanner.cpp | 58 +++++++++++++++++-- plugins/channelrx/freqscanner/freqscanner.h | 3 +- .../channelrx/freqscanner/freqscannergui.cpp | 16 +++++ .../channelrx/freqscanner/freqscannergui.ui | 53 +++++++++-------- .../freqscanner/freqscannersettings.h | 3 +- plugins/channelrx/freqscanner/readme.md | 15 ++++- 6 files changed, 116 insertions(+), 32 deletions(-) diff --git a/plugins/channelrx/freqscanner/freqscanner.cpp b/plugins/channelrx/freqscanner/freqscanner.cpp index e5d62b59f..c2f98796e 100644 --- a/plugins/channelrx/freqscanner/freqscanner.cpp +++ b/plugins/channelrx/freqscanner/freqscanner.cpp @@ -377,6 +377,7 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< bool freqInRange = false; qint64 nextCenterFrequency = m_centerFrequency; int usableBW = (m_scannerSampleRate * 3 / 4) & ~1; + int nextFrequencyIndex = 0; do { if (nextCenterFrequency + usableBW / 2 > m_stepStopFrequency) @@ -398,13 +399,30 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< && (m_settings.m_frequencySettings[i].m_frequency < nextCenterFrequency + usableBW / 2)) { freqInRange = true; + nextFrequencyIndex = i; + + // Do we need to realign for frequencies with wider bandwidths than default + if (!m_settings.m_frequencySettings[i].m_channelBandwidth.isEmpty()) + { + bool ok; + int channelBW = m_settings.m_frequencySettings[i].m_channelBandwidth.toInt(&ok); + if (ok) + { + if (channelBW >= usableBW) { + nextCenterFrequency = m_settings.m_frequencySettings[i].m_frequency; + } else if (m_settings.m_frequencySettings[i].m_frequency - channelBW / 2 < nextCenterFrequency - usableBW / 2) { + nextCenterFrequency = m_settings.m_frequencySettings[i].m_frequency - channelBW / 2; + } + } + } + break; } } } while (!complete && !freqInRange); - if (complete) + if (complete || (m_settings.m_mode == FreqScannerSettings::MULTIPLEX)) { if (m_scanResults.size() > 0) { @@ -421,7 +439,12 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< FreqScannerSettings::FrequencySettings *frequencySettings = nullptr; FreqScannerSettings::FrequencySettings *activeFrequencySettings = nullptr; - if (m_settings.m_priority == FreqScannerSettings::MAX_POWER) + if (m_settings.m_mode == FreqScannerSettings::MULTIPLEX) + { + activeFrequencySettings = &m_settings.m_frequencySettings[nextFrequencyIndex]; + frequency = activeFrequencySettings->m_frequency; + } + else if (m_settings.m_priority == FreqScannerSettings::MAX_POWER) { Real maxPower = -200.0f; @@ -528,6 +551,13 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< } m_state = IDLE; } + else if (m_settings.m_mode == FreqScannerSettings::MULTIPLEX) + { + // Wait for user-specified receive time before moving to next frequency + m_timeoutTimer.setSingleShot(true); + m_timeoutTimer.start((int)(m_settings.m_retransmitTime * 1000.0)); + m_state = WAIT_FOR_RX_TIME; + } else { // Wait for transmission to finish @@ -605,13 +635,33 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< } break; + case WAIT_FOR_RX_TIME: + for (int i = 0; i < results.size(); i++) + { + if (results[i].m_frequency == m_activeFrequency) + { + if (m_guiMessageQueue) { + m_guiMessageQueue->push(MsgReportActivePower::create(results[i].m_power)); + } + } + } + break; + } } void FreqScanner::timeout() { - // Power hasn't returned above threshold - Restart scan - initScan(); + if (m_settings.m_mode == FreqScannerSettings::MULTIPLEX) + { + // Move to next frequency + m_state = SCAN_FOR_MAX_POWER; + } + else + { + // Power hasn't returned above threshold - Restart scan + initScan(); + } } void FreqScanner::calcScannerSampleRate(int channelBW, int basebandSampleRate, int& scannerSampleRate, int& fftSize, int& binsPerChannel) diff --git a/plugins/channelrx/freqscanner/freqscanner.h b/plugins/channelrx/freqscanner/freqscanner.h index f07046736..39c55e9ac 100644 --- a/plugins/channelrx/freqscanner/freqscanner.h +++ b/plugins/channelrx/freqscanner/freqscanner.h @@ -399,7 +399,8 @@ private: START_SCAN, SCAN_FOR_MAX_POWER, WAIT_FOR_END_TX, - WAIT_FOR_RETRANSMISSION + WAIT_FOR_RETRANSMISSION, + WAIT_FOR_RX_TIME } m_state; QTimer m_timeoutTimer; diff --git a/plugins/channelrx/freqscanner/freqscannergui.cpp b/plugins/channelrx/freqscanner/freqscannergui.cpp index 7aa5ead86..b93ced43b 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.cpp +++ b/plugins/channelrx/freqscanner/freqscannergui.cpp @@ -364,6 +364,22 @@ void FreqScannerGUI::on_mode_currentIndexChanged(int index) { m_settings.m_mode = (FreqScannerSettings::Mode)index; applySetting("mode"); + bool multiplex = m_settings.m_mode == FreqScannerSettings::MULTIPLEX; + ui->threshLabel->setEnabled(!multiplex); + ui->thresh->setEnabled(!multiplex); + ui->threshText->setEnabled(!multiplex); + ui->priorityLabel->setEnabled(!multiplex); + ui->priority->setEnabled(!multiplex); + if (multiplex) + { + ui->retransmitTimeLabel->setText("tTX"); + ui->retransmitTime->setToolTip("Time in seconds to listen on each frequency"); + } + else + { + ui->retransmitTimeLabel->setText("tRTX"); + ui->retransmitTime->setToolTip("Time in seconds to wait for frequency to become active again, before restarting scan"); + } } void FreqScannerGUI::onWidgetRolled(QWidget* widget, bool rollDown) diff --git a/plugins/channelrx/freqscanner/freqscannergui.ui b/plugins/channelrx/freqscanner/freqscannergui.ui index dfa4b5ff8..2a611a31b 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.ui +++ b/plugins/channelrx/freqscanner/freqscannergui.ui @@ -29,7 +29,7 @@ - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Frequency Scanner @@ -102,7 +102,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -143,7 +143,7 @@ PointingHandCursor - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Minimum demod shift frequency from center in Hz @@ -160,14 +160,14 @@ - Qt::Vertical + Qt::Orientation::Vertical - Qt::Horizontal + Qt::Orientation::Horizontal @@ -191,13 +191,13 @@ Active frequency power - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft -120.0 - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -215,7 +215,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -266,7 +266,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -279,7 +279,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -328,7 +328,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -377,7 +377,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -428,7 +428,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -465,7 +465,7 @@ PointingHandCursor - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Channel bandwidth @@ -482,7 +482,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -551,7 +551,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -569,7 +569,7 @@ Run mode - 1 + 0 @@ -586,6 +586,11 @@ Scan-only + + + Multiplex + + @@ -597,7 +602,7 @@ - + :/play.png :/stop.png:/play.png @@ -621,7 +626,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -767,7 +772,7 @@ Leave blank for no adjustment Up - + :/arrow_up.png:/arrow_up.png @@ -781,7 +786,7 @@ Leave blank for no adjustment - + :/arrow_down.png:/arrow_down.png @@ -789,7 +794,7 @@ Leave blank for no adjustment - Qt::Horizontal + Qt::Orientation::Horizontal @@ -808,7 +813,7 @@ Leave blank for no adjustment - + :/bin.png:/bin.png @@ -843,7 +848,7 @@ Leave blank for no adjustment deltaFrequency - + diff --git a/plugins/channelrx/freqscanner/freqscannersettings.h b/plugins/channelrx/freqscanner/freqscannersettings.h index bcd669e97..4d6784029 100644 --- a/plugins/channelrx/freqscanner/freqscannersettings.h +++ b/plugins/channelrx/freqscanner/freqscannersettings.h @@ -64,7 +64,8 @@ struct FreqScannerSettings enum Mode { SINGLE, CONTINUOUS, - SCAN_ONLY + SCAN_ONLY, + MULTIPLEX } m_mode; //!< Whether to run a single or many scans QList m_columnIndexes;//!< How the columns are ordered in the table diff --git a/plugins/channelrx/freqscanner/readme.md b/plugins/channelrx/freqscanner/readme.md index 7bd676b98..934278075 100644 --- a/plugins/channelrx/freqscanner/readme.md +++ b/plugins/channelrx/freqscanner/readme.md @@ -6,6 +6,14 @@ This plugin can be used to scan a range of frequencies looking for a transmissio [Tutorial Video](https://www.youtube.com/watch?v=IpKP3t4Bmmg) +With the Run Mode (11) set to Multiplex, it can also repeatedly cycle through frequencies listening for a fixed period of time. This can be used, for example, to +receive both AIS and ADS-B data via a single SDR. + +Note that when scanning, the device centre frequency will often not be set exactly to the frequencies you enter. +The Frequency Scanner will typically try to set the device centre frequency in order to +scan as many frequencies simultanously as possible, and also avoid having a DC offset within the bandwidth of a scanned frequency. +The demodulator channel's frequency offset option will be used so that it receives at the specified frequency. +

Interface

The top and bottom bars of the channel window are described [here](../../../sdrgui/channel/readme.md) @@ -40,11 +48,13 @@ that corresponds to the set frequency is being received. Specifies the time in seconds that the Frequency Scanner will average its power measurement over. -

7: t_rtx - Retransmission Time

+

7: t_rtx - Retransmission Time / t_rx Receive Time

-Specifies the time in seconds that the Frequency Scanner will wait after the power on the active frequency falls below the threshold, before restarting +t_rtx: When Run Mode (11) is not Multiplex, specifies the time in seconds that the Frequency Scanner will wait after the power on the active frequency falls below the threshold, before restarting scanning. This enables the channel to remain tuned to a single frequency while there is a temporary break in transmission. +t_rx: When Run Mode (11) is Multiplex, specifies the time in seconds the channel will be tuned to each frequency. +

8: Ch BW - Channel Bandwidth

This specifies the bandwidth of the channels to be scanned. @@ -75,6 +85,7 @@ Specifies the run mode: - Single: All frequencies are scanned once. Channel (1) is tuned to the active frequency at the end of the scan. The scan does not repeat. - Continuous: All frequencies scanned, with channel (1) being tuned to active frequency at the end of the scan. Scan repeats once the power on the active frequency falls below the threshold (4) for longer than the retransmission time (7). - Scan only: All frequencies are scanned repeatedly. The channel will not be tuned. This mode is just for counting how often frequencies are active, which can be seen in the Active Count column in the frequency table (14). +- Multiplex: Frequencies will be stepped through sequentially and repeatedly, with the channel (1) being tuned for the time specified by t_rx (7).

12: Start/Stop Scanning