From f326860f6457fa3e17132bdff2aa7d1aabe7111a Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 9 Jun 2022 04:49:41 +0200 Subject: [PATCH] M17 demod: various adjustments --- .../channelrx/demodm17/m17/M17FrameDecoder.h | 1 + plugins/channelrx/demodm17/m17/Trellis.h | 16 +- plugins/channelrx/demodm17/m17/Viterbi.h | 6 +- plugins/channelrx/demodm17/m17demod.h | 2 + plugins/channelrx/demodm17/m17demod.ui | 1181 ------------ plugins/channelrx/demodm17/m17demodbaseband.h | 2 + plugins/channelrx/demodm17/m17demodgui.cpp | 52 +- plugins/channelrx/demodm17/m17demodgui.h | 2 +- plugins/channelrx/demodm17/m17demodgui.ui | 1584 +++++++++-------- .../channelrx/demodm17/m17demodprocessor.cpp | 71 +- .../channelrx/demodm17/m17demodprocessor.h | 16 + plugins/channelrx/demodm17/m17demodsink.h | 2 + .../demodm17/m17statustextdialog.cpp | 4 +- .../channelrx/demodm17/m17statustextdialog.h | 1 - .../channelrx/demodm17/m17statustextdialog.ui | 21 +- 15 files changed, 953 insertions(+), 2008 deletions(-) delete mode 100644 plugins/channelrx/demodm17/m17demod.ui diff --git a/plugins/channelrx/demodm17/m17/M17FrameDecoder.h b/plugins/channelrx/demodm17/m17/M17FrameDecoder.h index f639dd921..004fb4ada 100644 --- a/plugins/channelrx/demodm17/m17/M17FrameDecoder.h +++ b/plugins/channelrx/demodm17/m17/M17FrameDecoder.h @@ -274,6 +274,7 @@ struct M17FrameDecoder std::array tmp; std::copy(buffer.begin() + 96, buffer.end(), tmp.begin()); + depuncture(tmp, depuncture_buffer.stream, P2); viterbi_cost = viterbi_.decode(depuncture_buffer.stream, decode_buffer.stream); to_byte_array(decode_buffer.stream, output_buffer.stream); diff --git a/plugins/channelrx/demodm17/m17/Trellis.h b/plugins/channelrx/demodm17/m17/Trellis.h index 5488ac884..c9a1b4903 100644 --- a/plugins/channelrx/demodm17/m17/Trellis.h +++ b/plugins/channelrx/demodm17/m17/Trellis.h @@ -14,6 +14,19 @@ namespace mobilinkd { +inline constexpr std::array make_p1() { + std::array result{}; + for (size_t i = 0, j = 2; i != 61; ++i) { + if (i == j) { + result[i] = 0; + j += 4; + } else { + result[i] = 1; + } + } + return result; +}; + /// Puncture matrix for LSF constexpr auto P1 = std::array{ 1, @@ -42,8 +55,7 @@ constexpr auto P2 = std::array{ /// Puncture matrix for packet frames (7/8). constexpr auto P3 = std::array{ - 1, 1, 1, 1, - 1, 1, 1, 0}; + 1, 1, 1, 1, 1, 1, 1, 0}; /** * Convert an integer value to an array of bits, with the diff --git a/plugins/channelrx/demodm17/m17/Viterbi.h b/plugins/channelrx/demodm17/m17/Viterbi.h index a92d83fc7..ed3594378 100644 --- a/plugins/channelrx/demodm17/m17/Viterbi.h +++ b/plugins/channelrx/demodm17/m17/Viterbi.h @@ -57,7 +57,7 @@ constexpr std::array, (1 << Trellis_::K) for (size_t j = 0; j != (1 << Trellis_::k); ++j) { size_t l = update_memory(i, j) & (NumStates - 1); - result[l][k] = i; + result[l][k] = i; } } return result; @@ -156,7 +156,7 @@ struct Viterbi /** * Viterbi soft decoder using LLR inputs where 0 == erasure. - * + * * @return path metric for estimating BER. */ template @@ -198,7 +198,7 @@ struct Viterbi cost1[j] += std::abs(cost_[j][1] + s1); } } - + for (size_t j = 0; j != BUTTERFLY_SIZE; ++j) { calculate_path_metric(cost0, cost1, history_[hindex], j); diff --git a/plugins/channelrx/demodm17/m17demod.h b/plugins/channelrx/demodm17/m17demod.h index 7938103dc..8ab883909 100644 --- a/plugins/channelrx/demodm17/m17demod.h +++ b/plugins/channelrx/demodm17/m17demod.h @@ -148,7 +148,9 @@ public: const QString& getSrcCall() const { return m_basebandSink->getSrcCall(); } const QString& getDestcCall() const { return m_basebandSink->getDestcCall(); } const QString& getTypeInfo() const { return m_basebandSink->getTypeInfo(); } + bool getStreamElsePacket() const { return m_basebandSink->getStreamElsePacket(); } uint16_t getCRC() const { return m_basebandSink->getCRC(); } + int getStdPacketProtocol() const { return m_basebandSink->getStdPacketProtocol(); } static const char* const m_channelIdURI; static const char* const m_channelId; diff --git a/plugins/channelrx/demodm17/m17demod.ui b/plugins/channelrx/demodm17/m17demod.ui deleted file mode 100644 index 4b0fd45d1..000000000 --- a/plugins/channelrx/demodm17/m17demod.ui +++ /dev/null @@ -1,1181 +0,0 @@ - - - M17DemodGUI - - - - 0 - 0 - 482 - 392 - - - - - 0 - 0 - - - - - 482 - 392 - - - - - 750 - 392 - - - - - Liberation Sans - 9 - - - - M17 Demodulator - - - - - 0 - 0 - 480 - 172 - - - - - 0 - 0 - - - - - 480 - 0 - - - - Settings - - - - 3 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 2 - - - - - 6 - - - - - - 16 - 0 - - - - Df - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - Liberation Mono - 12 - - - - PointingHandCursor - - - Qt::StrongFocus - - - Demod shift frequency from center in Hz - - - - - - - Hz - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - RFBW - - - - - - - Bandwidth (kHz) before discriminator - - - 500 - - - 1 - - - 100 - - - Qt::Horizontal - - - - - - - - 40 - 0 - - - - 00.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - Channel power (dB) - - - Qt::RightToLeft - - - -100.0 dB - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - Level meter (dB) top trace: average, bottom trace: instantaneous peak, tip: peak hold - - - dB - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - Liberation Mono - 8 - - - - - - - - - - - - Activate status text log - - - - - - - - - - - 24 - 0 - - - - - 24 - 16777215 - - - - View status text log - - - - - - - :/listing.png:/listing.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - - - - Vol - - - - - - - - 24 - 24 - - - - Sound volume - - - 100 - - - 1 - - - 20 - - - - - - - - 30 - 0 - - - - - 30 - 16777215 - - - - Sound volume - - - 10.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - Sq - - - - - - - - 24 - 24 - - - - Squelch threshold (dB) - - - -100 - - - 0 - - - 1 - - - 1 - - - -40 - - - - - - - - 30 - 0 - - - - Squelch threshold (dB) - - - -100 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 24 - 24 - - - - Squelch gate (ms) - - - 0 - - - 50 - - - 1 - - - 5 - - - 5 - - - - - - - - 25 - 0 - - - - Squelch gate (ms) - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Toggle audio high pass filter - - - - - - - :/filter_highpass.png:/filter_highpass.png - - - - - - - Left: Mute/Unmute audio (all slots) Right: select audio output - - - ... - - - - :/sound_on.png - :/sound_off.png:/sound_on.png - - - true - - - - - - - - - 2 - - - 2 - - - 2 - - - - - Source - - - - - - - - 80 - 0 - - - - ... - - - - - - - Dest - - - - - - - - 80 - 0 - - - - ... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 180 - 480 - 210 - - - - - 480 - 210 - - - - Digital - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 0 - - - - - 200 - 200 - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 10 - 10 - 59 - 20 - - - - - 0 - 0 - - - - - 35 - 0 - - - - - 16777215 - 16777215 - - - - Baud rate: 2.4k: NXDN48, dPMR 4.8k: DMR, D-Star, YSF, NXDN96 - - - - 4.8k - - - - - - - 80 - 10 - 110 - 25 - - - - - 110 - 0 - - - - - 16777215 - 25 - - - - - Liberation Mono - 9 - - - - Synchronized on this frame type - - - QFrame::Box - - - QFrame::Sunken - - - 2 - - - No Sync______ - - - - - - 10 - 40 - 22 - 22 - - - - - 0 - 0 - - - - - 22 - 22 - - - - - 22 - 22 - - - - Symbol synchronization rate (%) - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 40 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Zero crossing relative position in number of samples (<0 sampling point lags, >0 it leads) - - - -00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 80 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - -00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 110 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier input level (%) when synchronized - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 70 - 23 - 22 - - - - Toggle between transition constellation and symbol synchronization displays - - - - - - - :/constellation.png - :/slopep_icon.png:/constellation.png - - - true - - - - - - 50 - 107 - 141 - 16 - - - - Maximum frequency deviation (kHz) - - - 100 - - - 1 - - - 35 - - - 35 - - - Qt::Horizontal - - - - - - 10 - 100 - 25 - 29 - - - - FMd - - - - - - 200 - 100 - 50 - 29 - - - - - 50 - 0 - - - - +00.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 130 - 28 - 30 - - - - Gain - - - - - - 50 - 137 - 141 - 16 - - - - - 0 - 0 - - - - Gain after discriminator - - - 50 - - - 200 - - - 1 - - - 100 - - - Qt::Horizontal - - - - - - 40 - 68 - 24 - 24 - - - - - 24 - 24 - - - - Display trace length (ms) - - - 6 - - - 30 - - - 1 - - - 6 - - - - - - 70 - 73 - 31 - 16 - - - - Display trace length (ms) - - - 0000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 200 - 130 - 50 - 29 - - - - - 50 - 0 - - - - 0.00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 110 - 70 - 24 - 24 - - - - - 24 - 24 - - - - Trace stroke [0..255] - - - 0 - - - 255 - - - 1 - - - 100 - - - - - - 130 - 73 - 31 - 16 - - - - Trace stroke value - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 170 - 70 - 24 - 24 - - - - - 24 - 24 - - - - Trace decay [0..255] - - - 0 - - - 255 - - - 1 - - - 200 - - - - - - 190 - 73 - 31 - 16 - - - - Trace decay value - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - RollupContents - QWidget -
gui/rollupcontents.h
- 1 -
- - ValueDialZ - QWidget -
gui/valuedialz.h
- 1 -
- - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
- - LevelMeterSignalDB - QWidget -
gui/levelmeter.h
- 1 -
- - TVScreen - QWidget -
gui/tvscreen.h
- 1 -
-
- - - - -
diff --git a/plugins/channelrx/demodm17/m17demodbaseband.h b/plugins/channelrx/demodm17/m17demodbaseband.h index 4e8fd78f1..37a9061b2 100644 --- a/plugins/channelrx/demodm17/m17demodbaseband.h +++ b/plugins/channelrx/demodm17/m17demodbaseband.h @@ -94,7 +94,9 @@ public: const QString& getSrcCall() const { return m_sink.getSrcCall(); } const QString& getDestcCall() const { return m_sink.getDestcCall(); } const QString& getTypeInfo() const { return m_sink.getTypeInfo(); } + bool getStreamElsePacket() const { return m_sink.getStreamElsePacket(); } uint16_t getCRC() const { return m_sink.getCRC(); } + int getStdPacketProtocol() const { return m_sink.getStdPacketProtocol(); } private: SampleSinkFifo m_sampleFifo; diff --git a/plugins/channelrx/demodm17/m17demodgui.cpp b/plugins/channelrx/demodm17/m17demodgui.cpp index b5c205aed..a6d9cf467 100644 --- a/plugins/channelrx/demodm17/m17demodgui.cpp +++ b/plugins/channelrx/demodm17/m17demodgui.cpp @@ -157,8 +157,8 @@ void M17DemodGUI::on_fmDeviation_valueChanged(int value) void M17DemodGUI::on_volume_valueChanged(int value) { - m_settings.m_volume= value / 10.0; - ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1)); + m_settings.m_volume= value / 100.0; + ui->volumeText->setText(QString("%1").arg(value / 100.0, 0, 'f', 2)); applySettings(); } @@ -419,8 +419,8 @@ void M17DemodGUI::displaySettings() ui->squelchGate->setValue(m_settings.m_squelchGate); ui->squelchGateText->setText(QString("%1").arg(ui->squelchGate->value() * 10.0, 0, 'f', 0)); - ui->volume->setValue(m_settings.m_volume * 10.0); - ui->volumeText->setText(QString("%1").arg(ui->volume->value() / 10.0, 0, 'f', 1)); + ui->volume->setValue(m_settings.m_volume * 100.0); + ui->volumeText->setText(QString("%1").arg(ui->volume->value() / 100.0, 0, 'f', 2)); ui->syncOrConstellation->setChecked(m_settings.m_syncOrConstellation); ui->audioMute->setChecked(m_settings.m_audioMute); @@ -561,10 +561,10 @@ void M17DemodGUI::tick() ui->lockLabel->setStyleSheet("QLabel { background-color : green; }"); } - ui->syncText->setText(getStatus(status)); + ui->syncText->setText(getStatus(status, m_m17Demod->getStreamElsePacket(), m_m17Demod->getStdPacketProtocol())); ui->evmText->setText(tr("%1").arg(evm*100.0f, 3, 'f', 1)); - ui->deviationText->setText(tr("%1").arg(deviation, 2, 'f', 1)); - ui->offsetText->setText(tr("%1").arg(offset, 3, 'f', 2)); + ui->deviationText->setText(tr("%1").arg(deviation/1.5f, 3, 'f', 2)); + ui->offsetText->setText(tr("%1").arg(offset/1.5f, 3, 'f', 2)); ui->viterbiText->setText(tr("%1").arg(viterbiCost)); ui->clockText->setText(tr("%1").arg(clock, 2, 'f', 1)); ui->sampleText->setText(tr("%1, %2, %3").arg(sampleIndex).arg(syncIndex).arg(clockIndex)); @@ -575,27 +575,47 @@ void M17DemodGUI::tick() ui->destText->setText(m_m17Demod->getDestcCall()); ui->typeText->setText(m_m17Demod->getTypeInfo()); ui->crcText->setText(tr("%1").arg(m_m17Demod->getCRC(), 4, 16, QChar('0'))); + + if (ui->activateStatusLog->isChecked() && (m_m17Demod->getLSFCount() != 0)) + { + QString s = tr("Src: %1 Dst: %2 Typ: %3 CRC: %4") + .arg(m_m17Demod->getSrcCall()) + .arg(m_m17Demod->getDestcCall()) + .arg(m_m17Demod->getTypeInfo()) + .arg(m_m17Demod->getCRC(), 4, 16, QChar('0')); + m_m17StatusTextDialog.addLine(s); + } + m_lsfCount = m_m17Demod->getLSFCount(); } + } m_tickCount++; } -QString M17DemodGUI::getStatus(int status) +QString M17DemodGUI::getStatus(int status, bool streamElsePacket, int packetProtocol) { if (status == 0) { return "Unlocked"; - } else if (status == 1) { - return "LSF"; - } else if (status == 2) { - return "Stream"; - } else if (status == 3) { - return "Packet"; } else if (status == 4) { return "BERT"; - } else if (status == 5) { - return "Frame"; + } else if (streamElsePacket) { + return "Stream"; + } else if (packetProtocol == 0) { + return "Raw"; + } else if (packetProtocol == 1) { + return "AX.25"; + } else if (packetProtocol == 2) { + return "APRS"; + } else if (packetProtocol == 3) { + return "6LoWPAN"; + } else if (packetProtocol == 4) { + return "IPv4"; + } else if (packetProtocol == 5) { + return "SMS"; + } else if (packetProtocol == 6) { + return "Winlink"; } else { return "Unknown"; } diff --git a/plugins/channelrx/demodm17/m17demodgui.h b/plugins/channelrx/demodm17/m17demodgui.h index 301e36dbd..1e7f916b0 100644 --- a/plugins/channelrx/demodm17/m17demodgui.h +++ b/plugins/channelrx/demodm17/m17demodgui.h @@ -110,7 +110,7 @@ private: bool handleMessage(const Message& message); void makeUIConnections(); void updateAbsoluteCenterFrequency(); - QString getStatus(int status); + QString getStatus(int status, bool streamElsePacket, int packetProtocol); void leaveEvent(QEvent*); void enterEvent(QEvent*); diff --git a/plugins/channelrx/demodm17/m17demodgui.ui b/plugins/channelrx/demodm17/m17demodgui.ui index a76e3db5f..3f9e64d12 100644 --- a/plugins/channelrx/demodm17/m17demodgui.ui +++ b/plugins/channelrx/demodm17/m17demodgui.ui @@ -7,7 +7,7 @@ 0 0 482 - 392 + 400 @@ -19,13 +19,13 @@ 482 - 392 + 400 - 750 - 392 + 560 + 400 @@ -43,7 +43,7 @@ 0 0 480 - 172 + 136 @@ -341,13 +341,13 @@ Sound volume - 100 + 200 1 - 20 + 100 @@ -369,7 +369,7 @@ Sound volume - 10.0 + 1.00 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -518,17 +518,44 @@ + + + + + + 0 + 136 + 480 + 249 + + + + + 480 + 248 + + + + Digital + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + - - 2 - - - 2 - - - 2 - @@ -544,6 +571,12 @@ 0 + + + Liberation Mono + 9 + + Source callsign @@ -573,6 +606,12 @@ 0 + + + Liberation Mono + 9 + + Destination callsign @@ -602,6 +641,12 @@ 0 + + + Liberation Mono + 9 + + Data stream type information @@ -618,6 +663,12 @@ + + + 0 + 30 + + CRC @@ -631,6 +682,12 @@ 0 + + + Liberation Mono + 9 + + CRC for the LSF data @@ -660,766 +717,743 @@ - - - - - - 0 - 180 - 480 - 210 - - - - - 480 - 210 - - - - Digital - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 0 - 0 - - - - - 200 - 200 - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 10 - 10 - 60 - 24 - - - - - 0 - 0 - - - - - 35 - 0 - - - - - 16777215 - 16777215 - - - - Baud rate: 2.4k: NXDN48, dPMR 4.8k: DMR, D-Star, YSF, NXDN96 - - - - 4.8k + + + + + + 0 + 0 + - - - - - - 80 - 10 - 110 - 24 - - - - - 110 - 0 - - - - - 16777215 - 24 - - - - - Liberation Mono - 9 - - - - Synchronization status - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - No Sync______ - - - - - - 194 - 10 - 24 - 24 - - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Data Carrier Detect (DCD) - - - QFrame::Box - - - QFrame::Sunken - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 84 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Dev - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 110 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier input level (%) when synchronized - - - 0.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 100 - 23 - 22 - - - - Toggle between transition constellation and symbol synchronization displays - - - - - - - :/constellation.png - :/slopep_icon.png:/constellation.png - - - true - - - - - - 50 - 135 - 154 - 22 - - - - Maximum frequency deviation (kHz) - - - 100 - - - 1 - - - 35 - - - 35 - - - Qt::Horizontal - - - - - - 10 - 130 - 25 - 29 - - - - FMd - - - - - - 205 - 130 - 50 - 29 - - - - - 50 - 0 - - - - +00.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 40 - 100 - 24 - 24 - - - - - 24 - 24 - - - - Display trace length (ms) - - - 6 - - - 30 - - - 1 - - - 6 - - - - - - 68 - 100 - 31 - 22 - - - - Display trace length (ms) - - - 0000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 108 - 100 - 24 - 24 - - - - - 24 - 24 - - - - Trace stroke [0..255] - - - 0 - - - 255 - - - 1 - - - 100 - - - - - - 128 - 100 - 31 - 22 - - - - Trace stroke value - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 168 - 100 - 24 - 24 - - - - - 24 - 24 - - - - Trace decay [0..255] - - - 0 - - - 255 - - - 1 - - - 200 - - - - - - 188 - 100 - 31 - 22 - - - - Trace decay value - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 222 - 10 - 24 - 24 - - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Locked state - - - QFrame::Box - - - QFrame::Sunken - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 40 - 27 - 28 - - - - - 27 - 0 - - - - Carrier relative position (%) when synchronized - - - EVM - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 40 - 40 - 38 - 28 - - - - - 30 - 0 - - - - Error Vector Magnitude (%) when synchronized - - - 00.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 142 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Ofs - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 170 - 40 - 35 - 28 - - - - - 25 - 0 - - - - Carrier input level (%) when synchronized - - - 0.00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 178 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Vit - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 203 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Carrier input level (%) when synchronized - - - 128 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Clk - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 40 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Carrier input level (%) when synchronized - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 80 - 65 - 35 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Samp - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 120 - 65 - 46 - 28 - - - - - 25 - 0 - - - - Carrier input level (%) when synchronized - - - 0, 0, 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - + + + 200 + 200 + + + + + + + + + 0 + 210 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 60 + 24 + + + + + 0 + 0 + + + + + 35 + 0 + + + + + 16777215 + 16777215 + + + + Baud rate: 2.4k: NXDN48, dPMR 4.8k: DMR, D-Star, YSF, NXDN96 + + + + 4.8k + + + + + + + 80 + 10 + 110 + 24 + + + + + 110 + 0 + + + + + 16777215 + 24 + + + + + Liberation Mono + 9 + + + + Synchronization status + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + No Sync______ + + + + + + 194 + 10 + 24 + 24 + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + Data Carrier Detect (DCD) + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 84 + 40 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Dev + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 110 + 40 + 31 + 28 + + + + + 25 + 0 + + + + Detected FM deviation relative to nominal deviation + + + 0.00 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 100 + 23 + 22 + + + + Toggle between transition constellation and symbol synchronization displays + + + + + + + :/constellation.png + :/slopep_icon.png:/constellation.png + + + true + + + + + + 50 + 135 + 154 + 22 + + + + Maximum frequency deviation (kHz) + + + 100 + + + 1 + + + 35 + + + 35 + + + Qt::Horizontal + + + + + + 10 + 130 + 25 + 29 + + + + FMd + + + + + + 205 + 130 + 50 + 29 + + + + + 50 + 0 + + + + +00.0k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 40 + 100 + 24 + 24 + + + + + 24 + 24 + + + + Display trace length (ms) + + + 6 + + + 30 + + + 1 + + + 6 + + + + + + 68 + 100 + 31 + 22 + + + + Display trace length (ms) + + + 0000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 108 + 100 + 24 + 24 + + + + + 24 + 24 + + + + Trace stroke [0..255] + + + 0 + + + 255 + + + 1 + + + 100 + + + + + + 128 + 100 + 31 + 22 + + + + Trace stroke value + + + 000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 168 + 100 + 24 + 24 + + + + + 24 + 24 + + + + Trace decay [0..255] + + + 0 + + + 255 + + + 1 + + + 200 + + + + + + 188 + 100 + 31 + 22 + + + + Trace decay value + + + 000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 222 + 10 + 24 + 24 + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + Locked state + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 40 + 27 + 28 + + + + + 27 + 0 + + + + Carrier relative position (%) when synchronized + + + EVM + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 40 + 40 + 38 + 28 + + + + + 30 + 0 + + + + Error Vector Magnitude (%) when synchronized + + + 00.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 148 + 40 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Ofs + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 172 + 40 + 31 + 28 + + + + + 25 + 0 + + + + Detected carrier deviation relative to nominal deviation + + + 0.00 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 178 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Vit + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 203 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Viterbi cost. -1 if not available. + + + 128 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Clk + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 40 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Difference between Tx and Rx clock normalized + + + 0.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 80 + 65 + 35 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Samp + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 120 + 65 + 46 + 28 + + + + + 25 + 0 + + + + Estimated sample point: sample, sync, clock. Clock wins + + + 0, 0, 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + diff --git a/plugins/channelrx/demodm17/m17demodprocessor.cpp b/plugins/channelrx/demodm17/m17demodprocessor.cpp index 8cbaf4fe1..931cac3a8 100644 --- a/plugins/channelrx/demodm17/m17demodprocessor.cpp +++ b/plugins/channelrx/demodm17/m17demodprocessor.cpp @@ -40,7 +40,7 @@ M17DemodProcessor::M17DemodProcessor() : { m_this = this; m_codec2 = ::codec2_create(CODEC2_MODE_3200); - m_audioBuffer.resize(48000); + m_audioBuffer.resize(12000); m_audioBufferFill = 0; m_srcCall = ""; m_destCall = ""; @@ -212,14 +212,16 @@ bool M17DemodProcessor::decode_lsf(mobilinkd::M17FrameDecoder::lsf_buffer_t cons } } - qDebug() << "M17DemodProcessor::decode_lsf: " << oss.str().c_str(); m_lsfCount++; + qDebug() << "M17DemodProcessor::decode_lsf: " << m_lsfCount << ":" << oss.str().c_str(); return true; } void M17DemodProcessor::decode_type(uint16_t type) { - if (type & 1) // bit 0 + m_streamElsePacket = type & 1; // bit 0 + + if (m_streamElsePacket) { m_typeInfo = "STR:"; // Stream mode @@ -268,6 +270,7 @@ void M17DemodProcessor::resetInfo() m_srcCall = ""; m_destCall = ""; m_typeInfo = ""; + m_streamElsePacket = true; m_metadata.fill(0); m_crc = 0; m_lsfCount = 0; @@ -301,33 +304,58 @@ bool M17DemodProcessor::decode_packet(mobilinkd::M17FrameDecoder::packet_buffer_ if (packet_segment[25] & 0x80) // last frame of packet. { size_t packet_size = (packet_segment[25] & 0x7F) >> 2; - packet_size = std::min(packet_size, size_t(25)); + packet_size = std::min(packet_size, size_t(25)); // on last frame this is the remainder byte count + m_packetFrameCounter = 0; for (size_t i = 0; i != packet_size; ++i) { m_currentPacket.push_back(packet_segment[i]); } + if (m_currentPacket.size() < 3) { + qDebug() << "M17DemodProcessor::decode_packet: too small:" << m_currentPacket.size(); + return false; + } + boost::crc_optimal<16, 0x1021, 0xFFFF, 0xFFFF, true, true> crc; crc.process_bytes(&m_currentPacket.front(), m_currentPacket.size()); - uint16_t checksum = crc.checksum(); + uint16_t calcChecksum = crc.checksum(); + uint16_t xmitChecksum = m_currentPacket.back() + (1<<8) * m_currentPacket.end()[-2]; - if (checksum == 0x0f47) + if (calcChecksum == xmitChecksum) // (checksum == 0x0f47) { - std::string ax25; - ax25.reserve(m_currentPacket.size()); + uint8_t protocol = m_currentPacket.front(); + m_stdPacketProtocol = protocol < (int) StdPacketUnknown ? (StdPacketProtocol) protocol : StdPacketUnknown; + qDebug() << "M17DemodProcessor::decode_packet: protocol: " << m_stdPacketProtocol; - for (auto c : m_currentPacket) { - ax25.push_back(char(c)); + if (m_stdPacketProtocol == StdPacketAX25) + { + std::string ax25; + ax25.reserve(m_currentPacket.size()); + + for (auto c : m_currentPacket) { + ax25.push_back(char(c)); + } + + mobilinkd::ax25_frame frame(ax25); + std::ostringstream oss; + mobilinkd::write(oss, frame); // TODO: get details + qDebug() << "M17DemodProcessor::decode_packet: AX25:" << oss.str().c_str(); + } + else if (m_stdPacketProtocol == StdPacketSMS) + { + std::ostringstream oss; + + for (std::vector::const_iterator it = m_currentPacket.begin()+1; it < m_currentPacket.end()-2; ++it) { + oss << *it; + } + + qDebug() << "M17DemodProcessor::decode_packet: SMS:" << oss.str().c_str(); } - mobilinkd::ax25_frame frame(ax25); - std::ostringstream oss; - mobilinkd::write(oss, frame); // TODO: get details - qDebug() << "M17DemodProcessor::decode_packet: " << oss.str().c_str(); return true; } - qWarning() << "M17DemodProcessor::decode_packet: Packet checksum error: " << std::hex << checksum << std::dec; + qWarning() << "M17DemodProcessor::decode_packet: Packet checksum error: " << std::hex << calcChecksum << "vs" << xmitChecksum << std::dec; return false; } @@ -450,8 +478,8 @@ void M17DemodProcessor::upsample(int upsampling, const int16_t *in, int nbSample for (int j = 1; j <= upsampling; j++) { upsample = (qint16) m_upsamplingFilter.runLP(cur*m_upsamplingFactors[j] + prev*m_upsamplingFactors[upsampling-j]); - m_audioBuffer[m_audioBufferFill].l = upsample; //m_compressor.compress(upsample); - m_audioBuffer[m_audioBufferFill].r = upsample; //m_compressor.compress(upsample); + m_audioBuffer[m_audioBufferFill].l = m_compressor.compress(upsample); + m_audioBuffer[m_audioBufferFill].r = m_compressor.compress(upsample); if (m_audioBufferFill < m_audioBuffer.size() - 1) { ++m_audioBufferFill; @@ -492,3 +520,12 @@ void M17DemodProcessor::setVolumeFactors() m_upsamplingFactors[i] = (i*m_volume) / (float) m_upsampling; } } + +M17DemodProcessor::StdPacketProtocol M17DemodProcessor::getStdPacketProtocol() const +{ + if (m_streamElsePacket) { + return StdPacketUnknown; + } else { + return m_stdPacketProtocol; + } +} diff --git a/plugins/channelrx/demodm17/m17demodprocessor.h b/plugins/channelrx/demodm17/m17demodprocessor.h index fa9c96105..bba5a86f8 100644 --- a/plugins/channelrx/demodm17/m17demodprocessor.h +++ b/plugins/channelrx/demodm17/m17demodprocessor.h @@ -30,6 +30,18 @@ class M17DemodProcessor : public QObject { Q_OBJECT public: + enum StdPacketProtocol + { + StdPacketRaw, + StdPacketAX25, + StdPacketAPRS, + StdPacket6LoWPAN, + StdPacketIPv4, + StdPacketSMS, + StdPacketWinlink, + StdPacketUnknown + }; + M17DemodProcessor(); ~M17DemodProcessor(); @@ -47,7 +59,9 @@ public: const QString& getSrcCall() const { return m_srcCall; } const QString& getDestcCall() const { return m_destCall; } const QString& getTypeInfo() const { return m_typeInfo; } + bool getStreamElsePacket() const { return m_streamElsePacket; } uint16_t getCRC() const { return m_crc; } + StdPacketProtocol getStdPacketProtocol() const; void getDiagnostics( bool& dcd, @@ -110,9 +124,11 @@ private: QString m_srcCall; QString m_destCall; QString m_typeInfo; + bool m_streamElsePacket; std::array m_metadata; uint16_t m_crc; uint32_t m_lsfCount; // Incremented each time a new LSF is decoded. Reset when lock is lost. + StdPacketProtocol m_stdPacketProtocol; static bool handle_frame(mobilinkd::M17FrameDecoder::output_buffer_t const& frame, int viterbi_cost); static void diagnostic_callback( diff --git a/plugins/channelrx/demodm17/m17demodsink.h b/plugins/channelrx/demodm17/m17demodsink.h index 3785b6f17..503c9cd2e 100644 --- a/plugins/channelrx/demodm17/m17demodsink.h +++ b/plugins/channelrx/demodm17/m17demodsink.h @@ -96,7 +96,9 @@ public: const QString& getSrcCall() const { return m_m17DemodProcessor.getSrcCall(); } const QString& getDestcCall() const { return m_m17DemodProcessor.getDestcCall(); } const QString& getTypeInfo() const { return m_m17DemodProcessor.getTypeInfo(); } + bool getStreamElsePacket() const { return m_m17DemodProcessor.getStreamElsePacket(); } uint16_t getCRC() const { return m_m17DemodProcessor.getCRC(); } + int getStdPacketProtocol() const { return (int) m_m17DemodProcessor.getStdPacketProtocol(); } private: struct MagSqLevelsStore diff --git a/plugins/channelrx/demodm17/m17statustextdialog.cpp b/plugins/channelrx/demodm17/m17statustextdialog.cpp index b1de33434..0db458f08 100644 --- a/plugins/channelrx/demodm17/m17statustextdialog.cpp +++ b/plugins/channelrx/demodm17/m17statustextdialog.cpp @@ -39,17 +39,17 @@ M17StatusTextDialog::~M17StatusTextDialog() void M17StatusTextDialog::addLine(const QString& line) { - if ((line.size() > 0) && (line != m_lastLine)) + if (line.size() > 0) { QDateTime dt = QDateTime::currentDateTime(); QString dateStr = dt.toString("HH:mm:ss"); QTextCursor cursor = ui->logEdit->textCursor(); cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); cursor.insertText(tr("%1 %2\n").arg(dateStr).arg(line)); + if (ui->pinToLastLine->isChecked()) { ui->logEdit->verticalScrollBar()->setValue(ui->logEdit->verticalScrollBar()->maximum()); } - m_lastLine = line; } } diff --git a/plugins/channelrx/demodm17/m17statustextdialog.h b/plugins/channelrx/demodm17/m17statustextdialog.h index 2158d9b44..797f5509d 100644 --- a/plugins/channelrx/demodm17/m17statustextdialog.h +++ b/plugins/channelrx/demodm17/m17statustextdialog.h @@ -36,7 +36,6 @@ public: private: Ui::M17StatusTextDialog* ui; - QString m_lastLine; private slots: void on_clear_clicked(); diff --git a/plugins/channelrx/demodm17/m17statustextdialog.ui b/plugins/channelrx/demodm17/m17statustextdialog.ui index a3130d47d..45c85eba6 100644 --- a/plugins/channelrx/demodm17/m17statustextdialog.ui +++ b/plugins/channelrx/demodm17/m17statustextdialog.ui @@ -109,6 +109,7 @@ Liberation Mono + 9 @@ -148,32 +149,32 @@ buttonBox accepted() - DSDStatusTextDialog + M17StatusTextDialog accept() - 257 - 194 + 369 + 357 - 157 - 203 + 369 + 189 buttonBox rejected() - DSDStatusTextDialog + M17StatusTextDialog reject() - 314 - 194 + 369 + 357 - 286 - 203 + 369 + 189