From f4bf4d0b9973977ce7186379036e6b11d853c4f3 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 8 Feb 2018 23:26:10 +0100 Subject: [PATCH] Perseus support final --- devices/perseus/deviceperseusscan.cpp | 2 +- plugins/samplesource/perseus/perseusgui.ui | 2 +- plugins/samplesource/perseus/perseusinput.cpp | 15 +++++++++++++-- plugins/samplesource/perseus/perseusthread.cpp | 3 ++- plugins/samplesource/perseus/perseusthread.h | 4 ++-- udev-rules/95-perseus.rules | 1 + udev-rules/install.sh | 1 + 7 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 udev-rules/95-perseus.rules diff --git a/devices/perseus/deviceperseusscan.cpp b/devices/perseus/deviceperseusscan.cpp index 70c424cc6..39233f17e 100644 --- a/devices/perseus/deviceperseusscan.cpp +++ b/devices/perseus/deviceperseusscan.cpp @@ -57,7 +57,7 @@ void DevicePerseusScan::scan(int nbDevices) uint32_t sigB = (prodid.signature[3]<<16) + prodid.signature[2]; uint32_t sigC = (prodid.signature[1]<<16) + prodid.signature[0]; std::stringstream ss; - ss << prodid.sn << "-" << std::hex << sigA << "-" << sigB << "-" << sigC; + ss << prodid.sn << "-" << std::hex << sigA << "-" << sigB << "-" << sigC; m_scans.push_back({ss.str(), prodid.sn, deviceIndex}); m_serialMap[m_scans.back().m_serial] = &m_scans.back(); perseus_close(descr); diff --git a/plugins/samplesource/perseus/perseusgui.ui b/plugins/samplesource/perseus/perseusgui.ui index 8c5868d1a..3ef1589f7 100644 --- a/plugins/samplesource/perseus/perseusgui.ui +++ b/plugins/samplesource/perseus/perseusgui.ui @@ -29,7 +29,7 @@ - AirspyHF + Perseus diff --git a/plugins/samplesource/perseus/perseusinput.cpp b/plugins/samplesource/perseus/perseusinput.cpp index ff1296638..7c19c5cf9 100644 --- a/plugins/samplesource/perseus/perseusinput.cpp +++ b/plugins/samplesource/perseus/perseusinput.cpp @@ -220,6 +220,16 @@ bool PerseusInput::handleMessage(const Message& message) bool PerseusInput::openDevice() { + if (m_perseusDescriptor != 0) { + closeDevice(); + } + + if (!m_sampleFifo.setSize(PERSEUS_NBSAMPLES)) + { + qCritical("PerseusInput::start: could not allocate SampleFifo"); + return false; + } + m_deviceAPI->getSampleSourceSerial(); int deviceSequence = DevicePerseus::instance().getSequenceFromSerial(m_deviceAPI->getSampleSourceSerial().toStdString()); @@ -264,7 +274,8 @@ void PerseusInput::setDeviceCenterFrequency(quint64 freq_hz, const PerseusSettin qint64 df = ((qint64)freq_hz * settings.m_LOppmTenths) / 10000000LL; freq_hz += df; - int rc = perseus_set_ddc_center_freq(m_perseusDescriptor, freq_hz, settings.m_wideBand ? 1 : 0); + // wideband flag is inverted since parameter is set to enable preselection filters + int rc = perseus_set_ddc_center_freq(m_perseusDescriptor, freq_hz, settings.m_wideBand ? 0 : 1); if (rc < 0) { qWarning("PerseusInput::setDeviceCenterFrequency: could not set frequency to %llu Hz: %s", freq_hz, perseus_errorstr()); @@ -297,7 +308,7 @@ bool PerseusInput::applySettings(const PerseusSettings& settings, bool force) qCritical("PerseusInput::applySettings: could not set sample rate index %u (%d S/s): %s", settings.m_devSampleRateIndex, rate, perseus_errorstr()); } - else if (m_perseusDescriptor != 0) + else if (m_perseusThread != 0) { qDebug("PerseusInput::applySettings: sample rate set to index: %u (%d S/s)", settings.m_devSampleRateIndex, rate); m_perseusThread->setSamplerate(rate); diff --git a/plugins/samplesource/perseus/perseusthread.cpp b/plugins/samplesource/perseus/perseusthread.cpp index d602383a3..9bc420749 100644 --- a/plugins/samplesource/perseus/perseusthread.cpp +++ b/plugins/samplesource/perseus/perseusthread.cpp @@ -48,7 +48,7 @@ void PerseusThread::startWork() void PerseusThread::stopWork() { - qDebug("AirspyThread::stopWork"); + qDebug("PerseusThread::stopWork"); m_running = false; wait(); } @@ -75,6 +75,7 @@ void PerseusThread::run() } else { + qDebug("PerseusThread::run: start Perseus Rx"); while (m_running) { sleep(1); } diff --git a/plugins/samplesource/perseus/perseusthread.h b/plugins/samplesource/perseus/perseusthread.h index a4ab5540e..81d1c5a8d 100644 --- a/plugins/samplesource/perseus/perseusthread.h +++ b/plugins/samplesource/perseus/perseusthread.h @@ -54,8 +54,8 @@ private: unsigned int m_log2Decim; static PerseusThread *m_this; - Decimators, SDR_RX_SAMP_SZ, 16> m_decimators32; - Decimators, SDR_RX_SAMP_SZ, 16> m_decimators64; + Decimators, SDR_RX_SAMP_SZ, 24> m_decimators32; // for no decimation (accumulator is int32) + Decimators, SDR_RX_SAMP_SZ, 24> m_decimators64; // for actual decimation (accumulator is int64) void run(); void callback(const uint8_t* buf, qint32 len); // inner call back diff --git a/udev-rules/95-perseus.rules b/udev-rules/95-perseus.rules new file mode 100644 index 000000000..3cf1f885d --- /dev/null +++ b/udev-rules/95-perseus.rules @@ -0,0 +1 @@ +ATTR{idVendor}=="04b4", ATTR{idProduct}=="325c", MODE="666", GROUP="plugdev" diff --git a/udev-rules/install.sh b/udev-rules/install.sh index b4533faec..f4b99e220 100755 --- a/udev-rules/install.sh +++ b/udev-rules/install.sh @@ -9,6 +9,7 @@ cp 64-limesuite.rules /etc/udev/rules.d/ cp 53-adi-plutosdr-usb.rules /etc/udev/rules.d/ cp rtl-sdr.rules /etc/udev/rules.d/ cp mirisdr.rules /etc/udev/rules.d/ +cp 95-perseus.rules /etc/udev/rules.d/ udevadm control --reload-rules udevadm trigger