From 0b5a6cce1f55eae10c158275cae9368c3f2c894d Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Tue, 17 Aug 2021 16:11:50 +0200 Subject: [PATCH 01/79] dual meter support/WHATSNEW --- WHATSNEW | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index 4cebf2d..77dd589 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -6,5 +6,5 @@ The following highlights are in this 1.x-release: build process changed: you can add the install prefix (derSuessmann) added "do not ask again" for switching off rig and exiting wfview added opus as audio transport - + dual meter support From 390f9500dc9c16dde7cf043c4bea4e77a9aa36dd Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 17 Aug 2021 09:35:40 -0700 Subject: [PATCH 02/79] Added more support for the IC-9100 --- rigcommander.cpp | 27 +++++++++++++++++++++++++++ rigidentities.cpp | 3 +++ rigidentities.h | 1 + 3 files changed, 31 insertions(+) diff --git a/rigcommander.cpp b/rigcommander.cpp index 6c82219..173071d 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -3304,6 +3304,33 @@ void rigCommander::determineRigCaps() rigCaps.bsr[bandGen] = 0x11; rigCaps.modes = commonModes; break; + case model9100: + rigCaps.modelName = QString("IC-9100"); + rigCaps.rigctlModel = 3068; + rigCaps.hasSpectrum = false; + rigCaps.inputs.append(inputUSB); // TODO, add commands for this radio's inputs + rigCaps.inputs.append(inputACC); + rigCaps.hasLan = false; + rigCaps.hasEthernet = false; + rigCaps.hasWiFi = false; + rigCaps.hasFDcomms = false; + rigCaps.hasATU = true; + rigCaps.hasDV = true; + rigCaps.preamps.push_back('\x01'); + rigCaps.preamps.push_back('\x02'); + rigCaps.attenuators.insert(rigCaps.attenuators.end(),{ '\x20' }); + rigCaps.antennas = {0x00, 0x01}; + rigCaps.bands = standardHF; + rigCaps.bands.insert(rigCaps.bands.end(), standardVU.begin(), standardVU.end()); + rigCaps.bands.push_back(band23cm); + rigCaps.bands.push_back(bandGen); + rigCaps.bsr[band2m] = 0x11; + rigCaps.bsr[band70cm] = 0x12; + rigCaps.bsr[band23cm] = 0x13; + rigCaps.bsr[bandGen] = 0x14; + rigCaps.modes = commonModes; + rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modeDV, 0x17, "DV")}); + break; default: rigCaps.modelName = QString("IC-0x%1").arg(rigCaps.modelID, 2, 16); rigCaps.hasSpectrum = false; diff --git a/rigidentities.cpp b/rigidentities.cpp index 7b113f7..13988b4 100644 --- a/rigidentities.cpp +++ b/rigidentities.cpp @@ -67,6 +67,9 @@ model_kind determineRadioModel(unsigned char rigID) case model756proiii: rig = model756proiii; break; + case model9100: + rig = model9100; + break; default: rig = modelUnknown; break; diff --git a/rigidentities.h b/rigidentities.h index bae0609..17f0b3f 100644 --- a/rigidentities.h +++ b/rigidentities.h @@ -33,6 +33,7 @@ enum model_kind { model756proii = 0x64, model756proiii = 0x6E, model910h = 0x60, + model9100 = 0x7C, modelUnknown = 0xFF }; From b8b2892a1bf0f2af8b725e9671094c753313ef37 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 17 Aug 2021 17:54:41 +0100 Subject: [PATCH 03/79] Remove unneeded submodules --- .gitmodules | 6 ------ opus-tools | 1 - rtaudio | 1 - 3 files changed, 8 deletions(-) delete mode 160000 opus-tools delete mode 160000 rtaudio diff --git a/.gitmodules b/.gitmodules index 0e24a44..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "opus-tools"] - path = opus-tools - url = https://github.com/xiph/opus-tools.git -[submodule "rtaudio"] - path = rtaudio - url = https://github.com/thestk/rtaudio.git diff --git a/opus-tools b/opus-tools deleted file mode 160000 index ae5d6d5..0000000 --- a/opus-tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ae5d6d59e82ef40300a4dece7897499685f87184 diff --git a/rtaudio b/rtaudio deleted file mode 160000 index c9bf99d..0000000 --- a/rtaudio +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c9bf99d414cf81d19ef0ddd00212a4a58ccd99c6 From f44dd4bda2a00d2cbba5499dcebafab16a4bc08b Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 17 Aug 2021 14:00:37 -0700 Subject: [PATCH 04/79] Added IC-736 --- rigcommander.cpp | 20 ++++++++++++++++++++ rigidentities.h | 1 + 2 files changed, 21 insertions(+) diff --git a/rigcommander.cpp b/rigcommander.cpp index 173071d..fad3854 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -3247,6 +3247,26 @@ void rigCommander::determineRigCaps() createMode(modeRTTY, 0x04, "RTTY"), createMode(modeRTTY_R, 0x08, "RTTY-R") }; break; + case model736: + rigCaps.modelName = QString("IC-736"); + rigCaps.rigctlModel = 3020; + rigCaps.hasSpectrum = false; + rigCaps.inputs.clear(); + rigCaps.hasLan = false; + rigCaps.hasEthernet = false; + rigCaps.hasWiFi = false; + rigCaps.hasFDcomms = false; + rigCaps.hasATU = false; + rigCaps.hasPTTCommand = false; + rigCaps.hasDataModes = false; + rigCaps.attenuators.push_back('\x20'); + rigCaps.preamps.push_back('\x01'); + rigCaps.bands = standardHF; + rigCaps.modes = { createMode(modeLSB, 0x00, "LSB"), createMode(modeUSB, 0x01, "USB"), + createMode(modeAM, 0x02, "AM"), + createMode(modeCW, 0x03, "CW"), createMode(modeCW_R, 0x07, "CW-R"), + }; + break; case model756pro: rigCaps.modelName = QString("IC-756 Pro"); rigCaps.rigctlModel = 3027; diff --git a/rigidentities.h b/rigidentities.h index 17f0b3f..dbc147e 100644 --- a/rigidentities.h +++ b/rigidentities.h @@ -29,6 +29,7 @@ enum model_kind { model705 = 0xA4, model706 = 0x58, model718 = 0x5E, + model736 = 0x40, model756pro = 0x5C, model756proii = 0x64, model756proiii = 0x6E, From c2840f43d9e7a7fe2434ba9d15e85138cf37c633 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 18 Aug 2021 12:11:23 +0100 Subject: [PATCH 05/79] Update wfview.vcxproj --- wfview.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wfview.vcxproj b/wfview.vcxproj index 847643e..bf3abb6 100644 --- a/wfview.vcxproj +++ b/wfview.vcxproj @@ -57,7 +57,7 @@ Sync release\ MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="eb2f897";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="fc2d1e2";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) false MultiThreadedDLL @@ -85,7 +85,7 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"eb2f897\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"fc2d1e2\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h @@ -99,7 +99,7 @@ Sync debug\ Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="eb2f897";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="fc2d1e2";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) false MultiThreadedDebugDLL true @@ -124,7 +124,7 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"eb2f897\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"fc2d1e2\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h From 58a6477f53bad1a38cb664b9c5a0e5f33f48eac4 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 19 Aug 2021 10:21:30 +0100 Subject: [PATCH 06/79] Set audio threads to be realtime priority --- udphandler.cpp | 2 ++ udpserver.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/udphandler.cpp b/udphandler.cpp index fd25042..3d71c05 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -732,6 +732,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio rxaudio = new audioHandler(); rxAudioThread = new QThread(this); + rxAudioThread->setPriority(QThread::TimeCriticalPriority); rxaudio->moveToThread(rxAudioThread); @@ -749,6 +750,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio txaudio = new audioHandler(); txAudioThread = new QThread(this); + txAudioThread->setPriority(QThread::TimeCriticalPriority); txaudio->moveToThread(txAudioThread); diff --git a/udpserver.cpp b/udpserver.cpp index 6bc80a7..8627284 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -382,6 +382,7 @@ void udpServer::controlReceived() txaudio = new audioHandler(); txAudioThread = new QThread(this); + txAudioThread->setPriority(QThread::TimeCriticalPriority); txaudio->moveToThread(txAudioThread); txAudioThread->start(); @@ -402,6 +403,8 @@ void udpServer::controlReceived() rxaudio = new audioHandler(); rxAudioThread = new QThread(this); + rxAudioThread->setPriority(QThread::TimeCriticalPriority); + rxaudio->moveToThread(rxAudioThread); rxAudioThread->start(); From 5b1ed2dc353e7f6c3e843027c9f02a948dd46624 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 23 Aug 2021 23:59:40 +0100 Subject: [PATCH 07/79] Set audio thread priority in the correct place! --- udphandler.cpp | 6 +++--- udpserver.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index c320e7d..a7e0717 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -718,7 +718,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio rxaudio->moveToThread(rxAudioThread); - rxAudioThread->start(); + rxAudioThread->start(QThread::TimeCriticalPriority); connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup))); @@ -735,8 +735,8 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio txaudio->moveToThread(txAudioThread); - txAudioThread->start(); - + txAudioThread->start(QThread::TimeCriticalPriority); + connect(this, SIGNAL(setupTxAudio(audioSetup)), txaudio, SLOT(init(audioSetup))); connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater())); diff --git a/udpserver.cpp b/udpserver.cpp index b6eb299..65a26c8 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -384,7 +384,7 @@ void udpServer::controlReceived() txAudioThread = new QThread(this); txaudio->moveToThread(txAudioThread); - txAudioThread->start(); + txAudioThread->start(QThread::TimeCriticalPriority); connect(this, SIGNAL(setupTxAudio(audioSetup)), txaudio, SLOT(init(audioSetup))); connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater())); @@ -402,8 +402,8 @@ void udpServer::controlReceived() rxaudio = new audioHandler(); rxAudioThread = new QThread(this); - rxaudio->moveToThread(rxAudioThread); - rxAudioThread->start(); + + rxAudioThread->start(QThread::TimeCriticalPriority); connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup))); connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater())); From 57b6f955c66358a2c0af6a4f7c66c9712bb8b476 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 23 Aug 2021 23:59:40 +0100 Subject: [PATCH 08/79] Set audio thread priority in the correct place! --- udphandler.cpp | 6 +++--- udpserver.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index fd25042..d5368a4 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -735,7 +735,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio rxaudio->moveToThread(rxAudioThread); - rxAudioThread->start(); + rxAudioThread->start(QThread::TimeCriticalPriority); connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup))); @@ -752,8 +752,8 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio txaudio->moveToThread(txAudioThread); - txAudioThread->start(); - + txAudioThread->start(QThread::TimeCriticalPriority); + connect(this, SIGNAL(setupTxAudio(audioSetup)), txaudio, SLOT(init(audioSetup))); connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater())); diff --git a/udpserver.cpp b/udpserver.cpp index 6bc80a7..4ac5f69 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -384,7 +384,7 @@ void udpServer::controlReceived() txAudioThread = new QThread(this); txaudio->moveToThread(txAudioThread); - txAudioThread->start(); + txAudioThread->start(QThread::TimeCriticalPriority); connect(this, SIGNAL(setupTxAudio(audioSetup)), txaudio, SLOT(init(audioSetup))); connect(txAudioThread, SIGNAL(finished()), txaudio, SLOT(deleteLater())); @@ -401,9 +401,10 @@ void udpServer::controlReceived() inAudio.samplerate = current->rxSampleRate; rxaudio = new audioHandler(); - rxAudioThread = new QThread(this); - rxaudio->moveToThread(rxAudioThread); - rxAudioThread->start(); + rxAudioThread = new QThread(this) + + rxaudio->moveToThread(rxAudioThread); + rxAudioThread->start(QThread::TimeCriticalPriority); connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup))); connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater())); From 7c9610283c29513659557b55eae66ab31248d3dc Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 24 Aug 2021 09:34:40 +0100 Subject: [PATCH 09/79] Replace missing ; --- udpserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/udpserver.cpp b/udpserver.cpp index a23f28e..a23eef2 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -403,7 +403,7 @@ void udpServer::controlReceived() rxaudio = new audioHandler(); - rxAudioThread = new QThread(this) + rxAudioThread = new QThread(this); rxaudio->moveToThread(rxAudioThread); rxAudioThread->start(QThread::TimeCriticalPriority); From 71c12b508fceabd88131db754e017f8728ce0dc6 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Wed, 25 Aug 2021 19:05:52 +0200 Subject: [PATCH 10/79] pttyhandler: add errno.h --- pttyhandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/pttyhandler.cpp b/pttyhandler.cpp index b671aa0..c958827 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #endif // Copyright 2017-2021 Elliott H. Liggett & Phil Taylor From 8d96c97f3ac898518f4f5d2a3440c0a725a8295a Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Fri, 27 Aug 2021 11:45:45 +0200 Subject: [PATCH 11/79] bumped version to 1.2 alpha for testing --- aboutbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aboutbox.cpp b/aboutbox.cpp index fa8a6c1..39d0be7 100644 --- a/aboutbox.cpp +++ b/aboutbox.cpp @@ -12,7 +12,7 @@ aboutbox::aboutbox(QWidget *parent) : ui->logoBtn->setIcon(QIcon(":resources/wfview.png")); ui->logoBtn->setStyleSheet("Text-align:left"); - ui->topText->setText("wfview version 1.1"); + ui->topText->setText("wfview version 1.2a"); QString head = QString(""); QString copyright = QString("Copyright 2017-2021 Elliott H. Liggett, W6EL. All rights reserved. wfview source code is licensed under the GNU GPLv3."); From 3a9f9db4a3968dc3d45b04ea234933fc5e2861fa Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Fri, 27 Aug 2021 18:06:09 +0100 Subject: [PATCH 12/79] Add saving of meter2 state --- wfmain.cpp | 24 ++++++++++++++++++++---- wfmain.h | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 2f94485..95496e7 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -685,6 +685,8 @@ void wfmain::setupMainUI() ui->meter2Widget->hide(); ui->meter2selectionCombo->show(); + ui->meter2selectionCombo->setCurrentIndex((int)prefs.meter2Type); + ui->secondaryMeterSelectionLabel->show(); @@ -1236,6 +1238,7 @@ void wfmain::setDefPrefs() defPrefs.wftheme = static_cast(QCPColorGradient::gpJet); defPrefs.confirmExit = true; defPrefs.confirmPowerOff = true; + defPrefs.meter2Type = meterNone; udpDefPrefs.ipAddress = QString(""); udpDefPrefs.controlLANPort = 50001; @@ -1269,7 +1272,7 @@ void wfmain::loadSettings() setWindowState(Qt::WindowActive); // Works around QT bug to returns window+keyboard focus. prefs.confirmExit = settings->value("ConfirmExit", defPrefs.confirmExit).toBool(); prefs.confirmPowerOff = settings->value("ConfirmPowerOff", defPrefs.confirmPowerOff).toBool(); - + prefs.meter2Type = static_cast(settings->value("Meter2Type", defPrefs.meter2Type).toInt()); settings->endGroup(); // Load color schemes: @@ -1570,6 +1573,7 @@ void wfmain::saveSettings() settings->setValue("WFLength", prefs.wflength); settings->setValue("ConfirmExit", prefs.confirmExit); settings->setValue("ConfirmPowerOff", prefs.confirmPowerOff); + settings->setValue("Meter2Type", (int)prefs.meter2Type); settings->endGroup(); // Radio and Comms: C-IV addr, port to use @@ -3003,6 +3007,16 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) // recalculate command timing now that we know the rig better: calculateTimingParameters(); initPeriodicCommands(); + + for (int i = 0; i < ui->meter2selectionCombo->count(); i++) + { + if (static_cast(ui->meter2selectionCombo->itemData(i).toInt()) == prefs.meter2Type) + { + qInfo() << "*******setting meter id" << i; + ui->meter2selectionCombo->setCurrentIndex(i); + on_meter2selectionCombo_activated(i); + } + } } } @@ -3218,9 +3232,9 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e void wfmain::receiveSpectrumMode(spectrumMode spectMode) { - for(int i=0; i < ui->spectrumModeCombo->count(); i++) + for (int i = 0; i < ui->spectrumModeCombo->count(); i++) { - if(static_cast(ui->spectrumModeCombo->itemData(i).toInt()) == spectMode) + if (static_cast(ui->spectrumModeCombo->itemData(i).toInt()) == spectMode) { ui->spectrumModeCombo->blockSignals(true); ui->spectrumModeCombo->setCurrentIndex(i); @@ -5241,7 +5255,7 @@ void wfmain::on_meter2selectionCombo_activated(int index) meterKind oldMeterType; newMeterType = static_cast(ui->meter2selectionCombo->currentData().toInt()); oldMeterType = ui->meter2Widget->getMeterType(); - + qInfo() << "*******setting meter type" << newMeterType; if(newMeterType == oldMeterType) return; @@ -5259,6 +5273,8 @@ void wfmain::on_meter2selectionCombo_activated(int index) ui->meter2Widget->setMeterType(newMeterType); insertPeriodicCommandUnique(newCmd); } + prefs.meter2Type = newMeterType; + (void)index; } diff --git a/wfmain.h b/wfmain.h index 934870d..390b161 100644 --- a/wfmain.h +++ b/wfmain.h @@ -477,6 +477,7 @@ private slots: void on_rigctldPortTxt_editingFinished(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -703,6 +704,7 @@ private: int wftheme; bool confirmExit; bool confirmPowerOff; + meterKind meter2Type; // plot scheme } prefs; From 97e5ff9ff8d9e9c411391c937d66b945062de144 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Fri, 27 Aug 2021 18:07:45 +0100 Subject: [PATCH 13/79] Remove unneeded debugging --- wfmain.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 95496e7..e8455af 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3008,13 +3008,15 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) calculateTimingParameters(); initPeriodicCommands(); + // Set the second meter here as I suspect we need to be connected for it to work? for (int i = 0; i < ui->meter2selectionCombo->count(); i++) { if (static_cast(ui->meter2selectionCombo->itemData(i).toInt()) == prefs.meter2Type) { - qInfo() << "*******setting meter id" << i; + // I thought that setCurrentIndex() would call the activated() function for the combobox + // but it doesn't, so call it manually. ui->meter2selectionCombo->setCurrentIndex(i); - on_meter2selectionCombo_activated(i); + on_meter2selectionCombo_activated(i); } } } @@ -5255,7 +5257,6 @@ void wfmain::on_meter2selectionCombo_activated(int index) meterKind oldMeterType; newMeterType = static_cast(ui->meter2selectionCombo->currentData().toInt()); oldMeterType = ui->meter2Widget->getMeterType(); - qInfo() << "*******setting meter type" << newMeterType; if(newMeterType == oldMeterType) return; From 67c80c25105dd9e58ddfc6da8e336a5ba4672270 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 29 Aug 2021 00:16:31 +0100 Subject: [PATCH 14/79] Add better detection of ci-v transceive disable --- pttyhandler.cpp | 11 ++++++++--- pttyhandler.h | 6 +++++- rigcommander.cpp | 28 ++++++++++++++++++++++++++-- rigidentities.h | 2 ++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/pttyhandler.cpp b/pttyhandler.cpp index b671aa0..c374e7f 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -217,9 +217,8 @@ void pttyHandler::receiveDataIn(int fd) { civId = (quint8)inPortData[lastFE + 2]; qInfo(logSerial()) << "pty remote CI-V changed:" << hex << (quint8)civId; } - - // filter 1A 05 01 12/27 = C-IV transceive command before forwarding on. - if (inPortData.contains(QByteArrayLiteral("\x1a\x05\x01\x12")) || inPortData.contains(QByteArrayLiteral("\x1a\x05\x01\x27"))) + // filter C-IV transceive command before forwarding on. + if (inPortData.contains(rigCaps.transceiveCommand)) { //qInfo(logSerial()) << "Filtered transceive command"; //printHex(inPortData, false, true); @@ -330,4 +329,10 @@ void pttyHandler::printHex(const QByteArray& pdata, bool printVert, bool printHo qDebug(logSerial()) << "----- End hex dump -----"; } +void pttyHandler::receiveFoundRigID(rigCapabilities rigCaps) { + this->rigCaps = rigCaps; + qInfo(logSerial) << "Received rigCapabilities for" << rigCaps.modelName; + +} + diff --git a/pttyhandler.h b/pttyhandler.h index da52ef8..14c9bfc 100644 --- a/pttyhandler.h +++ b/pttyhandler.h @@ -9,6 +9,8 @@ #include #include +#include "rigidentities.h" + // This class abstracts the comm port in a useful way and connects to // the command creator and command parser. @@ -27,6 +29,7 @@ private slots: void receiveDataIn(int fd); // from physical port void receiveDataFromRigToPtty(const QByteArray& data); void debugThis(); + void receiveFoundRigID(rigCapabilities rigCaps); signals: void haveTextMessage(QString message); // status, debug only @@ -66,8 +69,9 @@ private: mutable QMutex mutex; void printHex(const QByteArray& pdata, bool printVert, bool printHoriz); bool disableTransceive = false; - QSocketNotifier *ptReader = nullptr; + QSocketNotifier *ptReader = Q_NULLPTR; quint8 civId=0; + rigCapabilities rigCaps; }; #endif // PTTYHANDLER_H diff --git a/rigcommander.cpp b/rigcommander.cpp index 6c82219..e78fd33 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -61,7 +61,6 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu // data from the ptty to the rig: connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray))); - // data from the program to the comm port: connect(this, SIGNAL(dataForComm(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray))); @@ -73,6 +72,9 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu connect(this, SIGNAL(getMoreDebug()), comm, SLOT(debugThis())); connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis())); + + connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities))); + emit commReady(); } @@ -137,6 +139,8 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString))); connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis())); + connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities))); + emit haveAfGain(rxSetup.localAFgain); } @@ -2880,6 +2884,8 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(band630m); rigCaps.bands.push_back(band2200m); rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x71"); + break; case modelR8600: rigCaps.modelName = QString("IC-R8600"); @@ -2915,6 +2921,7 @@ void rigCommander::determineRigCaps() createMode(modeNXDN_VN, 0x19, "NXDN-VN"), createMode(modeNXDN_N, 0x20, "NXDN-N"), createMode(modeDCR, 0x21, "DCR")}); rigCaps.scopeCenterSpans.insert(rigCaps.scopeCenterSpans.end(), {createScopeCenter(cs1M, "±1M"), createScopeCenter(cs2p5M, "±2.5M")}); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x92"); break; case model9700: rigCaps.modelName = QString("IC-9700"); @@ -2943,6 +2950,7 @@ void rigCommander::determineRigCaps() rigCaps.modes = commonModes; rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modeDV, 0x17, "DV"), createMode(modeDD, 0x22, "DD")}); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x01\x27"); break; case model910h: rigCaps.modelName = QString("IC-910H"); @@ -2965,6 +2973,7 @@ void rigCommander::determineRigCaps() rigCaps.bsr[band70cm] = 0x02; rigCaps.bsr[band2m] = 0x01; rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x58"); break; case model7600: rigCaps.modelName = QString("IC-7600"); @@ -2989,6 +2998,7 @@ void rigCommander::determineRigCaps() rigCaps.modes = commonModes; rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modePSK, 0x12, "PSK"), createMode(modePSK_R, 0x13, "PSK-R")}); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x97"); break; case model7610: rigCaps.modelName = QString("IC-7610"); @@ -3020,6 +3030,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(band2200m); rigCaps.modes = commonModes; rigCaps.hasRXAntenna = true; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x01\x12"); break; case model7850: rigCaps.modelName = QString("IC-785x"); @@ -3052,6 +3063,7 @@ void rigCommander::determineRigCaps() rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modePSK, 0x12, "PSK"), createMode(modePSK_R, 0x13, "PSK-R")}); rigCaps.hasRXAntenna = true; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x01\x55"); break; case model705: rigCaps.modelName = QString("IC-705"); @@ -3088,6 +3100,7 @@ void rigCommander::determineRigCaps() rigCaps.modes = commonModes; rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modeWFM, 0x06, "WFM"), createMode(modeDV, 0x17, "DV")}); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x01\x31"); break; case model7000: rigCaps.modelName = QString("IC-7000"); @@ -3110,6 +3123,7 @@ void rigCommander::determineRigCaps() rigCaps.bsr[band70cm] = 0x12; rigCaps.bsr[bandGen] = 0x13; rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x92"); break; case model7410: rigCaps.modelName = QString("IC-7410"); @@ -3131,6 +3145,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(bandGen); rigCaps.bsr[bandGen] = 0x11; rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x40"); break; case model7100: rigCaps.modelName = QString("IC-7100"); @@ -3158,6 +3173,7 @@ void rigCommander::determineRigCaps() rigCaps.modes = commonModes; rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modeWFM, 0x06, "WFM"), createMode(modeDV, 0x17, "DV")}); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x95"); break; case model7200: rigCaps.modelName = QString("IC-7200"); @@ -3178,7 +3194,8 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(bandGen); rigCaps.bsr[bandGen] = 0x11; rigCaps.modes = commonModes; - break; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x03\x48"); + break; case model7700: rigCaps.modelName = QString("IC-7700"); rigCaps.rigctlModel = 3062; @@ -3204,6 +3221,7 @@ void rigCommander::determineRigCaps() rigCaps.modes = commonModes; rigCaps.modes.insert(rigCaps.modes.end(), {createMode(modePSK, 0x12, "PSK"), createMode(modePSK_R, 0x13, "PSK-R")}); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x95"); break; case model706: rigCaps.modelName = QString("IC-706"); @@ -3223,6 +3241,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(bandGen); rigCaps.modes = commonModes; rigCaps.modes.insert(rigCaps.modes.end(), createMode(modeWFM, 0x06, "WFM")); + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x00"); break; case model718: rigCaps.modelName = QString("IC-718"); @@ -3246,6 +3265,7 @@ void rigCommander::determineRigCaps() createMode(modeCW, 0x03, "CW"), createMode(modeCW_R, 0x07, "CW-R"), createMode(modeRTTY, 0x04, "RTTY"), createMode(modeRTTY_R, 0x08, "RTTY-R") }; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x00"); break; case model756pro: rigCaps.modelName = QString("IC-756 Pro"); @@ -3265,6 +3285,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(bandGen); rigCaps.bsr[bandGen] = 0x11; rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x00"); break; case model756proii: rigCaps.modelName = QString("IC-756 Pro II"); @@ -3284,6 +3305,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(bandGen); rigCaps.bsr[bandGen] = 0x11; rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x00"); break; case model756proiii: rigCaps.modelName = QString("IC-756 Pro III"); @@ -3303,6 +3325,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.push_back(bandGen); rigCaps.bsr[bandGen] = 0x11; rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x00"); break; default: rigCaps.modelName = QString("IC-0x%1").arg(rigCaps.modelID, 2, 16); @@ -3324,6 +3347,7 @@ void rigCommander::determineRigCaps() rigCaps.bands.insert(rigCaps.bands.end(), standardVU.begin(), standardVU.end()); rigCaps.bands.insert(rigCaps.bands.end(), {band23cm, band4m, band630m, band2200m, bandGen}); rigCaps.modes = commonModes; + rigCaps.transceiveCommand = QByteArrayLiteral("\x1a\x05\x00\x00"); qInfo(logRig()) << "Found unknown rig: 0x" << QString("%1").arg(rigCaps.modelID, 2, 16); break; } diff --git a/rigidentities.h b/rigidentities.h index bae0609..e905730 100644 --- a/rigidentities.h +++ b/rigidentities.h @@ -131,6 +131,8 @@ struct rigCapabilities { unsigned char bsr[20] = {0}; std::vector modes; + + QByteArray transceiveCommand; }; From 57e68571afed9866e3956f4286850c359f99d534 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 29 Aug 2021 00:25:23 +0100 Subject: [PATCH 15/79] Ignore control levels that we don't currently support --- rigcommander.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rigcommander.cpp b/rigcommander.cpp index e78fd33..9122449 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -1352,6 +1352,9 @@ void rigCommander::parseLevels() emit haveSql(level); rigState.squelch = level; break; + case '\x09': + // CW Pitch - ignore for now + break; case '\x0A': // TX RF level emit haveTxPower(level); @@ -1362,11 +1365,20 @@ void rigCommander::parseLevels() emit haveMicGain(level); rigState.micGain = level; break; + case '\x0C': + // CW Keying Speed - ignore for now + break; + case '\x0D': + // Notch filder setting - ignore for now + break; case '\x0E': // compressor level emit haveCompLevel(level); rigState.compLevel = level; break; + case '\x12': + // NB level - ignore for now + break; case '\x15': // monitor level emit haveMonitorLevel(level); From bf16dfe19a24664b0d975da9ac80e2a6ad4a5052 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 29 Aug 2021 11:51:53 +0100 Subject: [PATCH 16/79] Experimental support for split mode in rigctld --- rigcommander.cpp | 16 +++++++++++----- rigcommander.h | 2 +- rigctld.cpp | 41 +++++++++++++++++++++++++++++++++-------- rigctld.h | 2 +- wfmain.cpp | 43 ++++++++++++++++++++++--------------------- wfmain.h | 2 +- 6 files changed, 69 insertions(+), 37 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 9122449..03537dc 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -557,18 +557,24 @@ void rigCommander::getSpectrumMode() prepDataAndSend(specModePayload); } -void rigCommander::setFrequency(freqt freq) +void rigCommander::setFrequency(unsigned char vfo, freqt freq) { - //QByteArray freqPayload = makeFreqPayload(freq); QByteArray freqPayload = makeFreqPayload(freq); QByteArray cmdPayload; cmdPayload.append(freqPayload); - cmdPayload.prepend('\x00'); - + if (vfo == 0) { + rigState.vfoAFreq = freq; + cmdPayload.prepend('\x00'); + } + else + { + rigState.vfoBFreq = freq; + cmdPayload.prepend(vfo); + cmdPayload.prepend('\x25'); + } //printHex(cmdPayload, false, true); prepDataAndSend(cmdPayload); - rigState.vfoAFreq = freq; } QByteArray rigCommander::makeFreqPayload(freqt freq) diff --git a/rigcommander.h b/rigcommander.h index 1de8bc3..1486028 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -171,7 +171,7 @@ public slots: void getScopeMode(); // Frequency, Mode, BSR: - void setFrequency(freqt freq); + void setFrequency(unsigned char vfo, freqt freq); void getFrequency(); void setMode(unsigned char mode, unsigned char modeFilter); void setMode(mode_info); diff --git a/rigctld.cpp b/rigctld.cpp index 4879728..27dd6c3 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -57,7 +57,7 @@ rigCtlD::~rigCtlD() void rigCtlD::receiveFrequency(freqt freq) { - emit setFrequency(freq); + emit setFrequency(0, freq); } void rigCtlD::receiveStateInfo(rigStateStruct* state) @@ -301,7 +301,7 @@ void rigCtlClient::socketReadyRead() if (ok) { freq.Hz = static_cast(newFreq); qDebug(logRigCtlD()) << QString("Set frequency: %1 (%2)").arg(freq.Hz).arg(command[1]); - emit parent->setFrequency(freq); + emit parent->setFrequency(0, freq); } } else if (command[0] == "1" || command[0] == "dump_caps") @@ -465,21 +465,46 @@ void rigCtlClient::socketReadyRead() } response.append(resp); } - else if (command[0] == "I" || command[0] == "set_split_freq") + else if (command.length() > 1 && command[0] == "I" || command[0] == "set_split_freq") { setCommand = true; + freqt freq; + bool ok = false; + double newFreq = 0.0f; + newFreq = command[1].toDouble(&ok); + if (ok) { + freq.Hz = static_cast(newFreq); + qDebug(logRigCtlD()) << QString("set_split_freq: %1 (%2)").arg(freq.Hz).arg(command[1]); + emit parent->setFrequency(1, freq); + } } - else if (command[0] == "m" || command[0] == "get_mode") + else if (command.length() > 2 && (command[0] == "X" || command[0] == "set_split_mode")) { + setCommand = true; + } + else if (command.length() > 0 && (command[0] == "x" || command[0] == "get_split_mode")) + { if (longReply) { - response.append(QString("Mode: %1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("Passband: %1").arg(getFilter(rigState->mode, rigState->filter))); + response.append(QString("TX Mode: %1").arg(getMode(rigState->mode, rigState->datamode))); + response.append(QString("TX Passband: %1").arg(getFilter(rigState->mode, rigState->filter))); } else { response.append(QString("%1").arg(getMode(rigState->mode, rigState->datamode))); response.append(QString("%1").arg(getFilter(rigState->mode, rigState->filter))); } } + + else if (command[0] == "m" || command[0] == "get_mode") + { + if (longReply) { + response.append(QString("Mode: %1").arg(getMode(rigState->mode, rigState->datamode))); + response.append(QString("Passband: %1").arg(getFilter(rigState->mode, rigState->filter))); + } + else { + response.append(QString("%1").arg(getMode(rigState->mode, rigState->datamode))); + response.append(QString("%1").arg(getFilter(rigState->mode, rigState->filter))); + } + } else if (command[0] == "M" || command[0] == "set_mode") { // Set mode @@ -973,8 +998,8 @@ void rigCtlClient::socketReadyRead() } else if (command.length() > 1 && (command[0] == 0x87 || command[0] == "set_powerstat")) { - setCommand = true; - if (command[1] == "0") + setCommand = true; + if (command[1] == "0") { emit parent->sendPowerOff(); } diff --git a/rigctld.h b/rigctld.h index 51f3698..0b71fa9 100644 --- a/rigctld.h +++ b/rigctld.h @@ -336,7 +336,7 @@ signals: void onStarted(); void onStopped(); void sendData(QString data); - void setFrequency(freqt freq); + void setFrequency(unsigned char vfo, freqt freq); void setPTT(bool state); void setMode(unsigned char mode, unsigned char modeFilter); void setDataMode(bool dataOn, unsigned char modeFilter); diff --git a/wfmain.cpp b/wfmain.cpp index e8455af..8e93e07 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -273,7 +273,7 @@ void wfmain::rigConnections() connect(this, SIGNAL(setScopeMode(spectrumMode)), rig, SLOT(setSpectrumMode(spectrumMode))); connect(this, SIGNAL(getScopeMode()), rig, SLOT(getScopeMode())); - connect(this, SIGNAL(setFrequency(freqt)), rig, SLOT(setFrequency(freqt))); + connect(this, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); connect(this, SIGNAL(setScopeEdge(char)), rig, SLOT(setScopeEdge(char))); connect(this, SIGNAL(setScopeSpan(char)), rig, SLOT(setScopeSpan(char))); //connect(this, SIGNAL(getScopeMode()), rig, SLOT(getScopeMode())); @@ -400,7 +400,7 @@ void wfmain::makeRig() if (rigCtl != Q_NULLPTR) { connect(rig, SIGNAL(stateInfo(rigStateStruct*)), rigCtl, SLOT(receiveStateInfo(rigStateStruct*))); connect(this, SIGNAL(requestRigState()), rig, SLOT(sendState())); - connect(rigCtl, SIGNAL(setFrequency(freqt)), rig, SLOT(setFrequency(freqt))); + connect(rigCtl, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); connect(rigCtl, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); connect(rigCtl, SIGNAL(setDataMode(bool, unsigned char)), rig, SLOT(setDataMode(bool, unsigned char))); connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool))); @@ -2011,7 +2011,7 @@ void wfmain::shortcutMinus() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2025,7 +2025,7 @@ void wfmain::shortcutPlus() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2039,7 +2039,7 @@ void wfmain::shortcutShiftMinus() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2053,7 +2053,7 @@ void wfmain::shortcutShiftPlus() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2067,7 +2067,7 @@ void wfmain::shortcutControlMinus() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2081,7 +2081,7 @@ void wfmain::shortcutControlPlus() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2095,7 +2095,7 @@ void wfmain::shortcutPageUp() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2109,7 +2109,7 @@ void wfmain::shortcutPageDown() f.MHzDouble = f.Hz / (double)1E6; setUIFreq(); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); } @@ -2350,7 +2350,7 @@ void wfmain::doCmd(commandtype cmddata) { lastFreqCmdTime_ms = QDateTime::currentMSecsSinceEpoch(); freqt f = (*std::static_pointer_cast(data)); - emit setFrequency(f); + emit setFrequency(0,f); break; } case cmdSetMode: @@ -3041,6 +3041,7 @@ void wfmain::initPeriodicCommands() if (rigCaps.hasRXAntenna) { insertSlowPeriodicCommand(cmdGetAntenna, 128); } + insertSlowPeriodicCommand(cmdGetDuplexMode, 128); } void wfmain::insertPeriodicCommand(cmds cmd, unsigned char priority) @@ -3261,7 +3262,7 @@ void wfmain::handlePlotDoubleClick(QMouseEvent *me) freqGo.Hz = roundFrequency(freqGo.Hz, tsWfScrollHz); freqGo.MHzDouble = (float)freqGo.Hz / 1E6; - //emit setFrequency(freq); + //emit setFrequency(0,freq); issueCmd(cmdSetFreq, freqGo); freq = freqGo; setUIFreq(); @@ -3286,7 +3287,7 @@ void wfmain::handleWFDoubleClick(QMouseEvent *me) freqGo.Hz = roundFrequency(freqGo.Hz, tsWfScrollHz); freqGo.MHzDouble = (float)freqGo.Hz / 1E6; - //emit setFrequency(freq); + //emit setFrequency(0,freq); issueCmd(cmdSetFreq, freqGo); freq = freqGo; setUIFreq(); @@ -3341,7 +3342,7 @@ void wfmain::handleWFScroll(QWheelEvent *we) f.MHzDouble = f.Hz / (double)1E6; freq = f; - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmdUniquePriority(cmdSetFreq, f); ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f')); //issueDelayedCommandUnique(cmdGetFreq); @@ -3758,7 +3759,7 @@ void wfmain::on_freqDial_valueChanged(int value) ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f')); - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmdUniquePriority(cmdSetFreq, f); } else { ui->freqDial->blockSignals(true); @@ -3773,7 +3774,7 @@ void wfmain::receiveBandStackReg(freqt freqGo, char mode, char filter, bool data // read the band stack and apply by sending out commands qInfo(logSystem()) << __func__ << "BSR received into main: Freq: " << freqGo.Hz << ", mode: " << (unsigned int)mode << ", filter: " << (unsigned int)filter << ", data mode: " << dataOn; - //emit setFrequency(freq); + //emit setFrequency(0,freq); issueCmd(cmdSetFreq, freqGo); setModeVal = (unsigned char) mode; setFilterVal = (unsigned char) filter; @@ -3843,7 +3844,7 @@ void wfmain::on_band4mbtn_clicked() f.Hz = (70.200) * 1E6; } issueCmd(cmdSetFreq, f); - //emit setFrequency(f); + //emit setFrequency(0,f); issueDelayedCommandUnique(cmdGetFreq); ui->tabWidget->setCurrentIndex(0); } @@ -3910,7 +3911,7 @@ void wfmain::on_band60mbtn_clicked() freqt f; f.Hz = (5.3305) * 1E6; issueCmd(cmdSetFreq, f); - //emit setFrequency(f); + //emit setFrequency(0,f); issueDelayedCommandUnique(cmdGetFreq); ui->tabWidget->setCurrentIndex(0); } @@ -3931,7 +3932,7 @@ void wfmain::on_band630mbtn_clicked() { freqt f; f.Hz = 475 * 1E3; - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); ui->tabWidget->setCurrentIndex(0); @@ -3941,7 +3942,7 @@ void wfmain::on_band2200mbtn_clicked() { freqt f; f.Hz = 136 * 1E3; - //emit setFrequency(f); + //emit setFrequency(0,f); issueCmd(cmdSetFreq, f); issueDelayedCommandUnique(cmdGetFreq); ui->tabWidget->setCurrentIndex(0); @@ -5296,7 +5297,7 @@ void wfmain::on_enableRigctldChk_clicked(bool checked) if (rig != Q_NULLPTR) { // We are already connected to a rig. connect(rig, SIGNAL(stateInfo(rigStateStruct*)), rigCtl, SLOT(receiveStateInfo(rigStateStruct*))); - connect(rigCtl, SIGNAL(setFrequency(freqt)), rig, SLOT(setFrequency(freqt))); + connect(rigCtl, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); connect(rigCtl, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); connect(rigCtl, SIGNAL(setDataMode(bool, unsigned char)), rig, SLOT(setDataMode(bool, unsigned char))); connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool))); diff --git a/wfmain.h b/wfmain.h index 390b161..b921b9c 100644 --- a/wfmain.h +++ b/wfmain.h @@ -58,7 +58,7 @@ signals: // Frequency, mode, band: void getFrequency(); - void setFrequency(freqt freq); + void setFrequency(unsigned char vfo, freqt freq); void getMode(); void setMode(unsigned char modeIndex, unsigned char modeFilter); void setMode(mode_info); From f1221c6f1b9b71ad4228fdc2136f3b8b382958ea Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Tue, 31 Aug 2021 09:21:02 +0200 Subject: [PATCH 17/79] added 25 kHz step for tuning --- wfmain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wfmain.cpp b/wfmain.cpp index 8e93e07..e17d344 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -654,6 +654,7 @@ void wfmain::setupMainUI() ui->tuningStepCombo->addItem("9 kHz", (unsigned int) 9000); // European medium wave stepsize ui->tuningStepCombo->addItem("10 kHz", (unsigned int) 10000); ui->tuningStepCombo->addItem("12.5 kHz", (unsigned int) 12500); + ui->tuningStepCombo->addItem("25 kHz", (unsigned int) 25000); ui->tuningStepCombo->addItem("100 kHz", (unsigned int) 100000); ui->tuningStepCombo->addItem("250 kHz", (unsigned int) 250000); ui->tuningStepCombo->addItem("1 MHz", (unsigned int) 1000000); //for 23 cm and HF From 9413d20906ce844915a2e95fe01e6dd1b40ae9a1 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Tue, 7 Sep 2021 07:55:17 +0200 Subject: [PATCH 18/79] bumped version to 1.2 beta --- .swp | Bin 0 -> 12288 bytes aboutbox.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .swp diff --git a/.swp b/.swp new file mode 100644 index 0000000000000000000000000000000000000000..fbeaaba9ab9981e852f4edbefe8c4d1a01072e9f GIT binary patch literal 12288 zcmeI&%}T>S5C`y7PhM2&3yg|iAff8T2k@YR$JX<-JKav3?v^CBkc&^?gZLaim*Awf z7oiA3!NNa~oy=}_Gx*jlVYbHq^CF9_hT`OY|;%vgHhAC(I z`{^s!!2kpxuug%U_RaOx{82wXI;4YUdz}}<+7N&M1Rwwb2tWV=5P-lx6DTK*ag{ks?3<0uX=z1Rwwb2tWV=5P$##Ah3Y~Y~SlYca!8~&x*J2|I7FPGs{nH zpZ9OzeW7FsKmY;|fB*y_009U<00Izzz#jyjRVXm$Boe5{{f~Ew{drOjgiFb3rr9Np zqmlogoBtn->setIcon(QIcon(":resources/wfview.png")); ui->logoBtn->setStyleSheet("Text-align:left"); - ui->topText->setText("wfview version 1.2a"); + ui->topText->setText("wfview version 1.2b"); QString head = QString(""); QString copyright = QString("Copyright 2017-2021 Elliott H. Liggett, W6EL. All rights reserved. wfview source code is licensed under the GNU GPLv3."); From b37713124bb67862f50340abfaf1eb5eabdffa5b Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Tue, 7 Sep 2021 08:11:51 +0200 Subject: [PATCH 19/79] WHATSNEW, CHANGELOG --- CHANGELOG | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ WHATSNEW | 4 ++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0e30950..8a54b86 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,99 @@ # CHANGELOG +- 20210831 + + added 25 kHz step for tuning + +- 20210829 + + Experimental support for split mode in rigctld + + Ignore control levels that we don't currently support + + Add better detection of ci-v transceive disable + +- 20210827 + + Add saving of meter2 state + +- 20210823 + + Set audio thread priority in the correct place! + + Now with dual meters for everyone! + +- 20210820 + + Clear Center readout as well. + + Fixed issue where the "none" selection didn't work quite right. Also + fixed the T/R meter switching to clear out invalid readings. + + + Set audio threads to be realtime priority + +- 20210817 + + dual meter support/WHATSNEW + + Current scale tic marks on both sides now! + + More meter work, fixed some scales and added labels. + + Better meter fonts + +- 20210815 + + Fix for left over CIV client on server + + Improve detection of unsupported codec. + +- 20210814 + + Fix for Opus TX audio + + txrate logging wrong + + More warning removal! + + More commenting in rigctld.h + + Is this going to fix 8 bit audio? + + Comment unused structs from rigctld + + All audio codecs now work in both directions! + + Update audiohandler.cpp + + more 8bit fixes! + + ulaw encoding test + + 8 bit encoding fix + + Another issue with 8 bit audio + + Try again to remove debugging! + + Revert "Remove extra opus debugging" This reverts commit da53f5371bbeb35b10cbb831b83b74e1bdd771f9. + + Remove extra opus debugging + + Move opus init + + Add some debugging for decoder + + Use radio samplerate for opus + + Remove big/little endian conversion + + More Opus fixes + + Update audiohandler.cpp + + Try to fix Opus 2-channel + - 20210809 Add constants to make parsing (hopefully) easier diff --git a/WHATSNEW b/WHATSNEW index 77dd589..bfc7df3 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -7,4 +7,6 @@ The following highlights are in this 1.x-release: added "do not ask again" for switching off rig and exiting wfview added opus as audio transport dual meter support - + rigctl basic split support + rigctl prevents switching off civ transceive + added 25 kHz step From f7524c7fbaed947ad0ed9eb94a85072150b08cb8 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Tue, 7 Sep 2021 09:01:55 +0200 Subject: [PATCH 20/79] fixed warning --- rigctld.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rigctld.cpp b/rigctld.cpp index 27dd6c3..fee26c3 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -465,7 +465,7 @@ void rigCtlClient::socketReadyRead() } response.append(resp); } - else if (command.length() > 1 && command[0] == "I" || command[0] == "set_split_freq") + else if (command.length() > 1 && (command[0] == "I" || command[0] == "set_split_freq")) { setCommand = true; freqt freq; @@ -1395,4 +1395,4 @@ int rigCtlClient::getCalibratedValue(unsigned char meter,cal_table_t cal) { / (cal.table[i].raw - cal.table[i - 1].raw); return cal.table[i].val - interp; -} \ No newline at end of file +} From 8b06e9d048c22f40fe0a8274875c9212a9314d0e Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 7 Sep 2021 18:04:43 +0100 Subject: [PATCH 21/79] Make rigctld state work for USB connected rigs --- rigcommander.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rigcommander.cpp b/rigcommander.cpp index 03537dc..7cc4d1c 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -76,6 +76,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities))); emit commReady(); + sendState(); // Send current rig state to rigctld } From 21bc02cc25e9a04401600ef309f935007985391c Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Tue, 7 Sep 2021 20:32:47 +0200 Subject: [PATCH 22/79] bumped to 1.2c --- CHANGELOG | 4 ++++ aboutbox.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8a54b86..971165d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # CHANGELOG +- 20210907 + + Make rigctld state work for USB connected rigs + - 20210831 added 25 kHz step for tuning diff --git a/aboutbox.cpp b/aboutbox.cpp index e4297e6..5c45f42 100644 --- a/aboutbox.cpp +++ b/aboutbox.cpp @@ -12,7 +12,7 @@ aboutbox::aboutbox(QWidget *parent) : ui->logoBtn->setIcon(QIcon(":resources/wfview.png")); ui->logoBtn->setStyleSheet("Text-align:left"); - ui->topText->setText("wfview version 1.2b"); + ui->topText->setText("wfview version 1.2c"); QString head = QString(""); QString copyright = QString("Copyright 2017-2021 Elliott H. Liggett, W6EL. All rights reserved. wfview source code is licensed under the GNU GPLv3."); From 18eb9119befce6fd593abaaffac5f267dba07c43 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 22 Sep 2021 10:39:35 +0100 Subject: [PATCH 23/79] Only send RX antenna byte to rig when it has an RX antenna option in rigCaps --- rigcommander.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 7cc4d1c..78121cb 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -3802,7 +3802,9 @@ void rigCommander::setAntenna(unsigned char ant, bool rx) { QByteArray payload("\x12"); payload.append(ant); - payload.append((unsigned char)rx); // 0x00 = use for TX and RX + if (rigCaps.hasRXAntenna) { + payload.append((unsigned char)rx); // 0x00 = use for TX and RX + } prepDataAndSend(payload); } From 2c5f37d06c1a91568756340bdbbf31a2cab05074 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 22 Sep 2021 10:50:07 +0100 Subject: [PATCH 24/79] Fix alignment of rigname in taskbar --- wfmain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index e17d344..95d8353 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -752,9 +752,10 @@ void wfmain::setupMainUI() ui->statusBar->addPermanentWidget(connectedLed); rigName = new QLabel(this); + rigName->setAlignment(Qt::AlignRight); ui->statusBar->addPermanentWidget(rigName); rigName->setText("NONE"); - rigName->setFixedWidth(50); + rigName->setFixedWidth(60); freq.MHzDouble = 0.0; freq.Hz = 0; From 4cb16b105f5dbd7c2a0cbc703aab3e64359c99c8 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 22 Sep 2021 10:59:03 +0100 Subject: [PATCH 25/79] Add keepalive for linux/mac pty --- pttyhandler.cpp | 7 +++++++ pttyhandler.h | 1 + 2 files changed, 8 insertions(+) diff --git a/pttyhandler.cpp b/pttyhandler.cpp index 6b4350d..36a5204 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -73,6 +73,9 @@ void pttyHandler::openPort() // we're good! qInfo(logSerial()) << "Opened pseudoterminal, slave name :" << ptsname(ptfd); + // Open the slave device to keep alive. + ptKeepAlive = open(ptsnamd(ptfd), O_RDONLY); + ptReader = new QSocketNotifier(ptfd, QSocketNotifier::Read, this); connect(ptReader, &QSocketNotifier::activated, this, &pttyHandler::receiveDataIn); @@ -283,6 +286,10 @@ void pttyHandler::closePort() { QFile::remove(portName); } + + if (ptKeepAlive > 0) { + close(ptKeepAlive); + } #endif isConnected = false; } diff --git a/pttyhandler.h b/pttyhandler.h index 14c9bfc..73aa80e 100644 --- a/pttyhandler.h +++ b/pttyhandler.h @@ -62,6 +62,7 @@ private: bool rolledBack; int ptfd; // pseudo-terminal file desc. + int ptKeepAlive=0; // Used to keep the pty alive after client disconects. bool havePt; QString ptDevSlave; From c712e8737353264356784c6eb27895eaeaefa244 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 22 Sep 2021 11:02:09 +0100 Subject: [PATCH 26/79] Fix typo --- pttyhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pttyhandler.cpp b/pttyhandler.cpp index 36a5204..bea880d 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -74,7 +74,7 @@ void pttyHandler::openPort() qInfo(logSerial()) << "Opened pseudoterminal, slave name :" << ptsname(ptfd); // Open the slave device to keep alive. - ptKeepAlive = open(ptsnamd(ptfd), O_RDONLY); + ptKeepAlive = open(ptsname(ptfd), O_RDONLY); ptReader = new QSocketNotifier(ptfd, QSocketNotifier::Read, this); connect(ptReader, &QSocketNotifier::activated, From 6d0ad471c7a63bc6e66b0ae745d0d6fb87d6f475 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 22 Sep 2021 11:07:07 +0100 Subject: [PATCH 27/79] Remove duplicate setPriority() --- udphandler.cpp | 2 -- udpserver.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index 59fbb66..d5368a4 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -732,7 +732,6 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio rxaudio = new audioHandler(); rxAudioThread = new QThread(this); - rxAudioThread->setPriority(QThread::TimeCriticalPriority); rxaudio->moveToThread(rxAudioThread); @@ -750,7 +749,6 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio txaudio = new audioHandler(); txAudioThread = new QThread(this); - txAudioThread->setPriority(QThread::TimeCriticalPriority); txaudio->moveToThread(txAudioThread); diff --git a/udpserver.cpp b/udpserver.cpp index 0612a02..1db161d 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -382,7 +382,7 @@ void udpServer::controlReceived() txaudio = new audioHandler(); txAudioThread = new QThread(this); - txAudioThread->setPriority(QThread::TimeCriticalPriority); + txaudio->moveToThread(txAudioThread); txAudioThread->start(QThread::TimeCriticalPriority); From 66912e13b280648ab80bf10f6dd27fc1601e04fb Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sun, 26 Sep 2021 11:48:18 +0200 Subject: [PATCH 28/79] changelog --- .swo | Bin 0 -> 12288 bytes CHANGELOG | 13 +++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 .swo diff --git a/.swo b/.swo new file mode 100644 index 0000000000000000000000000000000000000000..171d63159bf83bd4b2d8c49f10bc2611913187ce GIT binary patch literal 12288 zcmeI%Jqp4w6u|N5=A_sQM1_teZI>=RfP-UQC29wuw80j2^I{%GZ({t&DB@7;@DHSq zq~Yc9gA5^SwVW?x5-4HY=<#_qZzIIM$_rg?-PFfem(|heU{@Y=vHQOKV;+7WfIyo9 zgDj51=TVc8u9vG*Rk*s-!H2LS{S zKmY**5I_I{1Q0*~0R(;!(DuFlG8E!!`{VuJ-T!ZH?uT3~MF0T=5I_I{1Q0*~0R#|0 f0D(UVq;V({rKC!tMEXsBYJ6?XO0Vm@Y*KLtN}e1c literal 0 HcmV?d00001 diff --git a/CHANGELOG b/CHANGELOG index 971165d..01363f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,18 @@ # CHANGELOG +- 202109022 + + Remove duplicate setPriority() + + Fix typo + + Add keepalive for linux/mac pty + + Fix alignment of rigname in taskbar + + Only send RX antenna byte to rig when it has an RX antenna option in rigCaps + + - 20210907 Make rigctld state work for USB connected rigs From b7edb2cf96df76dcdfb82701c3e6f2b610f26e00 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 6 Oct 2021 23:41:11 +0100 Subject: [PATCH 29/79] Send TX/Freq changes multiple times with rigctld --- rigctld.cpp | 47 ++++++++++++++++++++++++++++++----------------- rigctld.h | 2 +- wfview.vcxproj | 8 ++++---- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/rigctld.cpp b/rigctld.cpp index fee26c3..c7a8595 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -55,10 +55,11 @@ rigCtlD::~rigCtlD() qInfo(logRigCtlD()) << "closing rigctld"; } -void rigCtlD::receiveFrequency(freqt freq) -{ - emit setFrequency(0, freq); -} +//void rigCtlD::receiveFrequency(freqt freq) +//{ +// emit setFrequency(0, freq); +// emit setFrequency(0, freq); +//} void rigCtlD::receiveStateInfo(rigStateStruct* state) { @@ -287,7 +288,7 @@ void rigCtlClient::socketReadyRead() freqt freq; bool ok=false; double newFreq=0.0f; - QString vfo = "VFOA"; + unsigned char vfo=0; if (command.length() == 2) { newFreq = command[1].toDouble(&ok); @@ -295,13 +296,20 @@ void rigCtlClient::socketReadyRead() else if (command.length() == 3) // Includes VFO { newFreq = command[2].toDouble(&ok); - vfo = command[1]; + if (command[1] == "VFOB") + { + vfo = 1; + } } if (ok) { freq.Hz = static_cast(newFreq); qDebug(logRigCtlD()) << QString("Set frequency: %1 (%2)").arg(freq.Hz).arg(command[1]); - emit parent->setFrequency(0, freq); + emit parent->setFrequency(vfo, freq); + emit parent->setFrequency(vfo, freq); + emit parent->setFrequency(vfo, freq); + emit parent->setFrequency(vfo, freq); + emit parent->setFrequency(vfo, freq); } } else if (command[0] == "1" || command[0] == "dump_caps") @@ -343,12 +351,11 @@ void rigCtlClient::socketReadyRead() { setCommand = true; if (rigCaps.hasPTTCommand) { - if (command[1] == "0") { - emit parent->setPTT(false); - } - else { - emit parent->setPTT(true); - } + emit parent->setPTT(bool(command[1].toInt())); + emit parent->setPTT(bool(command[1].toInt())); + emit parent->setPTT(bool(command[1].toInt())); + emit parent->setPTT(bool(command[1].toInt())); + emit parent->setPTT(bool(command[1].toInt())); } else { @@ -476,6 +483,10 @@ void rigCtlClient::socketReadyRead() freq.Hz = static_cast(newFreq); qDebug(logRigCtlD()) << QString("set_split_freq: %1 (%2)").arg(freq.Hz).arg(command[1]); emit parent->setFrequency(1, freq); + emit parent->setFrequency(1, freq); + emit parent->setFrequency(1, freq); + emit parent->setFrequency(1, freq); + emit parent->setFrequency(1, freq); } } else if (command.length() > 2 && (command[0] == "X" || command[0] == "set_split_mode")) @@ -531,21 +542,23 @@ void rigCtlClient::socketReadyRead() emit parent->setMode(getMode(mode), width); if (mode.mid(0, 3) == "PKT") { emit parent->setDataMode(true, width); + emit parent->setDataMode(true, width); } else { emit parent->setDataMode(false, width); + emit parent->setDataMode(false, width); } } else if (command[0] == "s" || command[0] == "get_split_vfo") { if (longReply) { - response.append(QString("Split: 0")); - response.append(QString("TX VFO: VFOA")); + response.append(QString("Split: 1")); + response.append(QString("TX VFO: VFOB")); } else { - response.append("0"); - response.append("VFOA"); + response.append("1"); + response.append("VFOb"); } } diff --git a/rigctld.h b/rigctld.h index 0b71fa9..130ae5e 100644 --- a/rigctld.h +++ b/rigctld.h @@ -369,7 +369,7 @@ public slots: virtual void incomingConnection(qintptr socketDescriptor); void receiveRigCaps(rigCapabilities caps); void receiveStateInfo(rigStateStruct* state); - void receiveFrequency(freqt freq); +// void receiveFrequency(freqt freq); private: rigStateStruct* rigState = Q_NULLPTR; diff --git a/wfview.vcxproj b/wfview.vcxproj index bf3abb6..030b9d6 100644 --- a/wfview.vcxproj +++ b/wfview.vcxproj @@ -57,7 +57,7 @@ Sync release\ MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="fc2d1e2";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="66912e1";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) false MultiThreadedDLL @@ -85,7 +85,7 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"fc2d1e2\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"66912e1\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h @@ -99,7 +99,7 @@ Sync debug\ Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="fc2d1e2";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="66912e1";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) false MultiThreadedDebugDLL true @@ -124,7 +124,7 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"fc2d1e2\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"66912e1\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h From c4a9465fb3c959535f2d7078e5871ed2314794e5 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Fri, 8 Oct 2021 10:25:32 +0200 Subject: [PATCH 30/79] pushed 1.2d; fixing some reliability issues w/ wsjtx/rigctld --- .swo | Bin 12288 -> 0 bytes CHANGELOG | 5 +++++ WHATSNEW | 5 +++++ aboutbox.cpp | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) delete mode 100644 .swo diff --git a/.swo b/.swo deleted file mode 100644 index 171d63159bf83bd4b2d8c49f10bc2611913187ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI%Jqp4w6u|N5=A_sQM1_teZI>=RfP-UQC29wuw80j2^I{%GZ({t&DB@7;@DHSq zq~Yc9gA5^SwVW?x5-4HY=<#_qZzIIM$_rg?-PFfem(|heU{@Y=vHQOKV;+7WfIyo9 zgDj51=TVc8u9vG*Rk*s-!H2LS{S zKmY**5I_I{1Q0*~0R(;!(DuFlG8E!!`{VuJ-T!ZH?uT3~MF0T=5I_I{1Q0*~0R#|0 f0D(UVq;V({rKC!tMEXsBYJ6?XO0Vm@Y*KLtN}e1c diff --git a/CHANGELOG b/CHANGELOG index 01363f3..6d2a943 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # CHANGELOG +- 20211006 + + Send TX/Freq changes multiple times with rigctld + + bumped to 1.2d hopefully last testversion before 1.20 - 202109022 Remove duplicate setPriority() diff --git a/WHATSNEW b/WHATSNEW index bfc7df3..55b37ba 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -10,3 +10,8 @@ The following highlights are in this 1.x-release: rigctl basic split support rigctl prevents switching off civ transceive added 25 kHz step + + as a temporary measure sending multiple TX/FREQ change commands to the rig + when we use rigctld. + + people should use "fake it" in wsjtx as the split code is not reliable. diff --git a/aboutbox.cpp b/aboutbox.cpp index 5c45f42..a9222b0 100644 --- a/aboutbox.cpp +++ b/aboutbox.cpp @@ -12,7 +12,7 @@ aboutbox::aboutbox(QWidget *parent) : ui->logoBtn->setIcon(QIcon(":resources/wfview.png")); ui->logoBtn->setStyleSheet("Text-align:left"); - ui->topText->setText("wfview version 1.2c"); + ui->topText->setText("wfview version 1.2d"); QString head = QString(""); QString copyright = QString("Copyright 2017-2021 Elliott H. Liggett, W6EL. All rights reserved. wfview source code is licensed under the GNU GPLv3."); From 24a88794e6647851e48e2fdb61bcc23df0512ae5 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 20 Oct 2021 12:13:18 +0100 Subject: [PATCH 31/79] Trying to find cause of lockup when client disappears --- udpserver.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/udpserver.cpp b/udpserver.cpp index 1db161d..ca4daec 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -86,8 +86,8 @@ udpServer::~udpServer() delete client->retransmitTimer; } - delete client; controlClients.removeAll(client); + delete client; } foreach(CLIENT * client, civClients) { @@ -104,8 +104,9 @@ udpServer::~udpServer() client->retransmitTimer->stop(); delete client->retransmitTimer; } - delete client; + civClients.removeAll(client); + delete client; } foreach(CLIENT * client, audioClients) { @@ -122,8 +123,8 @@ udpServer::~udpServer() client->retransmitTimer->stop(); delete client->retransmitTimer; } - delete client; audioClients.removeAll(client); + delete client; } if (rxAudioTimer != Q_NULLPTR) { @@ -1519,7 +1520,6 @@ void udpServer::sendRetransmitRequest(CLIENT* c) it.value()++; } } - c->missMutex.unlock(); if (missingSeqs.length() != 0) { @@ -1548,6 +1548,7 @@ void udpServer::sendRetransmitRequest(CLIENT* c) udpMutex.unlock(); } } + c->missMutex.unlock(); } From 620d7890cdd28b3580b60a6ae737536a2057d9bc Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 20 Oct 2021 12:47:16 +0100 Subject: [PATCH 32/79] Tidy-up server shutdown --- udpserver.cpp | 74 ++++----------------------------------------------- 1 file changed, 5 insertions(+), 69 deletions(-) diff --git a/udpserver.cpp b/udpserver.cpp index ca4daec..0c79b90 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -67,82 +67,22 @@ udpServer::~udpServer() { qInfo(logUdpServer()) << "Closing udpServer"; - connMutex.lock(); - foreach(CLIENT * client, controlClients) { - if (client->idleTimer != Q_NULLPTR) - { - client->idleTimer->stop(); - delete client->idleTimer; - } - if (client->pingTimer != Q_NULLPTR) { - client->pingTimer->stop(); - delete client->pingTimer; - } + deleteConnection(&controlClients, client); - if (client->retransmitTimer != Q_NULLPTR) { - client->retransmitTimer->stop(); - delete client->retransmitTimer; - } - - controlClients.removeAll(client); - delete client; } foreach(CLIENT * client, civClients) { - if (client->idleTimer != Q_NULLPTR) - { - client->idleTimer->stop(); - delete client->idleTimer; - } - if (client->pingTimer != Q_NULLPTR) { - client->pingTimer->stop(); - delete client->pingTimer; - } - if (client->retransmitTimer != Q_NULLPTR) { - client->retransmitTimer->stop(); - delete client->retransmitTimer; - } - - civClients.removeAll(client); - delete client; + deleteConnection(&civClients, client); } + foreach(CLIENT * client, audioClients) { - if (client->idleTimer != Q_NULLPTR) - { - client->idleTimer->stop(); - delete client->idleTimer; - } - if (client->pingTimer != Q_NULLPTR) { - client->pingTimer->stop(); - delete client->pingTimer; - } - if (client->retransmitTimer != Q_NULLPTR) { - client->retransmitTimer->stop(); - delete client->retransmitTimer; - } - audioClients.removeAll(client); - delete client; - } - - if (rxAudioTimer != Q_NULLPTR) { - rxAudioTimer->stop(); - delete rxAudioTimer; - rxAudioTimer = Q_NULLPTR; - } - - if (rxAudioThread != Q_NULLPTR) { - rxAudioThread->quit(); - rxAudioThread->wait(); - } - - if (txAudioThread != Q_NULLPTR) { - txAudioThread->quit(); - txAudioThread->wait(); + deleteConnection(&audioClients, client); } + // Now all connections are deleted, close and delete the sockets. if (udpControl != Q_NULLPTR) { udpControl->close(); delete udpControl; @@ -155,10 +95,6 @@ udpServer::~udpServer() udpAudio->close(); delete udpAudio; } - - connMutex.unlock(); - - } From 511f2b5e98233acd8e56bb52cfaf7b25bd3e28ae Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Wed, 20 Oct 2021 14:54:44 +0200 Subject: [PATCH 33/79] changes in udp crashes in server side code --- CHANGELOG | 7 +++++++ WHATSNEW | 2 ++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6d2a943..a6086c2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ # CHANGELOG + +- 20211020 + + Tidy-up server shutdown + + Trying to find cause of lockup when client disappears + - 20211006 Send TX/Freq changes multiple times with rigctld diff --git a/WHATSNEW b/WHATSNEW index 55b37ba..33042e3 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -15,3 +15,5 @@ The following highlights are in this 1.x-release: when we use rigctld. people should use "fake it" in wsjtx as the split code is not reliable. + + tidied up udp server function for better reliability From 2c1272de66d4d1a3d566355b6bf7d1b33bab71fc Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Fri, 22 Oct 2021 00:24:15 +0100 Subject: [PATCH 34/79] Bit of tidying --- udpserver.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/udpserver.cpp b/udpserver.cpp index 0c79b90..c16ebbc 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -272,13 +272,11 @@ void udpServer::controlReceived() if (current->isAuthenticated) { qInfo(logUdpServer()) << current->ipAddress.toString() << ": User " << current->user.username << " login OK"; - sendLoginResponse(current, true); } else { qInfo(logUdpServer()) << current->ipAddress.toString() << ": Incorrect username/password"; - - sendLoginResponse(current, false); } + sendLoginResponse(current, current->isAuthenticated); break; } case (CONNINFO_SIZE): From bab77ebaba0e2fdb6cc7db64a2495e3dcb629855 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Fri, 22 Oct 2021 00:24:30 +0100 Subject: [PATCH 35/79] Don't block until audio buffer has space --- audiohandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 01c4f8b..d8227e4 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -451,13 +451,13 @@ qint64 audioHandler::writeData(const char* data, qint64 nBytes) tempBuf.sent = tempBuf.sent + send; } else { - ringBuf->write(tempBuf); - /* + //ringBuf->write(tempBuf); + if (!ringBuf->try_write(tempBuf)) { qDebug(logAudio()) << "outgoing audio buffer full!"; break; - } */ + } tempBuf.data.clear(); tempBuf.sent = 0; } From 37205a11da2feacd80fc0ecd9bf40d1a6697b561 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sun, 24 Oct 2021 18:09:11 +0200 Subject: [PATCH 36/79] changelog --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a6086c2..dea2e59 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # CHANGELOG +- 20211022 + + Don't block until audio buffer has space + + Bit of tidying - 20211020 From 4e5f315f08acb821c9b164e46e7dff555f8ce7ec Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 31 Oct 2021 23:53:20 +0000 Subject: [PATCH 37/79] Stuff audio buffer directly rather than signal/slot --- audiohandler.cpp | 2 +- udphandler.cpp | 4 ++-- udpserver.cpp | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index d8227e4..1a4fd17 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -81,7 +81,7 @@ bool audioHandler::init(audioSetup setupIn) setup.bits = 16; } - ringBuf = new wilt::Ring(100); // Should be customizable. + ringBuf = new wilt::Ring(8); // Should be customizable. tempBuf.sent = 0; diff --git a/udphandler.cpp b/udphandler.cpp index d5368a4..15605e7 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -945,8 +945,8 @@ void udpAudio::dataReceived() tempAudio.data = r.mid(0x18); // Prefer signal/slot to forward audio as it is thread/safe // Need to do more testing but latency appears fine. - //audioLatency = rxaudio->incomingAudio(tempAudio); - emit haveAudioData(tempAudio); + rxaudio->incomingAudio(tempAudio); + //emit haveAudioData(tempAudio); audioLatency = rxaudio->getLatency(); } break; diff --git a/udpserver.cpp b/udpserver.cpp index c16ebbc..3219815 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -653,7 +653,9 @@ void udpServer::audioReceived() tempAudio.sent = 0; tempAudio.data = r.mid(0x18); //qInfo(logUdpServer()) << "sending tx audio " << in->seq; - emit haveAudioData(tempAudio); + //emit haveAudioData(tempAudio); + txaudio->incomingAudio(tempAudio); + } } break; From ffdcada18c83ae0ddc76f6965cf755659c08f2a6 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 1 Nov 2021 09:18:01 +0000 Subject: [PATCH 38/79] Adjust buffer size depending on latency setting --- audiohandler.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 1a4fd17..72e0d2d 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -81,7 +81,7 @@ bool audioHandler::init(audioSetup setupIn) setup.bits = 16; } - ringBuf = new wilt::Ring(8); // Should be customizable. + ringBuf = new wilt::Ring(setupIn.latency / 8 + 1); // Should be customizable. tempBuf.sent = 0; @@ -600,6 +600,8 @@ void audioHandler::changeLatency(const quint16 newSize) { qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Changing latency to: " << newSize << " from " << setup.latency; setup.latency = newSize; + delete ringBuf; + ringBuf = new wilt::Ring(setup.latency / 8 + 1); // Should be customizable. } int audioHandler::getLatency() @@ -618,13 +620,13 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) { currentLatency = packet.time.msecsTo(QTime::currentTime()); - while (currentLatency > setup.latency) { + if (currentLatency > setup.latency) { qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Packet " << hex << packet.seq << " arrived too late (increase output latency!) " << dec << packet.time.msecsTo(QTime::currentTime()) << "ms"; - if (!ringBuf->try_read(packet)) - break; - currentLatency = packet.time.msecsTo(QTime::currentTime()); + // if (!ringBuf->try_read(packet)) + // break; + // currentLatency = packet.time.msecsTo(QTime::currentTime()); } //qDebug(logAudio) << "Chunksize" << this->chunkSize << "Packet size" << packet.data.length(); From 5b0a3620bd8c077ec3c6e90ce0bc13f4ee05442b Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 1 Nov 2021 11:17:25 +0000 Subject: [PATCH 39/79] Use buffered audio for Linux (was just Mac only) --- audiohandler.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 72e0d2d..d045a6e 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -124,14 +124,9 @@ bool audioHandler::init(audioSetup setupIn) if (info.probed) { - // if "preferred" sample rate is 44100, try 48K instead - if (info.preferredSampleRate == (unsigned int)44100) { - qDebug(logAudio()) << "Preferred sample rate 44100, trying 48000"; - this->nativeSampleRate = 48000; - } - else { - this->nativeSampleRate = info.preferredSampleRate; - } + // Always use the "preferred" sample rate + // We can always resample if needed + this->nativeSampleRate = info.preferredSampleRate; // Per channel chunk size. this->chunkSize = (this->nativeSampleRate / 50); @@ -293,7 +288,7 @@ void audioHandler::start() } if (setup.isinput) { -#ifdef Q_OS_MACX +#ifndef Q_OS_WIN this->open(QIODevice::WriteOnly); #else this->open(QIODevice::WriteOnly | QIODevice::Unbuffered); @@ -301,7 +296,7 @@ void audioHandler::start() audioInput->start(this); } else { -#ifdef Q_OS_MACX +#ifndef Q_OS_WIN this->open(QIODevice::ReadOnly); #else this->open(QIODevice::ReadOnly | QIODevice::Unbuffered); From 43efadbeaa2eeebc1b34155745ab83d2aff7227d Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 1 Nov 2021 12:44:23 +0000 Subject: [PATCH 40/79] Make switching between audio apis easier (and tidy .pro file) --- wfview.pro | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/wfview.pro b/wfview.pro index 3a197c5..c05ba29 100644 --- a/wfview.pro +++ b/wfview.pro @@ -48,13 +48,29 @@ DEFINES += PREFIX=\\\"$$PREFIX\\\" # DEFINES += RTAUDIO # DEFINES += PORTAUDIO -# RTAudio defines -win32:DEFINES += __WINDOWS_WASAPI__ -#win32:DEFINES += __WINDOWS_DS__ # Requires DirectSound libraries -linux:DEFINES += __LINUX_ALSA__ -#linux:DEFINES += __LINUX_OSS__ -#linux:DEFINES += __LINUX_PULSE__ -macx:DEFINES += __MACOSX_CORE__ +contains(DEFINES, RTAUDIO) { + # RTAudio defines + win32:DEFINES += __WINDOWS_WASAPI__ + #win32:DEFINES += __WINDOWS_DS__ # Requires DirectSound libraries + linux:DEFINES += __LINUX_ALSA__ + #linux:DEFINES += __LINUX_OSS__ + #linux:DEFINES += __LINUX_PULSE__ + macx:DEFINES += __MACOSX_CORE__ + win32:SOURCES += ../rtaudio/RTAudio.cpp + win32:HEADERS += ../rtaudio/RTAUdio.h + !linux:INCLUDEPATH += ../rtaudio + linux:LIBS += -lpulse -lpulse-simple -lpthread +} + +contains(DEFINES, PORTAUDIO) { + CONFIG(debug, release|debug) { + win32:LIBS += -L../portaudio/msvc/Win32/Debug/ -lportaudio_x86 + } else { + win32:LIBS += -L../portaudio/msvc/Win32/Release/ -lportaudio_x86 + } + win32:INCLUDEPATH += ../portaudio/include + !win32:LIBS += -lportaudio +} macx:INCLUDEPATH += /usr/local/include /opt/local/include macx:LIBS += -L/usr/local/lib -L/opt/local/lib @@ -111,12 +127,9 @@ CONFIG(debug, release|debug) { win32:LIBS += -L../opus/win32/VS2015/Win32/Release/ -lopus } -#linux:LIBS += -L./ -l$$QCPLIB -lpulse -lpulse-simple -lpthread linux:LIBS += -L./ -l$$QCPLIB -lopus -macx:LIBS += -framework CoreAudio -framework CoreFoundation -lpthread -lopus +macx:LIBS += -framework CoreAudio -framework CoreFoundation -lpthread -lopus -#win32:SOURCES += rtaudio/RTAudio.cpp -#win32:HEADERS += rtaudio/RTAUdio.h !linux:SOURCES += ../qcustomplot/qcustomplot.cpp !linux:HEADERS += ../qcustomplot/qcustomplot.h !linux:INCLUDEPATH += ../qcustomplot @@ -124,7 +137,6 @@ macx:LIBS += -framework CoreAudio -framework CoreFoundation -lpthread -lopus !linux:INCLUDEPATH += ../opus/include INCLUDEPATH += resampler -!linux:INCLUDEPATH += rtaudio SOURCES += main.cpp\ wfmain.cpp \ From 0c7bc1738268498d01453bff961f3f3e12fe3c8c Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 1 Nov 2021 20:27:33 +0000 Subject: [PATCH 41/79] Add portaudio support --- audiohandler.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++-- audiohandler.h | 27 ++++++++++-- wfmain.cpp | 38 +++++++++++++++++ wfview.pro | 2 +- 4 files changed, 166 insertions(+), 7 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index d045a6e..c17a6f4 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -8,6 +8,10 @@ #include "logcategories.h" #include "ulaw.h" +#if defined(Q_OS_WIN) && defined(PORTAUDIO) +#include +#endif + audioHandler::audioHandler(QObject* parent) { @@ -29,6 +33,7 @@ audioHandler::~audioHandler() } delete audio; #elif defined(PORTAUDIO) + Pa_StopStream(audio); #else stop(); #endif @@ -184,6 +189,79 @@ bool audioHandler::init(audioSetup setupIn) #elif defined(PORTAUDIO) + + PaError err; + +#ifdef Q_OS_WIN + CoInitialize(0); +#endif + + memset(&aParams, 0,sizeof(PaStreamParameters)); + + if (setup.port > 0) { + aParams.device = setup.port; + } + else if (setup.isinput) { + aParams.device = Pa_GetDefaultInputDevice(); + } + else { + aParams.device = Pa_GetDefaultOutputDevice(); + } + + info = Pa_GetDeviceInfo(aParams.device); + + aParams.channelCount = 2; + aParams.hostApiSpecificStreamInfo = NULL; + aParams.sampleFormat = paInt16; + aParams.suggestedLatency = info->defaultLowInputLatency; + aParams.hostApiSpecificStreamInfo = NULL; + + // Always use the "preferred" sample rate + // We can always resample if needed + this->nativeSampleRate = info->defaultSampleRate; + + // Per channel chunk size. + this->chunkSize = (this->nativeSampleRate / 50); + + qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << info->name << "(" << aParams.device << ") successfully probed"; + if (setup.isinput) { + devChannels = info->maxInputChannels; + } + else { + devChannels = info->maxOutputChannels; + } + qInfo(logAudio()) << " Channels:" << devChannels; + if (devChannels > 2) { + devChannels = 2; + } + aParams.channelCount = devChannels; + + qInfo(logAudio()) << " chunkSize: " << chunkSize; + + if (setup.isinput) { + err=Pa_OpenStream(&audio, &aParams, 0, this->nativeSampleRate, this->chunkSize, paNoFlag, &audioHandler::staticWrite, (void*)this); + //err = Pa_OpenDefaultStream(&audio, 2, 0, paFloat32, this->nativeSampleRate, this->chunkSize, &audioHandler::staticWrite, (void*)this); + } + else { + err=Pa_OpenStream(&audio, 0, &aParams, this->nativeSampleRate, this->chunkSize, paNoFlag, &audioHandler::staticRead, (void*)this); + //err = Pa_OpenDefaultStream(&audio, 0, 2, paFloat32, this->nativeSampleRate, this->chunkSize, &audioHandler::staticRead, (void*)this); + } + + if (err == paNoError) { + err = Pa_StartStream(audio); + } + if (err == paNoError) { + isInitialized = true; + qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "device successfully opened"; + } + else { + qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "failed to open device" << Pa_GetErrorText(err); + } + //qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "detected latency:" << audio->getStreamLatency(); + + + + #else format.setSampleSize(16); @@ -323,7 +401,8 @@ void audioHandler::setVolume(unsigned char volume) /// /// #if defined(RTAUDIO) -int audioHandler::readData(void* outputBuffer, void* inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status) +int audioHandler::readData(void* outputBuffer, void* inputBuffer, + unsigned int nFrames, double streamTime, RtAudioStreamStatus status) { Q_UNUSED(inputBuffer); Q_UNUSED(streamTime); @@ -332,6 +411,15 @@ int audioHandler::readData(void* outputBuffer, void* inputBuffer, unsigned int n int nBytes = nFrames * devChannels * 2; // This is ALWAYS 2 bytes per sample and 2 channels quint8* buffer = (quint8*)outputBuffer; #elif defined(PORTAUDIO) + +int audioHandler::readData(const void* inputBuffer, void* outputBuffer, + unsigned long nFrames, const PaStreamCallbackTimeInfo * streamTime, PaStreamCallbackFlags status) +{ + Q_UNUSED(inputBuffer); + Q_UNUSED(streamTime); + Q_UNUSED(status); + int nBytes = nFrames * devChannels * 2; // This is ALWAYS 2 bytes per sample and 2 channels + quint8* buffer = (quint8*)outputBuffer; #else qint64 audioHandler::readData(char* buffer, qint64 nBytes) { @@ -411,13 +499,15 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes) #if defined(RTAUDIO) return 0; #elif defined(PORTAUDIO) + return 0; #else return nBytes; #endif } #if defined(RTAUDIO) -int audioHandler::writeData(void* outputBuffer, void* inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status) +int audioHandler::writeData(void* outputBuffer, void* inputBuffer, + unsigned int nFrames, double streamTime, RtAudioStreamStatus status) { Q_UNUSED(outputBuffer); Q_UNUSED(streamTime); @@ -425,6 +515,15 @@ int audioHandler::writeData(void* outputBuffer, void* inputBuffer, unsigned int int nBytes = nFrames * devChannels * 2; // This is ALWAYS 2 bytes per sample and 2 channels const char* data = (const char*)inputBuffer; #elif defined(PORTAUDIO) +int audioHandler::writeData(const void* inputBuffer, void* outputBuffer, + unsigned long nFrames, const PaStreamCallbackTimeInfo * streamTime, + PaStreamCallbackFlags status) +{ + Q_UNUSED(outputBuffer); + Q_UNUSED(streamTime); + Q_UNUSED(status); + int nBytes = nFrames * devChannels * 2; // This is ALWAYS 2 bytes per sample and 2 channels + const char* data = (const char*)inputBuffer; #else qint64 audioHandler::writeData(const char* data, qint64 nBytes) { @@ -462,6 +561,7 @@ qint64 audioHandler::writeData(const char* data, qint64 nBytes) #if defined(RTAUDIO) return 0; #elif defined(PORTAUDIO) + return 0; #else return nBytes; #endif @@ -586,7 +686,7 @@ void audioHandler::incomingAudio(audioPacket inPacket) if (!ringBuf->try_write(inPacket)) { - qDebug(logAudio()) << "Buffer full! capacity:" << ringBuf->capacity() << "length" << ringBuf->size(); + qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Buffer full! capacity:" << ringBuf->capacity() << "length" << ringBuf->size(); } return; } diff --git a/audiohandler.h b/audiohandler.h index d2902d2..875d261 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -9,10 +9,14 @@ #include #if defined(RTAUDIO) +#ifdef Q_OS_WIN +#include "RtAudio.h" +#else #include "rtaudio/RtAudio.h" +#endif #elif defined (PORTAUDIO) #include "portaudio.h" -#error "PORTAUDIO is not currently supported" +//#error "PORTAUDIO is not currently supported" #else #include #include @@ -67,9 +71,8 @@ struct audioSetup { quint8 codec; bool ulaw; bool isinput; -#if defined(RTAUDIO) +#if defined(RTAUDIO) || defined(PORTAUDIO) int port; -#elif defined(PORTAUDIO) #else QAudioDeviceInfo port; #endif @@ -137,6 +140,21 @@ private: return static_cast(userData)->writeData(outputBuffer, inputBuffer, nFrames, streamTime, status); } #elif defined(PORTAUDIO) + int readData(const void* inputBuffer, void* outputBuffer, + unsigned long nFrames, + const PaStreamCallbackTimeInfo* streamTime, + PaStreamCallbackFlags status); + static int staticRead(const void* inputBuffer, void* outputBuffer, unsigned long nFrames, const PaStreamCallbackTimeInfo* streamTime, PaStreamCallbackFlags status, void* userData) { + return ((audioHandler*)userData)->readData(inputBuffer, outputBuffer, nFrames, streamTime, status); + } + + int writeData(const void* inputBuffer, void* outputBuffer, + unsigned long nFrames, + const PaStreamCallbackTimeInfo* streamTime, + PaStreamCallbackFlags status); + static int staticWrite(const void* inputBuffer, void* outputBuffer, unsigned long nFrames, const PaStreamCallbackTimeInfo* streamTime, PaStreamCallbackFlags status, void* userData) { + return ((audioHandler*)userData)->writeData(inputBuffer, outputBuffer, nFrames, streamTime, status); + } #else qint64 readData(char* data, qint64 nBytes); @@ -154,6 +172,9 @@ private: RtAudio::StreamOptions options; RtAudio::DeviceInfo info; #elif defined(PORTAUDIO) + PaStream* audio = Q_NULLPTR; + PaStreamParameters aParams; + const PaDeviceInfo *info; #else QAudioOutput* audioOutput=Q_NULLPTR; QAudioInput* audioInput=Q_NULLPTR; diff --git a/wfmain.cpp b/wfmain.cpp index 95d8353..e1d5ebb 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -106,6 +106,11 @@ wfmain::~wfmain() delete rpt; delete ui; delete settings; + +#if defined(PORTAUDIO) + Pa_Terminate(); +#endif + } void wfmain::closeEvent(QCloseEvent *event) @@ -1023,6 +1028,35 @@ void wfmain::setAudioDevicesUI() #elif defined(PORTAUDIO) // Use PortAudio device enumeration + + PaError err; + + err = Pa_Initialize(); + + if (err != paNoError) + { + qInfo(logAudio()) << "ERROR: Cannot initialize Portaudio"; + } + + qInfo(logAudio()) << "PortAudio version: " << Pa_GetVersionInfo()->versionText; + + int numDevices; + numDevices = Pa_GetDeviceCount(); + qInfo(logAudio()) << "Pa_CountDevices returned" << numDevices; + + const PaDeviceInfo* info; + for (int i = 0; i < numDevices; i++) + { + info = Pa_GetDeviceInfo(i); + if (info->maxInputChannels > 0) { + qInfo(logAudio()) << (i == Pa_GetDefaultInputDevice() ? "*" : " ") << "(" << i << ") Output Device : " << info->name; + ui->audioInputCombo->addItem(info->name, i); + } + if (info->maxOutputChannels > 0) { + qInfo(logAudio()) << (i == Pa_GetDefaultOutputDevice() ? "*" : " ") << "(" << i << ") Input Device : " << info->name; + ui->audioOutputCombo->addItem(info->name, i); + } + } #else // If no external library is configured, use QTMultimedia @@ -1466,6 +1500,7 @@ void wfmain::loadSettings() #if defined(RTAUDIO) rxSetup.port = ui->audioOutputCombo->itemData(audioOutputIndex).toInt(); #elif defined(PORTAUDIO) + rxSetup.port = ui->audioOutputCombo->itemData(audioOutputIndex).toInt(); #else QVariant v = ui->audioOutputCombo->currentData(); rxSetup.port = v.value(); @@ -1482,6 +1517,7 @@ void wfmain::loadSettings() #if defined(RTAUDIO) txSetup.port = ui->audioInputCombo->itemData(audioInputIndex).toInt(); #elif defined(PORTAUDIO) + txSetup.port = ui->audioInputCombo->itemData(audioInputIndex).toInt(); #else QVariant v = ui->audioInputCombo->currentData(); txSetup.port = v.value(); @@ -4223,6 +4259,7 @@ void wfmain::on_audioOutputCombo_currentIndexChanged(int value) #if defined(RTAUDIO) rxSetup.port = ui->audioOutputCombo->itemData(value).toInt(); #elif defined(PORTAUDIO) + rxSetup.port = ui->audioOutputCombo->itemData(value).toInt(); #else QVariant v = ui->audioOutputCombo->itemData(value); rxSetup.port = v.value(); @@ -4236,6 +4273,7 @@ void wfmain::on_audioInputCombo_currentIndexChanged(int value) #if defined(RTAUDIO) txSetup.port = ui->audioInputCombo->itemData(value).toInt(); #elif defined(PORTAUDIO) + txSetup.port = ui->audioInputCombo->itemData(value).toInt(); #else QVariant v = ui->audioInputCombo->itemData(value); txSetup.port = v.value(); diff --git a/wfview.pro b/wfview.pro index c05ba29..bdcd937 100644 --- a/wfview.pro +++ b/wfview.pro @@ -46,7 +46,7 @@ DEFINES += PREFIX=\\\"$$PREFIX\\\" # Choose audio system, uses QTMultimedia if both are commented out. # DEFINES += RTAUDIO -# DEFINES += PORTAUDIO +DEFINES += PORTAUDIO contains(DEFINES, RTAUDIO) { # RTAudio defines From 6f4cf6bbbea98af0ea7d2d8393bf4f2aacbb049e Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 1 Nov 2021 20:28:04 +0000 Subject: [PATCH 42/79] remove unneeded audio signal handler --- udphandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index 15605e7..161ce92 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -346,7 +346,7 @@ void udpHandler::dataReceived() audio = new udpAudio(localIP, radioIP, audioPort, rxSetup, txSetup); QObject::connect(civ, SIGNAL(receive(QByteArray)), this, SLOT(receiveFromCivStream(QByteArray))); - QObject::connect(audio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket))); + //QObject::connect(audio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket))); QObject::connect(this, SIGNAL(haveChangeLatency(quint16)), audio, SLOT(changeLatency(quint16))); QObject::connect(this, SIGNAL(haveSetVolume(unsigned char)), audio, SLOT(setVolume(unsigned char))); @@ -740,7 +740,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup))); // signal/slot not currently used. - connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket))); + //connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket))); connect(this, SIGNAL(haveChangeLatency(quint16)), rxaudio, SLOT(changeLatency(quint16))); connect(this, SIGNAL(haveSetVolume(unsigned char)), rxaudio, SLOT(setVolume(unsigned char))); connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater())); From 2f480e4b822e63d96cf1d163a93981e7b22b7c0e Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 1 Nov 2021 20:39:12 +0000 Subject: [PATCH 43/79] Use QT Audio by default --- wfview.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfview.pro b/wfview.pro index bdcd937..c05ba29 100644 --- a/wfview.pro +++ b/wfview.pro @@ -46,7 +46,7 @@ DEFINES += PREFIX=\\\"$$PREFIX\\\" # Choose audio system, uses QTMultimedia if both are commented out. # DEFINES += RTAUDIO -DEFINES += PORTAUDIO +# DEFINES += PORTAUDIO contains(DEFINES, RTAUDIO) { # RTAudio defines From 12d202cbcd65497b1213b4604142d9c07f9eb846 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 4 Nov 2021 20:17:50 -0700 Subject: [PATCH 44/79] Added code to force IC-736 to rigID --- rigcommander.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rigcommander.cpp b/rigcommander.cpp index fad3854..dba30f1 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -231,6 +231,9 @@ void rigCommander::findRigs() data.append(payloadSuffix); emit dataForComm(data); + // HACK for testing radios that do not respond to rig ID queries: + //this->model = model736; + //this->determineRigCaps(); return; } From 522557c6e8b7ac98524b0e18f0fe47f476ac33d2 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 4 Nov 2021 20:45:02 -0700 Subject: [PATCH 45/79] Added IC-736 FM mode --- rigcommander.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 3788012..193407f 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -3305,7 +3305,7 @@ void rigCommander::determineRigCaps() rigCaps.preamps.push_back('\x01'); rigCaps.bands = standardHF; rigCaps.modes = { createMode(modeLSB, 0x00, "LSB"), createMode(modeUSB, 0x01, "USB"), - createMode(modeAM, 0x02, "AM"), + createMode(modeAM, 0x02, "AM"), createMode(modeFM, 0x05, "FM"), createMode(modeCW, 0x03, "CW"), createMode(modeCW_R, 0x07, "CW-R"), }; break; From cecaee397deead4942cf79f9e82dd561106b3e99 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 5 Nov 2021 10:09:31 -0700 Subject: [PATCH 46/79] Added support for IF Shift and Twin Pass-Band Filters. Currently accessable only via the debug button. --- rigcommander.cpp | 71 ++++++++++++++++++++++++++++++ rigcommander.h | 9 ++++ rigidentities.h | 2 + transceiveradjustments.cpp | 57 ++++++++++++++++++++++++ transceiveradjustments.h | 23 ++++++++++ transceiveradjustments.ui | 76 +++++++++++++++++++++++++++++--- wfmain.cpp | 90 +++++++++++++++++++++++++++++++++++++- wfmain.h | 32 +++++++++++--- wfmain.ui | 8 ++-- 9 files changed, 353 insertions(+), 15 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 193407f..c6e72e0 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -1362,6 +1362,17 @@ void rigCommander::parseLevels() emit haveSql(level); rigState.squelch = level; break; + case '\x07': + // Twin BPF Inner, or, IF-Shift level + if(rigCaps.hasTBPF) + emit haveTPBFInner(level); + else + emit haveIFShift(level); + break; + case '\x08': + // Twin BPF Outer + emit haveTPBFOuter(level); + break; case '\x09': // CW Pitch - ignore for now break; @@ -1469,6 +1480,27 @@ void rigCommander::parseLevels() } +void rigCommander::setIFShift(unsigned char level) +{ + QByteArray payload("\x14\x07"); + payload.append(bcdEncodeInt(level)); + prepDataAndSend(payload); +} + +void rigCommander::setTPBFInner(unsigned char level) +{ + QByteArray payload("\x14\x07"); + payload.append(bcdEncodeInt(level)); + prepDataAndSend(payload); +} + +void rigCommander::setTPBFOuter(unsigned char level) +{ + QByteArray payload("\x14\x08"); + payload.append(bcdEncodeInt(level)); + prepDataAndSend(payload); +} + void rigCommander::setTxPower(unsigned char power) { QByteArray payload("\x14\x0A"); @@ -1892,6 +1924,24 @@ void rigCommander::getAfGain() prepDataAndSend(payload); } +void rigCommander::getIFShift() +{ + QByteArray payload("\x14\x07"); + prepDataAndSend(payload); +} + +void rigCommander::getTPBFInner() +{ + QByteArray payload("\x14\x07"); + prepDataAndSend(payload); +} + +void rigCommander::getTPBFOuter() +{ + QByteArray payload("\x14\x08"); + prepDataAndSend(payload); +} + void rigCommander::getSql() { QByteArray payload("\x14\x03"); @@ -2827,6 +2877,9 @@ void rigCommander::determineRigCaps() rigCaps.hasCTCSS = false; rigCaps.hasDTCS = false; + rigCaps.hasTBPF = false; + rigCaps.hasIFShift = false; + rigCaps.spectSeqMax = 0; rigCaps.spectAmpMax = 0; rigCaps.spectLenMax = 0; @@ -2897,6 +2950,7 @@ void rigCommander::determineRigCaps() rigCaps.hasWiFi = false; rigCaps.hasATU = true; rigCaps.hasCTCSS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x20'); rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); @@ -2925,6 +2979,7 @@ void rigCommander::determineRigCaps() rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; rigCaps.hasDV = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x10'); rigCaps.attenuators.push_back('\x20'); rigCaps.attenuators.push_back('\x30'); @@ -2962,6 +3017,7 @@ void rigCommander::determineRigCaps() rigCaps.hasDV = true; rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x10'); rigCaps.preamps.push_back('\x01'); rigCaps.bands = standardVU; @@ -3010,6 +3066,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = true; rigCaps.hasCTCSS = false; rigCaps.hasDTCS = false; + rigCaps.hasTBPF = true; rigCaps.attenuators.insert(rigCaps.attenuators.end(), {0x00, 0x06, 0x12, 0x18}); rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); @@ -3036,6 +3093,7 @@ void rigCommander::determineRigCaps() rigCaps.hasEthernet = true; rigCaps.hasWiFi = false; rigCaps.hasCTCSS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.insert(rigCaps.attenuators.end(), {'\x03', '\x06', '\x09', '\x12',\ '\x15', '\x18', '\x21', '\x24',\ @@ -3070,6 +3128,7 @@ void rigCommander::determineRigCaps() rigCaps.hasWiFi = false; rigCaps.hasATU = true; rigCaps.hasCTCSS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.insert(rigCaps.attenuators.end(), {'\x03', '\x06', '\x09', '\x12', '\x15', '\x18', '\x21'}); @@ -3104,6 +3163,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = true; rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.insert(rigCaps.attenuators.end(),{ '\x10' , '\x20'}); rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); @@ -3136,6 +3196,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = true; rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x12'); rigCaps.preamps.push_back('\x01'); rigCaps.bands = standardHF; @@ -3159,6 +3220,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = true; rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x20'); rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); @@ -3182,6 +3244,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = true; rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x12'); rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); @@ -3210,6 +3273,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = true; rigCaps.hasCTCSS = true; rigCaps.hasDTCS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.push_back('\x20'); rigCaps.preamps.push_back('\x01'); rigCaps.bands = standardHF; @@ -3229,6 +3293,7 @@ void rigCommander::determineRigCaps() rigCaps.hasEthernet = true; rigCaps.hasWiFi = false; rigCaps.hasCTCSS = true; + rigCaps.hasTBPF = true; rigCaps.attenuators.insert(rigCaps.attenuators.end(), {'\x06', '\x12', '\x18'}); rigCaps.preamps.push_back('\x01'); @@ -3276,6 +3341,7 @@ void rigCommander::determineRigCaps() rigCaps.hasFDcomms = false; rigCaps.hasATU = false; rigCaps.hasPTTCommand = false; + rigCaps.hasIFShift = true; rigCaps.hasDataModes = false; rigCaps.attenuators.push_back('\x20'); rigCaps.preamps.push_back('\x01'); @@ -3301,6 +3367,7 @@ void rigCommander::determineRigCaps() rigCaps.hasATU = false; rigCaps.hasPTTCommand = false; rigCaps.hasDataModes = false; + rigCaps.hasIFShift = true; // untested rigCaps.attenuators.push_back('\x20'); rigCaps.preamps.push_back('\x01'); rigCaps.bands = standardHF; @@ -3319,6 +3386,7 @@ void rigCommander::determineRigCaps() rigCaps.hasWiFi = false; rigCaps.hasFDcomms = false; rigCaps.hasATU = true; + rigCaps.hasTBPF = true; rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); rigCaps.attenuators.insert(rigCaps.attenuators.end(),{ '\x06' , '\x12', '\x18'}); @@ -3339,6 +3407,7 @@ void rigCommander::determineRigCaps() rigCaps.hasWiFi = false; rigCaps.hasFDcomms = false; rigCaps.hasATU = true; + rigCaps.hasTBPF = true; rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); rigCaps.attenuators.insert(rigCaps.attenuators.end(),{ '\x06' , '\x12', '\x18'}); @@ -3359,6 +3428,7 @@ void rigCommander::determineRigCaps() rigCaps.hasWiFi = false; rigCaps.hasFDcomms = false; rigCaps.hasATU = true; + rigCaps.hasTBPF = true; rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); rigCaps.attenuators.insert(rigCaps.attenuators.end(),{ '\x06' , '\x12', '\x18'}); @@ -3381,6 +3451,7 @@ void rigCommander::determineRigCaps() rigCaps.hasFDcomms = false; rigCaps.hasATU = true; rigCaps.hasDV = true; + rigCaps.hasTBPF = true; rigCaps.preamps.push_back('\x01'); rigCaps.preamps.push_back('\x02'); rigCaps.attenuators.insert(rigCaps.attenuators.end(),{ '\x20' }); diff --git a/rigcommander.h b/rigcommander.h index 1486028..1abc38f 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -215,6 +215,9 @@ public slots: void getRfGain(); void getAfGain(); void getSql(); + void getIFShift(); + void getTPBFInner(); + void getTPBFOuter(); void getTxLevel(); void getMicGain(); void getCompLevel(); @@ -232,6 +235,9 @@ public slots: void setSquelch(unsigned char level); void setRfGain(unsigned char level); void setAfGain(unsigned char level); + void setIFShift(unsigned char level); + void setTPBFInner(unsigned char level); + void setTPBFOuter(unsigned char level); void setTxPower(unsigned char power); void setMicGain(unsigned char gain); void setUSBGain(unsigned char gain); @@ -356,6 +362,9 @@ signals: void haveRfGain(unsigned char level); void haveAfGain(unsigned char level); void haveSql(unsigned char level); + void haveTPBFInner(unsigned char level); + void haveTPBFOuter(unsigned char level); + void haveIFShift(unsigned char level); void haveTxPower(unsigned char level); void haveMicGain(unsigned char level); void haveCompLevel(unsigned char level); diff --git a/rigidentities.h b/rigidentities.h index fd155e8..a87d9ec 100644 --- a/rigidentities.h +++ b/rigidentities.h @@ -122,6 +122,8 @@ struct rigCapabilities { bool hasPreamp; bool hasAntennaSel; bool hasDataModes; + bool hasIFShift; + bool hasTBPF; bool hasRXAntenna; diff --git a/transceiveradjustments.cpp b/transceiveradjustments.cpp index 5779f5f..319b305 100644 --- a/transceiveradjustments.cpp +++ b/transceiveradjustments.cpp @@ -12,5 +12,62 @@ transceiverAdjustments::transceiverAdjustments(QWidget *parent) : transceiverAdjustments::~transceiverAdjustments() { + rigCaps.inputs.clear(); + rigCaps.preamps.clear(); + rigCaps.attenuators.clear(); + rigCaps.antennas.clear(); + delete ui; } + +void transceiverAdjustments::on_IFShiftSlider_valueChanged(int value) +{ + emit setIFShift(value); +} + +void transceiverAdjustments::on_TPBFInnerSlider_valueChanged(int value) +{ + emit setTPBFInner(value); +} + +void transceiverAdjustments::on_TPBFOuterSlider_valueChanged(int value) +{ + emit setTPBFOuter(value); +} + +void transceiverAdjustments::setRig(rigCapabilities rig) +{ + this->rigCaps = rig; + ui->IFShiftSlider->setVisible(rigCaps.hasIFShift); + ui->IFShiftLabel->setVisible(rigCaps.hasIFShift); + + ui->TPBFInnerSlider->setVisible(rigCaps.hasTBPF); + ui->TPBFInnerLabel->setVisible(rigCaps.hasTBPF); + + ui->TPBFOuterSlider->setVisible(rigCaps.hasTBPF); + ui->TPBFInnerLabel->setVisible(rigCaps.hasTBPF); + + haveRigCaps = true; +} + +// These are accessed by wfmain when we receive new values from rigCommander: +void transceiverAdjustments::updateIFShift(unsigned char level) +{ + ui->IFShiftSlider->blockSignals(true); + ui->IFShiftSlider->setValue(level); + ui->IFShiftSlider->blockSignals(false); +} + +void transceiverAdjustments::updateTPBFInner(unsigned char level) +{ + ui->TPBFInnerSlider->blockSignals(true); + ui->TPBFInnerSlider->setValue(level); + ui->TPBFInnerSlider->blockSignals(false); +} + +void transceiverAdjustments::updateTPBFOuter(unsigned char level) +{ + ui->TPBFOuterSlider->blockSignals(true); + ui->TPBFOuterSlider->setValue(level); + ui->TPBFOuterSlider->blockSignals(false); +} diff --git a/transceiveradjustments.h b/transceiveradjustments.h index 2eee158..2411d4d 100644 --- a/transceiveradjustments.h +++ b/transceiveradjustments.h @@ -2,6 +2,8 @@ #define TRANSCEIVERADJUSTMENTS_H #include +#include "rigidentities.h" + namespace Ui { class transceiverAdjustments; @@ -15,8 +17,29 @@ public: explicit transceiverAdjustments(QWidget *parent = 0); ~transceiverAdjustments(); +signals: + void setIFShift(unsigned char level); + void setTPBFInner(unsigned char level); + void setTPBFOuter(unsigned char level); + +public slots: + void setRig(rigCapabilities rig); + void updateIFShift(unsigned char level); + void updateTPBFInner(unsigned char level); + void updateTPBFOuter(unsigned char level); + +private slots: + + void on_IFShiftSlider_valueChanged(int value); + + void on_TPBFInnerSlider_valueChanged(int value); + + void on_TPBFOuterSlider_valueChanged(int value); + private: Ui::transceiverAdjustments *ui; + rigCapabilities rigCaps; + bool haveRigCaps = false; }; #endif // TRANSCEIVERADJUSTMENTS_H diff --git a/transceiveradjustments.ui b/transceiveradjustments.ui index 9e8bb32..415b7bb 100644 --- a/transceiveradjustments.ui +++ b/transceiveradjustments.ui @@ -6,8 +6,8 @@ 0 0 - 680 - 339 + 832 + 337 @@ -194,16 +194,16 @@ - + - + Qt::Vertical - + IF Shift @@ -211,6 +211,72 @@ + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 255 + + + Qt::Vertical + + + + + + + PBF Inner + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 255 + + + Qt::Vertical + + + + + + + PBF Outer + + + + + diff --git a/wfmain.cpp b/wfmain.cpp index 95d8353..c338533 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -291,6 +291,9 @@ void wfmain::rigConnections() connect(this, SIGNAL(getRfGain()), rig, SLOT(getRfGain())); connect(this, SIGNAL(getAfGain()), rig, SLOT(getAfGain())); connect(this, SIGNAL(getSql()), rig, SLOT(getSql())); + connect(this, SIGNAL(getIfShift()), rig, SLOT(getIFShift())); + connect(this, SIGNAL(getTPBFInner()), rig, SLOT(getTPBFInner())); + connect(this, SIGNAL(getTPBFOuter()), rig, SLOT(getTPBFOuter())); connect(this, SIGNAL(getTxPower()), rig, SLOT(getTxLevel())); connect(this, SIGNAL(getMicGain()), rig, SLOT(getMicGain())); connect(this, SIGNAL(getSpectrumRefLevel()), rig, SLOT(getSpectrumRefLevel())); @@ -301,6 +304,9 @@ void wfmain::rigConnections() connect(this, SIGNAL(setRfGain(unsigned char)), rig, SLOT(setRfGain(unsigned char))); connect(this, SIGNAL(setAfGain(unsigned char)), rig, SLOT(setAfGain(unsigned char))); connect(this, SIGNAL(setSql(unsigned char)), rig, SLOT(setSquelch(unsigned char))); + connect(this, SIGNAL(setIFShift(unsigned char)), rig, SLOT(setIFShift(unsigned char))); + connect(this, SIGNAL(setTPBFInner(unsigned char)), rig, SLOT(setTPBFInner(unsigned char))); + connect(this, SIGNAL(setTPBFOuter(unsigned char)), rig, SLOT(setTPBFOuter(unsigned char))); connect(this, SIGNAL(setTxPower(unsigned char)), rig, SLOT(setTxPower(unsigned char))); connect(this, SIGNAL(setMicGain(unsigned char)), rig, SLOT(setMicGain(unsigned char))); connect(this, SIGNAL(setMonitorLevel(unsigned char)), rig, SLOT(setMonitorLevel(unsigned char))); @@ -313,6 +319,9 @@ void wfmain::rigConnections() connect(rig, SIGNAL(haveRfGain(unsigned char)), this, SLOT(receiveRfGain(unsigned char))); connect(rig, SIGNAL(haveAfGain(unsigned char)), this, SLOT(receiveAfGain(unsigned char))); connect(rig, SIGNAL(haveSql(unsigned char)), this, SLOT(receiveSql(unsigned char))); + connect(rig, SIGNAL(haveIFShift(unsigned char)), trxadj, SLOT(updateIFShift(unsigned char))); + connect(rig, SIGNAL(haveTPBFInner(unsigned char)), trxadj, SLOT(updateTPBFInner(unsigned char))); + connect(rig, SIGNAL(haveTPBFOuter(unsigned char)), trxadj, SLOT(updateTPBFOuter(unsigned char))); connect(rig, SIGNAL(haveTxPower(unsigned char)), this, SLOT(receiveTxPower(unsigned char))); connect(rig, SIGNAL(haveMicGain(unsigned char)), this, SLOT(receiveMicGain(unsigned char))); connect(rig, SIGNAL(haveSpectrumRefLevel(int)), this, SLOT(receiveSpectrumRefLevel(int))); @@ -802,6 +811,20 @@ void wfmain::setupMainUI() [=](const int &newValue) { statusFromSliderRaw("Waterfall Length", newValue);} ); + connect(this->trxadj, &transceiverAdjustments::setIFShift, + [=](const unsigned char &newValue) { issueCmd(cmdSetIFShift, newValue);} + ); + + connect(this->trxadj, &transceiverAdjustments::setTPBFInner, + [=](const unsigned char &newValue) { issueCmd(cmdSetTPBFInner, newValue);} + ); + + connect(this->trxadj, &transceiverAdjustments::setTPBFOuter, + [=](const unsigned char &newValue) { issueCmd(cmdSetTPBFOuter, newValue);} + ); + + + } void wfmain::updateSizes(int tabIndex) @@ -2203,6 +2226,14 @@ void wfmain:: getInitialRigState() issueDelayedCommand(cmdGetRitEnabled); issueDelayedCommand(cmdGetRitValue); + if(rigCaps.hasIFShift) + issueDelayedCommand(cmdGetIFShift); + if(rigCaps.hasTBPF) + { + issueDelayedCommand(cmdGetTPBFInner); + issueDelayedCommand(cmdGetTPBFOuter); + } + if(rigCaps.hasSpectrum) { issueDelayedCommand(cmdGetSpectrumMode); @@ -2404,6 +2435,24 @@ void wfmain::doCmd(commandtype cmddata) emit setSql(sqlLevel); break; } + case cmdSetIFShift: + { + unsigned char IFShiftLevel = (*std::static_pointer_cast(data)); + emit setIFShift(IFShiftLevel); + break; + } + case cmdSetTPBFInner: + { + unsigned char innterLevel = (*std::static_pointer_cast(data)); + emit setTPBFInner(innterLevel); + break; + } + case cmdSetTPBFOuter: + { + unsigned char outerLevel = (*std::static_pointer_cast(data)); + emit setTPBFOuter(outerLevel); + break; + } case cmdSetPTT: { bool pttrequest = (*std::static_pointer_cast(data)); @@ -2546,6 +2595,15 @@ void wfmain::doCmd(cmds cmd) case cmdGetSql: emit getSql(); break; + case cmdGetIFShift: + emit getIfShift(); + break; + case cmdGetTPBFInner: + emit getTPBFInner(); + break; + case cmdGetTPBFOuter: + emit getTPBFOuter(); + break; case cmdGetTxPower: emit getTxPower(); break; @@ -2871,6 +2929,7 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) // Added so that server receives rig capabilities. emit sendRigCaps(rigCaps); rpt->setRig(rigCaps); + trxadj->setRig(rigCaps); // Set the mode combo box up: @@ -2992,6 +3051,7 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) setBandButtons(); + ui->tuneEnableChk->setEnabled(rigCaps.hasATU); ui->tuneNowBtn->setEnabled(rigCaps.hasATU); @@ -4054,6 +4114,21 @@ void wfmain::receiveSql(unsigned char level) ui->sqlSlider->setValue(level); } +void wfmain::receiveIFShift(unsigned char level) +{ + trxadj->updateIFShift(level); +} + +void wfmain::receiveTBPFInner(unsigned char level) +{ + trxadj->updateTPBFInner(level); +} + +void wfmain::receiveTBPFOuter(unsigned char level) +{ + trxadj->updateTPBFOuter(level); +} + void wfmain::on_tuneNowBtn_clicked() { issueDelayedCommand(cmdStartATU); @@ -4315,6 +4390,19 @@ void wfmain::on_sqlSlider_valueChanged(int value) issueCmd(cmdSetSql, (unsigned char)value); //emit setSql((unsigned char)value); } +// These three are from the transceiver adjustment window: +void wfmain::changeIFShift(unsigned char level) +{ + issueCmd(cmdSetIFShift, level); +} +void wfmain::changeTPBFInner(unsigned char level) +{ + issueCmd(cmdSetTPBFInner, level); +} +void wfmain::changeTPBFOuter(unsigned char level) +{ + issueCmd(cmdSetTPBFOuter, level); +} void wfmain::on_modeFilterCombo_activated(int index) { @@ -5343,7 +5431,7 @@ void wfmain::on_rigctldPortTxt_editingFinished() void wfmain::on_debugBtn_clicked() { qInfo(logSystem()) << "Debug button pressed."; - //trxadj->show(); + trxadj->show(); //setRadioTimeDatePrep(); //wf->setInteraction(QCP::iRangeZoom, true); //wf->setInteraction(QCP::iRangeDrag, true); diff --git a/wfmain.h b/wfmain.h index b921b9c..ac66e8e 100644 --- a/wfmain.h +++ b/wfmain.h @@ -85,6 +85,9 @@ signals: void getRfGain(); void getAfGain(); void getSql(); + void getIfShift(); + void getTPBFInner(); + void getTPBFOuter(); void getTxPower(); void getMicGain(); void getSpectrumRefLevel(); @@ -94,6 +97,13 @@ signals: void setRfGain(unsigned char level); void setAfGain(unsigned char level); void setSql(unsigned char level); + void setIFShift(unsigned char level); + void setTPBFInner(unsigned char level); + void setTPBFOuter(unsigned char level); + + void setIFShiftWindow(unsigned char level); + void setTPBFInnerWindow(unsigned char level); + void setTPBFOuterWindow(unsigned char level); void setMicGain(unsigned char); void setCompLevel(unsigned char); void setTxPower(unsigned char); @@ -213,6 +223,13 @@ private slots: void receiveRfGain(unsigned char level); void receiveAfGain(unsigned char level); void receiveSql(unsigned char level); + void receiveIFShift(unsigned char level); + void receiveTBPFInner(unsigned char level); + void receiveTBPFOuter(unsigned char level); + // 'change' from data in transceiver controls window: + void changeIFShift(unsigned char level); + void changeTPBFInner(unsigned char level); + void changeTPBFOuter(unsigned char level); void receiveTxPower(unsigned char power); void receiveMicGain(unsigned char gain); void receiveCompLevel(unsigned char compLevel); @@ -600,13 +617,18 @@ private: unsigned char setModeVal=0; unsigned char setFilterVal=0; - enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdSetFreq, cmdGetMode, cmdSetMode, cmdGetDataMode, cmdSetModeFilter, - cmdSetDataModeOn, cmdSetDataModeOff, cmdGetRitEnabled, cmdGetRitValue, + enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdSetFreq, cmdGetMode, cmdSetMode, + cmdGetDataMode, cmdSetModeFilter, cmdSetDataModeOn, cmdSetDataModeOff, cmdGetRitEnabled, cmdGetRitValue, cmdSpecOn, cmdSpecOff, cmdDispEnable, cmdDispDisable, cmdGetRxGain, cmdSetRxRfGain, cmdGetAfGain, cmdSetAfGain, - cmdGetSql, cmdSetSql, cmdGetATUStatus, cmdSetATU, cmdStartATU, cmdGetSpectrumMode, cmdGetSpectrumSpan, cmdScopeCenterMode, cmdScopeFixedMode, cmdGetPTT, cmdSetPTT, - cmdGetTxPower, cmdSetTxPower, cmdGetMicGain, cmdSetMicGain, cmdSetModLevel, cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput, + cmdGetSql, cmdSetSql, cmdGetIFShift, cmdSetIFShift, cmdGetTPBFInner, cmdSetTPBFInner, + cmdGetTPBFOuter, cmdSetTPBFOuter, cmdGetATUStatus, + cmdSetATU, cmdStartATU, cmdGetSpectrumMode, + cmdGetSpectrumSpan, cmdScopeCenterMode, cmdScopeFixedMode, cmdGetPTT, cmdSetPTT, + cmdGetTxPower, cmdSetTxPower, cmdGetMicGain, cmdSetMicGain, cmdSetModLevel, + cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput, cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdQueNormalSpeed, - cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetCenterMeter, cmdGetPowerMeter, cmdGetSWRMeter, cmdGetALCMeter, cmdGetCompMeter, cmdGetTxRxMeter, + cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetCenterMeter, cmdGetPowerMeter, + cmdGetSWRMeter, cmdGetALCMeter, cmdGetCompMeter, cmdGetTxRxMeter, cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna, cmdSetTime, cmdSetDate, cmdSetUTCOffset}; diff --git a/wfmain.ui b/wfmain.ui index f392fd8..0194a6a 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -6,7 +6,7 @@ 0 0 - 934 + 941 582 @@ -18,7 +18,7 @@ - 3 + 0 @@ -2814,8 +2814,8 @@ 0 0 - 934 - 21 + 941 + 22 From a9fb81d8f681006458af656492b584981aeb4ed1 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 5 Nov 2021 11:52:20 -0700 Subject: [PATCH 47/79] Added an IF Shift-like control for radios with Twin PBF. --- transceiveradjustments.cpp | 21 ++++++++++++++++++--- transceiveradjustments.h | 3 +++ transceiveradjustments.ui | 3 +++ wfmain.cpp | 7 ++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/transceiveradjustments.cpp b/transceiveradjustments.cpp index 319b305..a5e8501 100644 --- a/transceiveradjustments.cpp +++ b/transceiveradjustments.cpp @@ -22,7 +22,20 @@ transceiverAdjustments::~transceiverAdjustments() void transceiverAdjustments::on_IFShiftSlider_valueChanged(int value) { - emit setIFShift(value); + if(rigCaps.hasIFShift) + { + emit setIFShift(value); + } else { + unsigned char inner = ui->TPBFInnerSlider->value(); + unsigned char outer = ui->TPBFOuterSlider->value(); + int shift = value - previousIFShift; + inner = MAX( 0, MIN(255,int (inner + shift)) ); + outer = MAX( 0, MIN(255,int (outer + shift)) ); + + ui->TPBFInnerSlider->setValue(inner); + ui->TPBFOuterSlider->setValue(outer); + previousIFShift = value; + } } void transceiverAdjustments::on_TPBFInnerSlider_valueChanged(int value) @@ -38,8 +51,10 @@ void transceiverAdjustments::on_TPBFOuterSlider_valueChanged(int value) void transceiverAdjustments::setRig(rigCapabilities rig) { this->rigCaps = rig; - ui->IFShiftSlider->setVisible(rigCaps.hasIFShift); - ui->IFShiftLabel->setVisible(rigCaps.hasIFShift); + if(!rigCaps.hasIFShift) + updateIFShift(128); + //ui->IFShiftSlider->setVisible(rigCaps.hasIFShift); + //ui->IFShiftLabel->setVisible(rigCaps.hasIFShift); ui->TPBFInnerSlider->setVisible(rigCaps.hasTBPF); ui->TPBFInnerLabel->setVisible(rigCaps.hasTBPF); diff --git a/transceiveradjustments.h b/transceiveradjustments.h index 2411d4d..bec6a34 100644 --- a/transceiveradjustments.h +++ b/transceiveradjustments.h @@ -1,6 +1,8 @@ #ifndef TRANSCEIVERADJUSTMENTS_H #define TRANSCEIVERADJUSTMENTS_H +#include + #include #include "rigidentities.h" @@ -40,6 +42,7 @@ private: Ui::transceiverAdjustments *ui; rigCapabilities rigCaps; bool haveRigCaps = false; + int previousIFShift = 128; }; #endif // TRANSCEIVERADJUSTMENTS_H diff --git a/transceiveradjustments.ui b/transceiveradjustments.ui index 415b7bb..791c7ef 100644 --- a/transceiveradjustments.ui +++ b/transceiveradjustments.ui @@ -197,6 +197,9 @@ + + 255 + Qt::Vertical diff --git a/wfmain.cpp b/wfmain.cpp index c338533..6afc3fa 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4393,15 +4393,16 @@ void wfmain::on_sqlSlider_valueChanged(int value) // These three are from the transceiver adjustment window: void wfmain::changeIFShift(unsigned char level) { - issueCmd(cmdSetIFShift, level); + //issueCmd(cmdSetIFShift, level); + issueCmdUniquePriority(cmdSetIFShift, level); } void wfmain::changeTPBFInner(unsigned char level) { - issueCmd(cmdSetTPBFInner, level); + issueCmdUniquePriority(cmdSetTPBFInner, level); } void wfmain::changeTPBFOuter(unsigned char level) { - issueCmd(cmdSetTPBFOuter, level); + issueCmdUniquePriority(cmdSetTPBFOuter, level); } void wfmain::on_modeFilterCombo_activated(int index) From 76c5488983f876a2d139455074951fd2f6f367d2 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 5 Nov 2021 17:12:19 -0700 Subject: [PATCH 48/79] Changed IF/TPBF commands to be "unique priority" inserts. Added "more" button for extended transceiver controls. --- wfmain.cpp | 11 ++++++++--- wfmain.h | 2 ++ wfmain.ui | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 6afc3fa..94bc45a 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -812,15 +812,15 @@ void wfmain::setupMainUI() ); connect(this->trxadj, &transceiverAdjustments::setIFShift, - [=](const unsigned char &newValue) { issueCmd(cmdSetIFShift, newValue);} + [=](const unsigned char &newValue) { issueCmdUniquePriority(cmdSetIFShift, newValue);} ); connect(this->trxadj, &transceiverAdjustments::setTPBFInner, - [=](const unsigned char &newValue) { issueCmd(cmdSetTPBFInner, newValue);} + [=](const unsigned char &newValue) { issueCmdUniquePriority(cmdSetTPBFInner, newValue);} ); connect(this->trxadj, &transceiverAdjustments::setTPBFOuter, - [=](const unsigned char &newValue) { issueCmd(cmdSetTPBFOuter, newValue);} + [=](const unsigned char &newValue) { issueCmdUniquePriority(cmdSetTPBFOuter, newValue);} ); @@ -5428,6 +5428,11 @@ void wfmain::on_rigctldPortTxt_editingFinished() } } +void wfmain::on_moreControlsBtn_clicked() +{ + trxadj->show(); +} + // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index ac66e8e..356ae9a 100644 --- a/wfmain.h +++ b/wfmain.h @@ -495,6 +495,8 @@ private slots: void on_rigctldPortTxt_editingFinished(); + void on_moreControlsBtn_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); diff --git a/wfmain.ui b/wfmain.ui index 0194a6a..e129aac 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -465,6 +465,16 @@ + + + + Show additional controls + + + Show More + + + @@ -852,6 +862,9 @@ 50 + + Transmit and Receive button + Transmit @@ -885,6 +898,9 @@ + + Show the repeater tone and offset window + Repeater From cd7ea9724281f32a24e6b080138f52b6b895e9ae Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 5 Nov 2021 17:38:07 -0700 Subject: [PATCH 49/79] Added geometry constraints to the transceiver adjustments window, and disable controls which do not function except for debug builds. --- transceiveradjustments.cpp | 19 ++++- transceiveradjustments.ui | 148 +++++++++++++++++++++++++++---------- 2 files changed, 128 insertions(+), 39 deletions(-) diff --git a/transceiveradjustments.cpp b/transceiveradjustments.cpp index a5e8501..c87c612 100644 --- a/transceiveradjustments.cpp +++ b/transceiveradjustments.cpp @@ -6,7 +6,24 @@ transceiverAdjustments::transceiverAdjustments(QWidget *parent) : ui(new Ui::transceiverAdjustments) { ui->setupUi(this); - // request level updates +#ifndef QT_DEBUG + ui->transmitterControlsGroupBox->setVisible(false); // no controls available so far + ui->bassRxLabel->setVisible(false); + ui->bassRxSlider->setVisible(false); + ui->trebleRxLabel->setVisible(false); + ui->trebleRxSlider->setVisible(false); + + ui->NRRxCheckBox->setVisible(false); + ui->NRRxSlider->setVisible(false); + ui->notchRxChkBox->setVisible(false); + ui->notchRxSlider->setVisible(false); + ui->NBRxChkBox->setVisible(false); + ui->NBRxSlider->setVisible(false); + ui->bandwidthGroupBox->setVisible(false); + this->window()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + this->window()->resize(QSizePolicy::Minimum, QSizePolicy::Minimum); + +#endif } diff --git a/transceiveradjustments.ui b/transceiveradjustments.ui index 791c7ef..62debf0 100644 --- a/transceiveradjustments.ui +++ b/transceiveradjustments.ui @@ -29,13 +29,13 @@ 10 - + Transmitter - + 0 @@ -49,14 +49,20 @@ 0 - + + + + 0 + 230 + + Qt::Vertical - + Comp @@ -65,16 +71,22 @@ - + - + + + + 0 + 230 + + Qt::Vertical - + 0 @@ -89,16 +101,22 @@ - + - + + + + 0 + 230 + + Qt::Vertical - + 0 @@ -106,23 +124,29 @@ - Trebble + Treble - + - + + + + 0 + 230 + + Qt::Vertical - + 0 @@ -140,22 +164,28 @@ - + Receiver - + - + + + + 0 + 230 + + Qt::Vertical - + 0 @@ -170,16 +200,22 @@ - + - + + + + 0 + 230 + + Qt::Vertical - + 0 @@ -187,7 +223,7 @@ - Trebble + Treble @@ -197,6 +233,12 @@ + + + 0 + 230 + + 255 @@ -230,6 +272,12 @@ + + + 0 + 230 + + 255 @@ -263,6 +311,12 @@ + + + 0 + 230 + + 255 @@ -281,16 +335,22 @@ - + - + + + + 0 + 230 + + Qt::Vertical - + NR @@ -299,16 +359,22 @@ - + - + + + + 0 + 230 + + Qt::Vertical - + NB @@ -317,16 +383,22 @@ - + - + + + + 0 + 230 + + Qt::Vertical - + Notch @@ -335,40 +407,40 @@ - + Bandwidth - + Low - + - + High - + - + Filter - + From 77509aead67356d8e09c11786ed8fbd75aa775cc Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 5 Nov 2021 23:21:36 -0700 Subject: [PATCH 50/79] Added RTS PTT support commHandler and rigCommander. RTS is only sent from rigCommander at this time, the pty is not parsed. --- commhandler.cpp | 20 ++++++++++++++++++++ commhandler.h | 8 ++++++++ rigcommander.cpp | 27 +++++++++++++++++++++------ rigcommander.h | 1 + rigidentities.h | 1 + 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/commhandler.cpp b/commhandler.cpp index 7a48d87..165c90e 100644 --- a/commhandler.cpp +++ b/commhandler.cpp @@ -45,6 +45,7 @@ commHandler::commHandler(QString portName, quint32 baudRate) baudrate = baudRate; stopbits = 1; this->portName = portName; + this->PTTviaRTS = false; setupComm(); // basic parameters openPort(); @@ -162,6 +163,25 @@ void commHandler::receiveDataIn() } } +void commHandler::setRTS(bool rtsOn) +{ + bool success = port->setRequestToSend(rtsOn); + if(!success) + { + qInfo(logSerial()) << "Error, could not set RTS on port " << portName; + } +} + +bool commHandler::rtsStatus() +{ + return port->isRequestToSend(); +} + +void commHandler::setUseRTSforPTT(bool PTTviaRTS) +{ + this->PTTviaRTS = PTTviaRTS; +} + void commHandler::openPort() { bool success; diff --git a/commhandler.h b/commhandler.h index e7e5580..c76e23f 100644 --- a/commhandler.h +++ b/commhandler.h @@ -18,9 +18,14 @@ public: commHandler(); commHandler(QString portName, quint32 baudRate); bool serialError; + bool rtsStatus(); ~commHandler(); +public slots: + void setUseRTSforPTT(bool useRTS); + void setRTS(bool rtsOn); + private slots: void receiveDataIn(); // from physical port void receiveDataFromUserToRig(const QByteArray &data); @@ -38,6 +43,7 @@ private: void openPort(); void closePort(); + void sendDataOut(const QByteArray &writeData); // out to radio void debugMe(); void hexPrint(); @@ -63,6 +69,8 @@ private: bool havePt; QString ptDevSlave; + bool PTTviaRTS = false; + bool isConnected; // port opened mutable QMutex mutex; void printHex(const QByteArray &pdata, bool printVert, bool printHoriz); diff --git a/rigcommander.cpp b/rigcommander.cpp index c6e72e0..b57e285 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -63,6 +63,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu connect(ptty, SIGNAL(haveDataFromPort(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray))); // data from the program to the comm port: connect(this, SIGNAL(dataForComm(QByteArray)), comm, SLOT(receiveDataFromUserToRig(QByteArray))); + connect(this, SIGNAL(toggleRTS(bool)), comm, SLOT(setRTS(bool))); // data from the rig to the ptty: connect(comm, SIGNAL(haveDataFromPort(QByteArray)), ptty, SLOT(receiveDataFromRigToPtty(QByteArray))); @@ -992,9 +993,14 @@ void rigCommander::getSatelliteMode() void rigCommander::getPTT() { - QByteArray payload; - payload.setRawData("\x1C\x00", 2); - prepDataAndSend(payload); + if(rigCaps.useRTSforPTT) + { + emit havePTTStatus(comm->rtsStatus()); + } else { + QByteArray payload; + payload.setRawData("\x1C\x00", 2); + prepDataAndSend(payload); + } } void rigCommander::getBandStackReg(char band, char regCode) @@ -1011,9 +1017,14 @@ void rigCommander::setPTT(bool pttOn) if(pttAllowed) { - QByteArray payload("\x1C\x00", 2); - payload.append((char)pttOn); - prepDataAndSend(payload); + if(rigCaps.useRTSforPTT) + { + emit toggleRTS(pttOn); + } else { + QByteArray payload("\x1C\x00", 2); + payload.append((char)pttOn); + prepDataAndSend(payload); + } rigState.ptt = pttOn; } } @@ -2908,6 +2919,7 @@ void rigCommander::determineRigCaps() rigCaps.hasTransmit = true; rigCaps.hasPTTCommand = true; + rigCaps.useRTSforPTT = false; // Common, reasonable defaults for most supported HF rigs: rigCaps.bsr[band160m] = 0x01; @@ -3321,6 +3333,7 @@ void rigCommander::determineRigCaps() rigCaps.hasFDcomms = false; rigCaps.hasATU = true; rigCaps.hasPTTCommand = false; + rigCaps.useRTSforPTT = true; rigCaps.hasDataModes = false; rigCaps.attenuators.push_back('\x20'); rigCaps.bands = standardHF; @@ -3341,6 +3354,7 @@ void rigCommander::determineRigCaps() rigCaps.hasFDcomms = false; rigCaps.hasATU = false; rigCaps.hasPTTCommand = false; + rigCaps.useRTSforPTT = true; rigCaps.hasIFShift = true; rigCaps.hasDataModes = false; rigCaps.attenuators.push_back('\x20'); @@ -3366,6 +3380,7 @@ void rigCommander::determineRigCaps() rigCaps.hasFDcomms = false; rigCaps.hasATU = false; rigCaps.hasPTTCommand = false; + rigCaps.useRTSforPTT = true; rigCaps.hasDataModes = false; rigCaps.hasIFShift = true; // untested rigCaps.attenuators.push_back('\x20'); diff --git a/rigcommander.h b/rigcommander.h index 1abc38f..bf02aad 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -322,6 +322,7 @@ signals: void haveSerialPortError(const QString port, const QString errorText); void haveStatusUpdate(const QString text); void dataForComm(const QByteArray &outData); + void toggleRTS(bool rtsOn); // UDP: void haveChangeLatency(quint16 value); diff --git a/rigidentities.h b/rigidentities.h index a87d9ec..cae1b75 100644 --- a/rigidentities.h +++ b/rigidentities.h @@ -118,6 +118,7 @@ struct rigCapabilities { bool hasTransmit; bool hasPTTCommand; + bool useRTSforPTT; bool hasAttenuator; bool hasPreamp; bool hasAntennaSel; From 589df7180575a61cc7bfb13008b8a8c4caeeacb8 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sat, 6 Nov 2021 10:42:13 +0000 Subject: [PATCH 51/79] Change MAX/MIN to use qMax/qMin instead --- transceiveradjustments.cpp | 4 ++-- transceiveradjustments.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/transceiveradjustments.cpp b/transceiveradjustments.cpp index c87c612..309cd43 100644 --- a/transceiveradjustments.cpp +++ b/transceiveradjustments.cpp @@ -46,8 +46,8 @@ void transceiverAdjustments::on_IFShiftSlider_valueChanged(int value) unsigned char inner = ui->TPBFInnerSlider->value(); unsigned char outer = ui->TPBFOuterSlider->value(); int shift = value - previousIFShift; - inner = MAX( 0, MIN(255,int (inner + shift)) ); - outer = MAX( 0, MIN(255,int (outer + shift)) ); + inner = qMax( 0, qMin(255,int (inner + shift)) ); + outer =qMax( 0, qMin(255,int (outer + shift)) ); ui->TPBFInnerSlider->setValue(inner); ui->TPBFOuterSlider->setValue(outer); diff --git a/transceiveradjustments.h b/transceiveradjustments.h index bec6a34..2f5ecd6 100644 --- a/transceiveradjustments.h +++ b/transceiveradjustments.h @@ -1,7 +1,9 @@ #ifndef TRANSCEIVERADJUSTMENTS_H #define TRANSCEIVERADJUSTMENTS_H -#include + + +#include #include #include "rigidentities.h" From 35bc1afb4bb7465e675b94aadf930a8f2c454428 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sat, 6 Nov 2021 10:42:13 +0000 Subject: [PATCH 52/79] Change MAX/MIN to use qMax/qMin instead --- transceiveradjustments.cpp | 4 ++-- transceiveradjustments.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/transceiveradjustments.cpp b/transceiveradjustments.cpp index c87c612..309cd43 100644 --- a/transceiveradjustments.cpp +++ b/transceiveradjustments.cpp @@ -46,8 +46,8 @@ void transceiverAdjustments::on_IFShiftSlider_valueChanged(int value) unsigned char inner = ui->TPBFInnerSlider->value(); unsigned char outer = ui->TPBFOuterSlider->value(); int shift = value - previousIFShift; - inner = MAX( 0, MIN(255,int (inner + shift)) ); - outer = MAX( 0, MIN(255,int (outer + shift)) ); + inner = qMax( 0, qMin(255,int (inner + shift)) ); + outer =qMax( 0, qMin(255,int (outer + shift)) ); ui->TPBFInnerSlider->setValue(inner); ui->TPBFOuterSlider->setValue(outer); diff --git a/transceiveradjustments.h b/transceiveradjustments.h index bec6a34..2f5ecd6 100644 --- a/transceiveradjustments.h +++ b/transceiveradjustments.h @@ -1,7 +1,9 @@ #ifndef TRANSCEIVERADJUSTMENTS_H #define TRANSCEIVERADJUSTMENTS_H -#include + + +#include #include #include "rigidentities.h" From d58a078f705fb111622a816215e53155982099a5 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sat, 6 Nov 2021 13:09:55 +0100 Subject: [PATCH 53/79] deleted a lingering swapfile from one of my vim sessions --- .swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .swp diff --git a/.swp b/.swp deleted file mode 100644 index fbeaaba9ab9981e852f4edbefe8c4d1a01072e9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&%}T>S5C`y7PhM2&3yg|iAff8T2k@YR$JX<-JKav3?v^CBkc&^?gZLaim*Awf z7oiA3!NNa~oy=}_Gx*jlVYbHq^CF9_hT`OY|;%vgHhAC(I z`{^s!!2kpxuug%U_RaOx{82wXI;4YUdz}}<+7N&M1Rwwb2tWV=5P-lx6DTK*ag{ks?3<0uX=z1Rwwb2tWV=5P$##Ah3Y~Y~SlYca!8~&x*J2|I7FPGs{nH zpZ9OzeW7FsKmY;|fB*y_009U<00Izzz#jyjRVXm$Boe5{{f~Ew{drOjgiFb3rr9Np zqm Date: Sat, 6 Nov 2021 13:10:41 +0100 Subject: [PATCH 54/79] deleted a lingering swapfile from one of my vim sessions --- .swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .swp diff --git a/.swp b/.swp deleted file mode 100644 index fbeaaba9ab9981e852f4edbefe8c4d1a01072e9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&%}T>S5C`y7PhM2&3yg|iAff8T2k@YR$JX<-JKav3?v^CBkc&^?gZLaim*Awf z7oiA3!NNa~oy=}_Gx*jlVYbHq^CF9_hT`OY|;%vgHhAC(I z`{^s!!2kpxuug%U_RaOx{82wXI;4YUdz}}<+7N&M1Rwwb2tWV=5P-lx6DTK*ag{ks?3<0uX=z1Rwwb2tWV=5P$##Ah3Y~Y~SlYca!8~&x*J2|I7FPGs{nH zpZ9OzeW7FsKmY;|fB*y_009U<00Izzz#jyjRVXm$Boe5{{f~Ew{drOjgiFb3rr9Np zqm Date: Sat, 6 Nov 2021 22:49:10 -0700 Subject: [PATCH 55/79] Added PTT "snooping" to the commHandler, such that radios needing RTS set for PTT will work. Includes replying to PTT queries with the RTS status. There is currently no UI to manually select radios that need RTS. --- commhandler.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ rigcommander.cpp | 27 ++++++++++++------------ wfmain.cpp | 27 ++++++++++++++---------- 3 files changed, 84 insertions(+), 24 deletions(-) diff --git a/commhandler.cpp b/commhandler.cpp index 165c90e..2160f15 100644 --- a/commhandler.cpp +++ b/commhandler.cpp @@ -20,6 +20,7 @@ commHandler::commHandler() baudrate = 115200; stopbits = 1; portName = "/dev/ttyUSB0"; + this->PTTviaRTS = false; setupComm(); // basic parameters openPort(); @@ -81,6 +82,59 @@ void commHandler::sendDataOut(const QByteArray &writeData) mutex.lock(); qint64 bytesWritten; + + if(PTTviaRTS) + { + // Size: 1 2 3 4 5 6 7 8 + //index: 0 1 2 3 4 5 6 7 + //Query: FE FE TO FROM 0x1C 0x00 0xFD + //PTT On: FE FE TO FROM 0x1C 0x00 0x01 0xFD + //PTT Off: FE FE TO FROM 0x1C 0x00 0x00 0xFD + + if(writeData.endsWith(QByteArrayLiteral("\x1C\x00\xFD"))) + { + // Query + qDebug(logSerial()) << "Looks like PTT Query"; + + + bool pttOn = this->rtsStatus(); + QByteArray pttreturncmd = QByteArray("\xFE\xFE"); + pttreturncmd.append(writeData.at(3)); + pttreturncmd.append(writeData.at(2)); + pttreturncmd.append(QByteArray("\x1C\x00", 2)); + pttreturncmd.append((char)pttOn); + pttreturncmd.append("\xFD"); + qDebug(logSerial()) << "Sending fake PTT query result: " << (bool)pttOn; + printHex(pttreturncmd, false, true); + emit haveDataFromPort(pttreturncmd); + + + mutex.unlock(); + return; + } else if(writeData.endsWith(QByteArrayLiteral("\x1C\x00\x01\xFD"))) + { + // PTT ON + qDebug(logSerial()) << "Looks like PTT ON"; + setRTS(true); + mutex.unlock(); + return; + } else if(writeData.endsWith(QByteArrayLiteral("\x1C\x00\x00\xFD"))) + { + // PTT OFF + qDebug(logSerial()) << "Looks like PTT OFF"; + setRTS(false); + mutex.unlock(); + return; + } else if (writeData.length() > 6) + { + if(writeData.at(4) == 0x1c ) + { + qDebug(logSerial()) << "Potential 0x1C PTT command did not match. Has length " << writeData.length() << " and contains:"; + printHex(writeData, false, true); + } + } + } + bytesWritten = port->write(writeData); if(bytesWritten != (qint64)writeData.size()) diff --git a/rigcommander.cpp b/rigcommander.cpp index b57e285..673ae03 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -993,14 +993,14 @@ void rigCommander::getSatelliteMode() void rigCommander::getPTT() { - if(rigCaps.useRTSforPTT) - { - emit havePTTStatus(comm->rtsStatus()); - } else { + //if(rigCaps.useRTSforPTT && !usingNativeLAN) + //{ + // emit havePTTStatus(comm->rtsStatus()); + //} else { QByteArray payload; payload.setRawData("\x1C\x00", 2); prepDataAndSend(payload); - } + //} } void rigCommander::getBandStackReg(char band, char regCode) @@ -1017,14 +1017,9 @@ void rigCommander::setPTT(bool pttOn) if(pttAllowed) { - if(rigCaps.useRTSforPTT) - { - emit toggleRTS(pttOn); - } else { - QByteArray payload("\x1C\x00", 2); - payload.append((char)pttOn); - prepDataAndSend(payload); - } + QByteArray payload("\x1C\x00", 2); + payload.append((char)pttOn); + prepDataAndSend(payload); rigState.ptt = pttOn; } } @@ -2340,6 +2335,8 @@ void rigCommander::parseRegister21() longfreq = payloadIn.mid(2,2); longfreq.append(QByteArray(3,'\x00')); f = parseFrequency(longfreq, 3); + if(payloadIn.length() < 5) + break; ritHz = f.Hz*((payloadIn.at(4)=='\x01')?-1:1); emit haveRitFrequency(ritHz); break; @@ -3508,6 +3505,10 @@ void rigCommander::determineRigCaps() } haveRigCaps = true; + if(!usingNativeLAN) + comm->setUseRTSforPTT(rigCaps.useRTSforPTT); + + if(lookingForRig) { lookingForRig = false; diff --git a/wfmain.cpp b/wfmain.cpp index 94bc45a..a27f384 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2614,10 +2614,12 @@ void wfmain::doCmd(cmds cmd) emit getSpectrumRefLevel(); break; case cmdGetATUStatus: - emit getATUStatus(); + if(rigCaps.hasATU) + emit getATUStatus(); break; case cmdStartATU: - emit startATU(); + if(rigCaps.hasATU) + emit startATU(); break; case cmdGetAttenuator: emit getAttenuator(); @@ -2635,10 +2637,7 @@ void wfmain::doCmd(cmds cmd) emit setScopeMode(spectModeFixed); break; case cmdGetPTT: - if(rigCaps.hasPTTCommand) - { - emit getPTT(); - } + emit getPTT(); break; case cmdGetTxRxMeter: if(amTransmitting) @@ -3094,12 +3093,16 @@ void wfmain::initPeriodicCommands() insertSlowPeriodicCommand(cmdGetFreq, 128); insertSlowPeriodicCommand(cmdGetMode, 128); - insertSlowPeriodicCommand(cmdGetPTT, 128); + if(rigCaps.hasTransmit) + insertSlowPeriodicCommand(cmdGetPTT, 128); insertSlowPeriodicCommand(cmdGetTxPower, 128); insertSlowPeriodicCommand(cmdGetRxGain, 128); - insertSlowPeriodicCommand(cmdGetAttenuator, 128); - insertSlowPeriodicCommand(cmdGetPTT, 128); - insertSlowPeriodicCommand(cmdGetPreamp, 128); + if(rigCaps.hasAttenuator) + insertSlowPeriodicCommand(cmdGetAttenuator, 128); + if(rigCaps.hasTransmit) + insertSlowPeriodicCommand(cmdGetPTT, 128); + if(rigCaps.hasPreamp) + insertSlowPeriodicCommand(cmdGetPreamp, 128); if (rigCaps.hasRXAntenna) { insertSlowPeriodicCommand(cmdGetAntenna, 128); } @@ -5437,7 +5440,9 @@ void wfmain::on_moreControlsBtn_clicked() void wfmain::on_debugBtn_clicked() { qInfo(logSystem()) << "Debug button pressed."; - trxadj->show(); + // issueDelayedCommand(cmdGetRigID); + emit getRigCIV(); + //trxadj->show(); //setRadioTimeDatePrep(); //wf->setInteraction(QCP::iRangeZoom, true); //wf->setInteraction(QCP::iRangeDrag, true); From 88430db9ac342a298ea3943272c3c614cbaccbea Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sat, 6 Nov 2021 23:59:03 -0700 Subject: [PATCH 56/79] Added override allowing the user-specified CI-V address to also be used as the Rig ID (model). This is useful for older radios that do not reply to Rig ID queries. For radios using the default CI-V address, it should "just work". --- rigcommander.cpp | 19 +++++++++++++++++++ rigcommander.h | 1 + rigidentities.cpp | 3 +++ wfmain.cpp | 25 +++++++++++++++++++++++-- wfmain.h | 4 ++++ wfmain.ui | 16 +++++++++++++--- 6 files changed, 63 insertions(+), 5 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 673ae03..694b276 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -3952,6 +3952,25 @@ void rigCommander::getRigID() prepDataAndSend(payload); } +void rigCommander::setRigID(unsigned char rigID) +{ + // This function overrides radio model detection. + // It can be used for radios without Rig ID commands, + // or to force a specific radio model + + qInfo(logRig()) << "Sending rig ID to: (int)" << (int)rigID; + + + lookingForRig = true; + foundRig = false; + + this->model = determineRadioModel(rigID); + rigCaps.modelID = rigID; + rigCaps.model = determineRadioModel(rigID); + + determineRigCaps(); +} + void rigCommander::changeLatency(const quint16 value) { emit haveChangeLatency(value); diff --git a/rigcommander.h b/rigcommander.h index bf02aad..2b18c36 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -280,6 +280,7 @@ public slots: // Rig ID and CIV: void getRigID(); void findRigs(); + void setRigID(unsigned char rigID); void setCIVAddr(unsigned char civAddr); // Calibration: diff --git a/rigidentities.cpp b/rigidentities.cpp index 13988b4..a48a44d 100644 --- a/rigidentities.cpp +++ b/rigidentities.cpp @@ -55,6 +55,9 @@ model_kind determineRadioModel(unsigned char rigID) case model718: rig = model718; break; + case model736: + rig = model736; + break; case model910h: rig = model910h; break; diff --git a/wfmain.cpp b/wfmain.cpp index b71b28b..ff1011f 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -408,6 +408,7 @@ void wfmain::makeRig() connect(this, SIGNAL(sendCloseComm()), rig, SLOT(closeComm())); connect(this, SIGNAL(sendChangeLatency(quint16)), rig, SLOT(changeLatency(quint16))); connect(this, SIGNAL(getRigCIV()), rig, SLOT(findRigs())); + connect(this, SIGNAL(setRigID(unsigned char)), rig, SLOT(setRigID(unsigned char))); connect(rig, SIGNAL(discoveredRigID(rigCapabilities)), this, SLOT(receiveFoundRigID(rigCapabilities))); connect(rig, SIGNAL(commReady()), this, SLOT(receiveCommReady())); @@ -532,8 +533,14 @@ void wfmain::receiveCommReady() // We still query the rigID to find the model, but at least we know the CIV. qInfo(logSystem()) << "Skipping automatic CIV, using user-supplied value of " << prefs.radioCIVAddr; showStatusBarText(QString("Using user-supplied radio CI-V address of 0x%1").arg(prefs.radioCIVAddr, 2, 16)); - emit getRigID(); - getInitialRigState(); + if(prefs.CIVisRadioModel) + { + qInfo(logSystem()) << "Skipping Rig ID query, using user-supplied model from CI-V address: " << prefs.radioCIVAddr; + emit setRigID(prefs.radioCIVAddr); + } else { + emit getRigID(); + getInitialRigState(); + } } } @@ -990,6 +997,10 @@ void wfmain::setUIToPrefs() ui->wfthemeCombo->setCurrentIndex(ui->wfthemeCombo->findData(prefs.wftheme)); colorMap->setGradient(static_cast(prefs.wftheme)); + + ui->useCIVasRigIDChk->blockSignals(true); + ui->useCIVasRigIDChk->setChecked(prefs.CIVisRadioModel); + ui->useCIVasRigIDChk->blockSignals(false); } void wfmain::setAudioDevicesUI() @@ -1285,6 +1296,7 @@ void wfmain::setDefPrefs() defPrefs.wfInterpolate = true; defPrefs.stylesheetPath = QString("qdarkstyle/style.qss"); defPrefs.radioCIVAddr = 0x00; // previously was 0x94 for 7300. + defPrefs.CIVisRadioModel = false; defPrefs.serialPortRadio = QString("auto"); defPrefs.serialPortBaud = 115200; defPrefs.enablePTT = false; @@ -1382,6 +1394,9 @@ void wfmain::loadSettings() ui->rigCIVManualAddrChk->setChecked(false); ui->rigCIVaddrHexLine->setEnabled(false); } + prefs.CIVisRadioModel = (bool)settings->value("CIVisRadioModel", defPrefs.CIVisRadioModel).toBool(); + + prefs.serialPortRadio = settings->value("SerialPortRadio", defPrefs.serialPortRadio).toString(); int serialIndex = ui->serialDeviceListCombo->findText(prefs.serialPortRadio); if (serialIndex != -1) { @@ -1640,6 +1655,7 @@ void wfmain::saveSettings() // Radio and Comms: C-IV addr, port to use settings->beginGroup("Radio"); settings->setValue("RigCIVuInt", prefs.radioCIVAddr); + settings->setValue("CIVisRadioModel", prefs.CIVisRadioModel); settings->setValue("SerialPortRadio", prefs.serialPortRadio); settings->setValue("SerialPortBaud", prefs.serialPortBaud); settings->setValue("VirtualSerialPort", prefs.virtualSerialPort); @@ -5474,6 +5490,11 @@ void wfmain::on_moreControlsBtn_clicked() trxadj->show(); } +void wfmain::on_useCIVasRigIDChk_clicked(bool checked) +{ + prefs.CIVisRadioModel = checked; +} + // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index 356ae9a..b854a48 100644 --- a/wfmain.h +++ b/wfmain.h @@ -51,6 +51,7 @@ public: signals: // Basic to rig: void setCIVAddr(unsigned char newRigCIVAddr); + void setRigID(unsigned char rigID); // Power void sendPowerOn(); @@ -497,6 +498,8 @@ private slots: void on_moreControlsBtn_clicked(); + void on_useCIVasRigIDChk_clicked(bool checked); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -714,6 +717,7 @@ private: bool wfInterpolate; QString stylesheetPath; unsigned char radioCIVAddr; + bool CIVisRadioModel; QString serialPortRadio; quint32 serialPortBaud; bool enablePTT; diff --git a/wfmain.ui b/wfmain.ui index e129aac..a620f5a 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -6,7 +6,7 @@ 0 0 - 941 + 946 582 @@ -18,7 +18,7 @@ - 0 + 3 @@ -2373,6 +2373,16 @@ + + + + <html><head/><body><p>Only check for older radios!</p><p>This checkbox forces wfview to trust that the CI-V address is also the model number of the radio. This is only useful for older radios that do not reply to our Rig ID requests (0x19 0x00). Do not check this box unless you have an older radio. </p></body></html> + + + Use as Model too + + + @@ -2830,7 +2840,7 @@ 0 0 - 941 + 946 22 From 0315033f8951a60e7217832f8b0c20949eb22e1a Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 7 Nov 2021 00:24:08 -0700 Subject: [PATCH 57/79] Fixed manual rig ID issue with uninitialized variable. --- rigcommander.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rigcommander.cpp b/rigcommander.cpp index 694b276..1c3ecd6 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -3964,6 +3964,10 @@ void rigCommander::setRigID(unsigned char rigID) lookingForRig = true; foundRig = false; + // needed because this is a fake message and thus the value is uninitialized + // this->civAddr comes from how rigCommander is setup and should be accurate. + this->incomingCIVAddr = this->civAddr; + this->model = determineRadioModel(rigID); rigCaps.modelID = rigID; rigCaps.model = determineRadioModel(rigID); From 1d037646845c70a3215c47db7b5c2789ac4103fe Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 7 Nov 2021 01:28:35 -0700 Subject: [PATCH 58/79] Pulled out some debug code that isn't needed. --- commhandler.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/commhandler.cpp b/commhandler.cpp index 2160f15..e678317 100644 --- a/commhandler.cpp +++ b/commhandler.cpp @@ -94,9 +94,7 @@ void commHandler::sendDataOut(const QByteArray &writeData) if(writeData.endsWith(QByteArrayLiteral("\x1C\x00\xFD"))) { // Query - qDebug(logSerial()) << "Looks like PTT Query"; - - + //qDebug(logSerial()) << "Looks like PTT Query"; bool pttOn = this->rtsStatus(); QByteArray pttreturncmd = QByteArray("\xFE\xFE"); pttreturncmd.append(writeData.at(3)); @@ -104,7 +102,7 @@ void commHandler::sendDataOut(const QByteArray &writeData) pttreturncmd.append(QByteArray("\x1C\x00", 2)); pttreturncmd.append((char)pttOn); pttreturncmd.append("\xFD"); - qDebug(logSerial()) << "Sending fake PTT query result: " << (bool)pttOn; + //qDebug(logSerial()) << "Sending fake PTT query result: " << (bool)pttOn; printHex(pttreturncmd, false, true); emit haveDataFromPort(pttreturncmd); @@ -114,24 +112,17 @@ void commHandler::sendDataOut(const QByteArray &writeData) } else if(writeData.endsWith(QByteArrayLiteral("\x1C\x00\x01\xFD"))) { // PTT ON - qDebug(logSerial()) << "Looks like PTT ON"; + //qDebug(logSerial()) << "Looks like PTT ON"; setRTS(true); mutex.unlock(); return; } else if(writeData.endsWith(QByteArrayLiteral("\x1C\x00\x00\xFD"))) { // PTT OFF - qDebug(logSerial()) << "Looks like PTT OFF"; + //qDebug(logSerial()) << "Looks like PTT OFF"; setRTS(false); mutex.unlock(); return; - } else if (writeData.length() > 6) - { - if(writeData.at(4) == 0x1c ) - { - qDebug(logSerial()) << "Potential 0x1C PTT command did not match. Has length " << writeData.length() << " and contains:"; - printHex(writeData, false, true); - } } } From 93869b1bea4e73b15d9c6b78e481049034ab4e1a Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 09:58:41 +0000 Subject: [PATCH 59/79] Fix Linux rtaudio build --- wfview.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfview.pro b/wfview.pro index c05ba29..707d484 100644 --- a/wfview.pro +++ b/wfview.pro @@ -59,7 +59,7 @@ contains(DEFINES, RTAUDIO) { win32:SOURCES += ../rtaudio/RTAudio.cpp win32:HEADERS += ../rtaudio/RTAUdio.h !linux:INCLUDEPATH += ../rtaudio - linux:LIBS += -lpulse -lpulse-simple -lpthread + linux:LIBS += -lpulse -lpulse-simple -lrtaudio -lpthread } contains(DEFINES, PORTAUDIO) { From 1c0f33c721b669c903164246dc8129a82a2dc13c Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 12:16:25 +0000 Subject: [PATCH 60/79] Close PA stream after stopping it! --- audiohandler.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index c17a6f4..6b0d54c 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -34,6 +34,7 @@ audioHandler::~audioHandler() delete audio; #elif defined(PORTAUDIO) Pa_StopStream(audio); + Pa_CloseStream(audio); #else stop(); #endif @@ -230,21 +231,20 @@ bool audioHandler::init(audioSetup setupIn) else { devChannels = info->maxOutputChannels; } - qInfo(logAudio()) << " Channels:" << devChannels; if (devChannels > 2) { devChannels = 2; } aParams.channelCount = devChannels; + qInfo(logAudio()) << " Channels:" << devChannels; qInfo(logAudio()) << " chunkSize: " << chunkSize; + qInfo(logAudio()) << " sampleRate: " << nativeSampleRate; if (setup.isinput) { err=Pa_OpenStream(&audio, &aParams, 0, this->nativeSampleRate, this->chunkSize, paNoFlag, &audioHandler::staticWrite, (void*)this); - //err = Pa_OpenDefaultStream(&audio, 2, 0, paFloat32, this->nativeSampleRate, this->chunkSize, &audioHandler::staticWrite, (void*)this); } else { err=Pa_OpenStream(&audio, 0, &aParams, this->nativeSampleRate, this->chunkSize, paNoFlag, &audioHandler::staticRead, (void*)this); - //err = Pa_OpenDefaultStream(&audio, 0, 2, paFloat32, this->nativeSampleRate, this->chunkSize, &audioHandler::staticRead, (void*)this); } if (err == paNoError) { @@ -257,9 +257,6 @@ bool audioHandler::init(audioSetup setupIn) else { qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "failed to open device" << Pa_GetErrorText(err); } - //qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "detected latency:" << audio->getStreamLatency(); - - #else From 6fbd9cec707938e1c773d6fe5a950dc6045b92f9 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 13:27:52 +0000 Subject: [PATCH 61/79] Create resampleRatio --- audiohandler.cpp | 15 +++++++++------ audiohandler.h | 3 +-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 6b0d54c..1b21d4f 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -337,9 +337,12 @@ bool audioHandler::init(audioSetup setupIn) qInfo(logAudio()) << "Creating opus decoder: " << opus_strerror(opus_err); } } - wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen); - qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " ratioNum" << ratioNum << " ratioDen" << ratioDen; + unsigned int ratioNum; + unsigned int ratioDen; + wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen); + resampleRatio = ratioDen / ratioNum; + qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " resampleRatio" << resampleRatio; qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "thread id" << QThread::currentThreadId(); @@ -658,11 +661,11 @@ void audioHandler::incomingAudio(audioPacket inPacket) */ //qDebug(logAudio()) << "Now 16 bit stereo, length" << inPacket.data.length(); - if (ratioDen != 1) { + if (resampleRatio != 1.0) { // We need to resample // We have a stereo 16bit stream. - quint32 outFrames = ((inPacket.data.length() / 2 / devChannels) * ratioDen); + quint32 outFrames = ((inPacket.data.length() / 2 / devChannels) * resampleRatio); quint32 inFrames = (inPacket.data.length() / 2 / devChannels); QByteArray outPacket(outFrames * 4, (char)0xff); // Preset the output buffer size. @@ -723,9 +726,9 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) //qDebug(logAudio) << "Chunksize" << this->chunkSize << "Packet size" << packet.data.length(); // Packet will arrive as stereo interleaved 16bit 48K - if (ratioNum != 1) + if (resampleRatio != 1.0) { - quint32 outFrames = ((packet.data.length() / 2 / devChannels) / ratioNum); + quint32 outFrames = ((packet.data.length() / 2 / devChannels) / resampleRatio); quint32 inFrames = (packet.data.length() / 2 / devChannels); QByteArray outPacket((int)outFrames * 2 * devChannels, (char)0xff); diff --git a/audiohandler.h b/audiohandler.h index 875d261..c368181 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -196,8 +196,7 @@ private: QMapaudioBuffer; - unsigned int ratioNum; - unsigned int ratioDen; + double resampleRatio; wilt::Ring *ringBuf=Q_NULLPTR; From 6247611d85001fa69e2d301ffb4b4812d8eb60e6 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 13:49:00 +0000 Subject: [PATCH 62/79] Fix resample ratio for input and output (hopefully!) --- audiohandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 1b21d4f..76575eb 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -341,8 +341,8 @@ bool audioHandler::init(audioSetup setupIn) unsigned int ratioDen; wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen); - resampleRatio = ratioDen / ratioNum; - qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " resampleRatio" << resampleRatio; + resampleRatio = static_cast(ratioDen) / ratioNum; + qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " resampleRatio: " << resampleRatio; qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "thread id" << QThread::currentThreadId(); @@ -728,7 +728,7 @@ void audioHandler::getNextAudioChunk(QByteArray& ret) // Packet will arrive as stereo interleaved 16bit 48K if (resampleRatio != 1.0) { - quint32 outFrames = ((packet.data.length() / 2 / devChannels) / resampleRatio); + quint32 outFrames = ((packet.data.length() / 2 / devChannels) * resampleRatio); quint32 inFrames = (packet.data.length() / 2 / devChannels); QByteArray outPacket((int)outFrames * 2 * devChannels, (char)0xff); From ca552a0d8005442454b3e2a546b04785761b8a2e Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 14:11:22 +0000 Subject: [PATCH 63/79] Enable SSE or NEON enhancements for resampler --- audiohandler.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/audiohandler.h b/audiohandler.h index c368181..5c6efd6 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -35,6 +35,16 @@ typedef signed short MY_TYPE; #include #include #include +#if defined(__x86_64__) || defined(__i386__) || defined(_M_IX86_FP) +#if !defined(USE_SSE) +#define USE_SSE +#endif +#else +#if !defined(USE_NEON) +#define USE_NEON +#endif +#endif + #include "resampler/speex_resampler.h" #include "ring/ring.h" From f04284db0ef4b83287737577122b9f478e35c371 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 14:18:20 +0000 Subject: [PATCH 64/79] Update audiohandler.h --- audiohandler.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/audiohandler.h b/audiohandler.h index 5c6efd6..3036330 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -36,13 +36,13 @@ typedef signed short MY_TYPE; #include #include #if defined(__x86_64__) || defined(__i386__) || defined(_M_IX86_FP) -#if !defined(USE_SSE) -#define USE_SSE -#endif +#undef USE_NEON +#define USE_SSE 1 +#define USE_SSE2 1 #else -#if !defined(USE_NEON) -#define USE_NEON -#endif +#undef USE_SSE +#undef SUE_SSE2 +#define USE_NEON 1 #endif #include "resampler/speex_resampler.h" From 827614e080687169f220dc8d70c41158786b2aac Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 7 Nov 2021 14:24:25 +0000 Subject: [PATCH 65/79] Add SSE2 enhancements to resampler --- audiohandler.h | 9 --------- wfview.pro | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/audiohandler.h b/audiohandler.h index 3036330..e67e2ef 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -35,15 +35,6 @@ typedef signed short MY_TYPE; #include #include #include -#if defined(__x86_64__) || defined(__i386__) || defined(_M_IX86_FP) -#undef USE_NEON -#define USE_SSE 1 -#define USE_SSE2 1 -#else -#undef USE_SSE -#undef SUE_SSE2 -#define USE_NEON 1 -#endif #include "resampler/speex_resampler.h" #include "ring/ring.h" diff --git a/wfview.pro b/wfview.pro index 707d484..3cbab06 100644 --- a/wfview.pro +++ b/wfview.pro @@ -34,6 +34,7 @@ DEFINES += QCUSTOMPLOT_COMPILE_LIBRARY # These defines are used for the resampler equals(QT_ARCH, i386): DEFINES += USE_SSE +equals(QT_ARCH, i386): DEFINES += USE_SSE2 equals(QT_ARCH, arm): DEFINES += USE_NEON DEFINES += OUTSIDE_SPEEX DEFINES += RANDOM_PREFIX=wf From bb53558c92bc4235870f9dcfb3ee03cf8736fa9f Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 9 Nov 2021 15:55:43 +0000 Subject: [PATCH 66/79] Small changes to audio handler --- audiohandler.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 76575eb..77bde33 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -214,7 +214,13 @@ bool audioHandler::init(audioSetup setupIn) aParams.channelCount = 2; aParams.hostApiSpecificStreamInfo = NULL; aParams.sampleFormat = paInt16; - aParams.suggestedLatency = info->defaultLowInputLatency; + if (setup.isinput) { + aParams.suggestedLatency = info->defaultLowInputLatency; + } + else { + aParams.suggestedLatency = info->defaultLowOutputLatency; + } + aParams.hostApiSpecificStreamInfo = NULL; // Always use the "preferred" sample rate @@ -459,14 +465,16 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes) //qDebug(logAudio()) << "Adding partial:" << send; } - while (currentLatency > setup.latency) { + if (currentLatency > setup.latency) { qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Packet " << hex << packet.seq << " arrived too late (increase output latency!) " << dec << packet.time.msecsTo(QTime::currentTime()) << "ms"; - lastSeq = packet.seq; - if (!ringBuf->try_read(packet)) - break; - currentLatency = packet.time.msecsTo(QTime::currentTime()); + while (currentLatency > setup.latency/2) { + if (!ringBuf->try_read(packet)) { + break; + } + currentLatency = packet.time.msecsTo(QTime::currentTime()); + } } int send = qMin((int)nBytes - sentlen, packet.data.length()); From 81c83357f2e421adf474c778906975b12ca147ce Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 10 Nov 2021 17:44:33 +0000 Subject: [PATCH 67/79] Catch exception in opus_decode --- audiohandler.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 77bde33..82bbd79 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -575,7 +575,6 @@ qint64 audioHandler::writeData(const char* data, qint64 nBytes) #endif } - void audioHandler::incomingAudio(audioPacket inPacket) { // No point buffering audio until stream is actually running. @@ -594,8 +593,17 @@ void audioHandler::incomingAudio(audioPacket inPacket) /* Decode the frame. */ QByteArray outPacket((setup.samplerate / 50) * sizeof(qint16) * setup.radioChan, (char)0xff); // Preset the output buffer size. qint16* out = (qint16*)outPacket.data(); + + std::exception_ptr eptr; + int nSamples = 0; - int nSamples = opus_decode(decoder, in, inPacket.data.size(), out, (setup.samplerate / 50), 0); + try { + nSamples = opus_decode(decoder, in, inPacket.data.size(), out, (setup.samplerate / 50), 0); + } + catch (...) { + qInfo(logAudio()) << "Exception occurred in opus_decode: nSamples=" << nSamples << + "in=" < Date: Wed, 10 Nov 2021 18:07:48 +0000 Subject: [PATCH 68/79] Check number of samples in opus packet before attempting decode --- audiohandler.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 82bbd79..dc35900 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -593,17 +593,13 @@ void audioHandler::incomingAudio(audioPacket inPacket) /* Decode the frame. */ QByteArray outPacket((setup.samplerate / 50) * sizeof(qint16) * setup.radioChan, (char)0xff); // Preset the output buffer size. qint16* out = (qint16*)outPacket.data(); - - std::exception_ptr eptr; - int nSamples = 0; - - try { - nSamples = opus_decode(decoder, in, inPacket.data.size(), out, (setup.samplerate / 50), 0); - } - catch (...) { - qInfo(logAudio()) << "Exception occurred in opus_decode: nSamples=" << nSamples << - "in=" < Date: Wed, 10 Nov 2021 20:45:59 +0000 Subject: [PATCH 69/79] Server only tries mutex lock for 10ms before giving up. --- udpserver.cpp | 614 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 420 insertions(+), 194 deletions(-) diff --git a/udpserver.cpp b/udpserver.cpp index 3219815..c209211 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -2,6 +2,7 @@ #include "logcategories.h" #define STALE_CONNECTION 15 +#define LOCK_PERIOD 10 // time to attempt to lock Mutex in ms udpServer::udpServer(SERVERCONFIG config, audioSetup outAudio, audioSetup inAudio) : config(config), outAudio(outAudio), @@ -157,10 +158,15 @@ void udpServer::controlReceived() current->commonCap = 0x8010; qInfo(logUdpServer()) << current->ipAddress.toString() << ": New Control connection created"; - connMutex.lock(); - controlClients.append(current); - connMutex.unlock(); + if (connMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + controlClients.append(current); + connMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock connMutex()"; + } } current->lastHeard = QDateTime::currentDateTime(); @@ -443,9 +449,15 @@ void udpServer::civReceived() current->retransmitTimer->start(RETRANSMIT_PERIOD); qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): New connection created"; - connMutex.lock(); - civClients.append(current); - connMutex.unlock(); + if (connMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + civClients.append(current); + connMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock connMutex()"; + } + } @@ -589,9 +601,14 @@ void udpServer::audioReceived() current->retransmitTimer->start(RETRANSMIT_PERIOD); current->seqPrefix = 0; qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): New connection created"; - connMutex.lock(); - audioClients.append(current); - connMutex.unlock(); + if (connMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + audioClients.append(current); + connMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock connMutex()"; + } } @@ -713,9 +730,15 @@ void udpServer::commonReceived(QList* l, CLIENT* current, QByteArray r) // Don't constantly retransmit the same packet, give-up eventually qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Sending retransmit of " << hex << match->seqNum; match->retransmitCount++; - udpMutex.lock(); - current->socket->writeDatagram(match->data, current->ipAddress, current->port); - udpMutex.unlock(); + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + current->socket->writeDatagram(match->data, current->ipAddress, current->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } + } else { // Just send an idle! @@ -751,9 +774,15 @@ void udpServer::commonReceived(QList* l, CLIENT* current, QByteArray r) // Send "untracked" as it has already been sent once. qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Sending retransmit of " << hex << match->seqNum; match->retransmitCount++; - udpMutex.lock(); - current->socket->writeDatagram(match->data, current->ipAddress, current->port); - udpMutex.unlock(); + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + current->socket->writeDatagram(match->data, current->ipAddress, current->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } + match++; } } @@ -765,9 +794,15 @@ void udpServer::commonReceived(QList* l, CLIENT* current, QByteArray r) //} if (current->rxSeqBuf.isEmpty()) { - current->rxMutex.lock(); - current->rxSeqBuf.insert(in->seq, QTime::currentTime()); - current->rxMutex.unlock(); + if (current->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + current->rxSeqBuf.insert(in->seq, QTime::currentTime()); + current->rxMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock rxMutex()"; + } + } else { @@ -776,35 +811,58 @@ void udpServer::commonReceived(QList* l, CLIENT* current, QByteArray r) { qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): ******* seq number may have rolled over ****** previous highest: " << hex << current->rxSeqBuf.lastKey() << " current: " << hex << in->seq; // Looks like it has rolled over so clear buffer and start again. - current->rxMutex.lock(); - current->rxSeqBuf.clear(); - current->rxMutex.unlock(); - current->missMutex.lock(); - current->rxMissing.clear(); - current->missMutex.unlock(); + if (current->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + current->rxSeqBuf.clear(); + current->rxMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock rxMutex()"; + } + + if (current->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + current->rxMissing.clear(); + current->missMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; + } + return; } if (!current->rxSeqBuf.contains(in->seq)) { // Add incoming packet to the received buffer and if it is in the missing buffer, remove it. - current->rxMutex.lock(); - if (current->rxSeqBuf.size() > 400) + if (current->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - current->rxSeqBuf.remove(0); + if (current->rxSeqBuf.size() > 400) + { + current->rxSeqBuf.remove(0); + } + current->rxSeqBuf.insert(in->seq, QTime::currentTime()); + current->rxMutex.unlock(); } - current->rxSeqBuf.insert(in->seq, QTime::currentTime()); - current->rxMutex.unlock(); + else { + qInfo(logUdpServer()) << "Unable to lock rxMutex()"; + } + } else{ // Check whether this is one of our missing ones! - current->missMutex.lock(); - QMap::iterator s = current->rxMissing.find(in->seq); - if (s != current->rxMissing.end()) + if (current->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Missing SEQ has been received! " << hex << in->seq; - s = current->rxMissing.erase(s); + QMap::iterator s = current->rxMissing.find(in->seq); + if (s != current->rxMissing.end()) + { + qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Missing SEQ has been received! " << hex << in->seq; + s = current->rxMissing.erase(s); + } + current->missMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; } - current->missMutex.unlock(); } } } @@ -832,20 +890,37 @@ void udpServer::sendControl(CLIENT* c, quint8 type, quint16 seq) s.timeSent = QTime::currentTime(); s.retransmitCount = 0; s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - c->txMutex.lock(); - c->txSeqBuf.insert(seq, s); - c->txSeq++; - c->txMutex.unlock(); + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->txSeqBuf.insert(seq, s); + c->txSeq++; + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); } else { p.seq = seq; - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } + } return; @@ -893,9 +968,14 @@ void udpServer::sendPing(QList* l, CLIENT* c, quint16 seq, bool reply) p.time = pingTime; p.reply = (char)reply; - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } return; } @@ -935,14 +1015,24 @@ void udpServer::sendLoginResponse(CLIENT* c, bool allowed) s.timeSent = QTime::currentTime(); s.retransmitCount = 0; s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - c->txMutex.lock(); - c->txSeqBuf.insert(c->txSeq, s); - c->txSeq++; - c->txMutex.unlock(); + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->txSeqBuf.insert(c->txSeq, s); + c->txSeq++; + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } if (c->idleTimer != Q_NULLPTR) c->idleTimer->start(100); @@ -1040,18 +1130,29 @@ void udpServer::sendCapabilities(CLIENT* c) s.timeSent = QTime::currentTime(); s.retransmitCount = 0; s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - c->txMutex.lock(); - if (c->txSeqBuf.size() > 400) + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - c->txSeqBuf.remove(0); + if (c->txSeqBuf.size() > 400) + { + c->txSeqBuf.remove(0); + } + c->txSeqBuf.insert(p.seq, s); + c->txSeq++; + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; } - c->txSeqBuf.insert(p.seq, s); - c->txSeq++; - c->txMutex.unlock(); - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); if (c->idleTimer != Q_NULLPTR) c->idleTimer->start(100); @@ -1100,18 +1201,30 @@ void udpServer::sendConnectionInfo(CLIENT* c) s.retransmitCount = 0; s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - c->txMutex.lock(); - if (c->txSeqBuf.size() > 400) + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - c->txSeqBuf.remove(0); + if (c->txSeqBuf.size() > 400) + { + c->txSeqBuf.remove(0); + } + c->txSeqBuf.insert(p.seq, s); + c->txSeq++; + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } + + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; } - c->txSeqBuf.insert(p.seq, s); - c->txSeq++; - c->txMutex.unlock(); - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); if (c->idleTimer != Q_NULLPTR) c->idleTimer->start(100); @@ -1146,18 +1259,29 @@ void udpServer::sendTokenResponse(CLIENT* c, quint8 type) s.retransmitCount = 0; s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - c->txMutex.lock(); - if (c->txSeqBuf.size() > 400) + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - c->txSeqBuf.remove(0); + if (c->txSeqBuf.size() > 400) + { + c->txSeqBuf.remove(0); + } + c->txSeqBuf.insert(p.seq, s); + c->txSeq++; + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; } - c->txSeqBuf.insert(p.seq, s); - c->txSeq++; - c->txMutex.unlock(); - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } if (c->idleTimer != Q_NULLPTR) @@ -1253,18 +1377,29 @@ void udpServer::sendStatus(CLIENT* c) s.timeSent = QTime::currentTime(); s.retransmitCount = 0; s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - c->txMutex.lock(); - if (c->txSeqBuf.size() > 400) + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - c->txSeqBuf.remove(0); + if (c->txSeqBuf.size() > 400) + { + c->txSeqBuf.remove(0); + } + c->txSeq++; + c->txSeqBuf.insert(p.seq, s); + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; } - c->txSeq++; - c->txSeqBuf.insert(p.seq, s); - c->txMutex.unlock(); - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } } @@ -1297,19 +1432,31 @@ void udpServer::dataForServer(QByteArray d) s.retransmitCount = 0; s.data = t; - client->txMutex.lock(); - if (client->txSeqBuf.size() > 400) + if (client->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - client->txSeqBuf.remove(0); + if (client->txSeqBuf.size() > 400) + { + client->txSeqBuf.remove(0); + } + client->txSeqBuf.insert(p.seq, s); + client->txSeq++; + client->innerSeq++; + client->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } + + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + client->socket->writeDatagram(t, client->ipAddress, client->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; } - client->txSeqBuf.insert(p.seq, s); - client->txSeq++; - client->innerSeq++; - client->txMutex.unlock(); - udpMutex.lock(); - client->socket->writeDatagram(t, client->ipAddress, client->port); - udpMutex.unlock(); } else { qInfo(logUdpServer()) << "Got data for different ID" << hex << (quint8)d[lastFE+1] << ":" << hex << (quint8)d[lastFE+2]; } @@ -1359,19 +1506,31 @@ void udpServer::receiveAudioData(const audioPacket& d) s.timeSent = QTime::currentTime(); s.retransmitCount = 0; s.data = t; - client->txMutex.lock(); - if (client->txSeqBuf.size() > 400) + if (client->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - client->txSeqBuf.remove(0); + if (client->txSeqBuf.size() > 400) + { + client->txSeqBuf.remove(0); + } + client->txSeqBuf.insert(p.seq, s); + client->txSeq++; + client->sendAudioSeq++; + client->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } + + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + client->socket->writeDatagram(t, client->ipAddress, client->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; } - client->txSeqBuf.insert(p.seq, s); - client->txSeq++; - client->sendAudioSeq++; - client->txMutex.unlock(); - udpMutex.lock(); - client->socket->writeDatagram(t, client->ipAddress, client->port); - udpMutex.unlock(); } } @@ -1397,13 +1556,24 @@ void udpServer::sendRetransmitRequest(CLIENT* c) { // Too many packets to process, flush buffers and start again! qDebug(logUdp()) << "Too many missing packets, flushing buffer: " << c->rxSeqBuf.lastKey() << "missing=" << c->rxSeqBuf.lastKey() - c->rxSeqBuf.firstKey() - c->rxSeqBuf.size() + 1; - c->missMutex.lock(); - c->rxMissing.clear(); - c->missMutex.unlock(); + if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->rxMissing.clear(); + c->missMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; + } + + if (c->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->rxSeqBuf.clear(); + c->rxMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock rxMutex()"; + } - c->rxMutex.lock(); - c->rxSeqBuf.clear(); - c->rxMutex.unlock(); } else { // We have at least 1 missing packet! @@ -1417,25 +1587,43 @@ void udpServer::sendRetransmitRequest(CLIENT* c) // We haven't seen this missing packet before qDebug(logUdp()) << this->metaObject()->className() << ": Adding to missing buffer (len=" << c->rxMissing.size() << "): " << j; - c->missMutex.lock(); - c->rxMissing.insert(j, 0); - c->missMutex.unlock(); - - c->rxMutex.lock(); - if (c->rxSeqBuf.size() > 400) + if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - c->rxSeqBuf.remove(0); + c->rxMissing.insert(j, 0); + c->missMutex.unlock(); } - c->rxSeqBuf.insert(j, QTime::currentTime()); // Add this missing packet to the rxbuffer as we now long about it. - c->rxMutex.unlock(); + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; + } + + + if (c->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + if (c->rxSeqBuf.size() > 400) + { + c->rxSeqBuf.remove(0); + } + c->rxSeqBuf.insert(j, QTime::currentTime()); // Add this missing packet to the rxbuffer as we now long about it. + c->rxMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock rxMutex()"; + } + } else { if (s.value() == 4) { // We have tried 4 times to request this packet, time to give up! - c->missMutex.lock(); - s = c->rxMissing.erase(s); - c->missMutex.unlock(); + if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + s = c->rxMissing.erase(s); + c->missMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; + } + } } @@ -1444,48 +1632,64 @@ void udpServer::sendRetransmitRequest(CLIENT* c) } } - c->missMutex.lock(); - for (auto it = c->rxMissing.begin(); it != c->rxMissing.end(); ++it) + if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { - if (it.value() < 10) + for (auto it = c->rxMissing.begin(); it != c->rxMissing.end(); ++it) { - missingSeqs.append(it.key() & 0xff); - missingSeqs.append(it.key() >> 8 & 0xff); - missingSeqs.append(it.key() & 0xff); - missingSeqs.append(it.key() >> 8 & 0xff); - it.value()++; + if (it.value() < 10) + { + missingSeqs.append(it.key() & 0xff); + missingSeqs.append(it.key() >> 8 & 0xff); + missingSeqs.append(it.key() & 0xff); + missingSeqs.append(it.key() >> 8 & 0xff); + it.value()++; + } } + + if (missingSeqs.length() != 0) + { + control_packet p; + memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! + p.type = 0x01; + p.seq = 0x0000; + p.sentid = c->myId; + p.rcvdid = c->remoteId; + if (missingSeqs.length() == 4) // This is just a single missing packet so send using a control. + { + p.seq = (missingSeqs[0] & 0xff) | (quint16)(missingSeqs[1] << 8); + qDebug(logUdp()) << this->metaObject()->className() << ": sending request for missing packet : " << hex << p.seq; + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } + + } + else + { + qDebug(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(); + + if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + missingSeqs.insert(0, p.packet, sizeof(p.packet)); + c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port); + udpMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock udpMutex()"; + } + + } + } + c->missMutex.unlock(); } - - if (missingSeqs.length() != 0) - { - control_packet p; - memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! - p.type = 0x01; - p.seq = 0x0000; - p.sentid = c->myId; - p.rcvdid = c->remoteId; - if (missingSeqs.length() == 4) // This is just a single missing packet so send using a control. - { - p.seq = (missingSeqs[0] & 0xff) | (quint16)(missingSeqs[1] << 8); - qDebug(logUdp()) << this->metaObject()->className() << ": sending request for missing packet : " << hex << p.seq; - - udpMutex.lock(); - c->socket->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), c->ipAddress, c->port); - udpMutex.unlock(); - } - else - { - qDebug(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(); - - udpMutex.lock(); - missingSeqs.insert(0, p.packet, sizeof(p.packet)); - c->socket->writeDatagram(missingSeqs, c->ipAddress, c->port); - udpMutex.unlock(); - } + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; } - c->missMutex.unlock(); - } @@ -1514,35 +1718,57 @@ void udpServer::deleteConnection(QList* l, CLIENT* c) delete c->retransmitTimer; } - c->rxMutex.lock(); - c->rxSeqBuf.clear(); - c->rxMutex.unlock(); - - c->txMutex.lock(); - c->txSeqBuf.clear(); - c->txMutex.unlock(); - - c->missMutex.lock(); - c->rxMissing.clear(); - c->missMutex.unlock(); - - - connMutex.lock(); - QList::iterator it = l->begin(); - while (it != l->end()) { - CLIENT* client = *it; - if (client != Q_NULLPTR && client == c) { - qInfo(logUdpServer()) << "Found" << client->type << "connection to: " << client->ipAddress.toString() << ":" << QString::number(client->port); - it = l->erase(it); - } - else { - ++it; - } + if (c->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->rxSeqBuf.clear(); + c->rxMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock rxMutex()"; + } + + + if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->txSeqBuf.clear(); + c->txMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock txMutex()"; + } + + + if (c->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + c->rxMissing.clear(); + c->missMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock missMutex()"; + } + + + if (connMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + QList::iterator it = l->begin(); + while (it != l->end()) { + CLIENT* client = *it; + if (client != Q_NULLPTR && client == c) { + qInfo(logUdpServer()) << "Found" << client->type << "connection to: " << client->ipAddress.toString() << ":" << QString::number(client->port); + it = l->erase(it); + } + else { + ++it; + } + } + delete c; // Is this needed or will the erase have done it? + c = Q_NULLPTR; + qInfo(logUdpServer()) << "Current Number of clients connected: " << l->length(); + connMutex.unlock(); + } + else { + qInfo(logUdpServer()) << "Unable to lock connMutex()"; } - delete c; // Is this needed or will the erase have done it? - c = Q_NULLPTR; - qInfo(logUdpServer()) << "Current Number of clients connected: " << l->length(); - connMutex.unlock(); if (l->length() == 0) { From 04526db635c023a0c47f4155709a064fd5595b35 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 15 Nov 2021 15:02:00 +0000 Subject: [PATCH 70/79] Try using slot for audio again --- udphandler.cpp | 8 ++++---- udpserver.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index 161ce92..c0c93e9 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -346,7 +346,7 @@ void udpHandler::dataReceived() audio = new udpAudio(localIP, radioIP, audioPort, rxSetup, txSetup); QObject::connect(civ, SIGNAL(receive(QByteArray)), this, SLOT(receiveFromCivStream(QByteArray))); - //QObject::connect(audio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket))); + QObject::connect(audio, SIGNAL(haveAudioData(audioPacket)), this, SLOT(receiveAudioData(audioPacket))); QObject::connect(this, SIGNAL(haveChangeLatency(quint16)), audio, SLOT(changeLatency(quint16))); QObject::connect(this, SIGNAL(haveSetVolume(unsigned char)), audio, SLOT(setVolume(unsigned char))); @@ -740,7 +740,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio connect(this, SIGNAL(setupRxAudio(audioSetup)), rxaudio, SLOT(init(audioSetup))); // signal/slot not currently used. - //connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket))); + connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket))); connect(this, SIGNAL(haveChangeLatency(quint16)), rxaudio, SLOT(changeLatency(quint16))); connect(this, SIGNAL(haveSetVolume(unsigned char)), rxaudio, SLOT(setVolume(unsigned char))); connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater())); @@ -945,8 +945,8 @@ void udpAudio::dataReceived() tempAudio.data = r.mid(0x18); // Prefer signal/slot to forward audio as it is thread/safe // Need to do more testing but latency appears fine. - rxaudio->incomingAudio(tempAudio); - //emit haveAudioData(tempAudio); + //rxaudio->incomingAudio(tempAudio); + emit haveAudioData(tempAudio); audioLatency = rxaudio->getLatency(); } break; diff --git a/udpserver.cpp b/udpserver.cpp index c209211..30208eb 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -670,8 +670,8 @@ void udpServer::audioReceived() tempAudio.sent = 0; tempAudio.data = r.mid(0x18); //qInfo(logUdpServer()) << "sending tx audio " << in->seq; - //emit haveAudioData(tempAudio); - txaudio->incomingAudio(tempAudio); + emit haveAudioData(tempAudio); + //txaudio->incomingAudio(tempAudio); } } From b5591e08674bd3883f002e2da219834f2d933b20 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 15 Nov 2021 15:26:18 +0000 Subject: [PATCH 71/79] Force PA to use 48K Sample Rate if default is 44.1K --- audiohandler.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index dc35900..4dd623a 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -223,10 +223,14 @@ bool audioHandler::init(audioSetup setupIn) aParams.hostApiSpecificStreamInfo = NULL; - // Always use the "preferred" sample rate + // Always use the "preferred" sample rate (unless it is 44100) // We can always resample if needed - this->nativeSampleRate = info->defaultSampleRate; - + if (info->defaultSampleRate == 44100) { + this->nativeSampleRate = 48000; + } + else { + this->nativeSampleRate = info->defaultSampleRate; + } // Per channel chunk size. this->chunkSize = (this->nativeSampleRate / 50); From 42675ae770ad79920f7914265c33cdf279b12ff6 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 15 Nov 2021 19:28:44 +0000 Subject: [PATCH 72/79] Add mutex for incoming audio on udp and server --- udphandler.cpp | 58 ++++++++++++++++++++++++++++---------------------- udphandler.h | 3 +++ udpserver.cpp | 26 ++++++++++++++-------- udpserver.h | 1 + 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/udphandler.cpp b/udphandler.cpp index c0c93e9..6ae6333 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -856,36 +856,44 @@ void udpAudio::sendTxAudio() return; } QByteArray audio; - txaudio->getNextAudioChunk(audio); + if (audioMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + txaudio->getNextAudioChunk(audio); + // Now we have the next audio chunk, we can release the mutex. + audioMutex.unlock(); - if (audio.length() > 0) { - int counter = 1; - int len = 0; + if (audio.length() > 0) { + int counter = 1; + int len = 0; - while (len < audio.length()) { - QByteArray partial = audio.mid(len, 1364); - audio_packet p; - memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! - p.len = sizeof(p) + partial.length(); - p.sentid = myId; - p.rcvdid = remoteId; - if (partial.length() == 0xa0) { - p.ident = 0x9781; + while (len < audio.length()) { + QByteArray partial = audio.mid(len, 1364); + audio_packet p; + memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00! + p.len = sizeof(p) + partial.length(); + p.sentid = myId; + p.rcvdid = remoteId; + if (partial.length() == 0xa0) { + p.ident = 0x9781; + } + else { + p.ident = 0x0080; // TX audio is always this? + } + p.datalen = (quint16)qToBigEndian((quint16)partial.length()); + p.sendseq = (quint16)qToBigEndian((quint16)sendAudioSeq); // THIS IS BIG ENDIAN! + QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); + tx.append(partial); + len = len + partial.length(); + //qInfo(logUdp()) << "Sending audio packet length: " << tx.length(); + sendTrackedPacket(tx); + sendAudioSeq++; + counter++; } - else { - p.ident = 0x0080; // TX audio is always this? - } - p.datalen = (quint16)qToBigEndian((quint16)partial.length()); - p.sendseq = (quint16)qToBigEndian((quint16)sendAudioSeq); // THIS IS BIG ENDIAN! - QByteArray tx = QByteArray::fromRawData((const char*)p.packet, sizeof(p)); - tx.append(partial); - len = len + partial.length(); - //qInfo(logUdp()) << "Sending audio packet length: " << tx.length(); - sendTrackedPacket(tx); - sendAudioSeq++; - counter++; } } + else { + qInfo(logUdpServer()) << "Unable to lock mutex for rxaudio"; + } } void udpAudio::changeLatency(quint16 value) diff --git a/udphandler.h b/udphandler.h index c16bc4a..1a8e975 100644 --- a/udphandler.h +++ b/udphandler.h @@ -32,6 +32,7 @@ #define AREYOUTHERE_PERIOD 500 #define WATCHDOG_PERIOD 500 #define RETRANSMIT_PERIOD 100 +#define LOCK_PERIOD 100 struct udpPreferences { QString ipAddress; @@ -197,6 +198,8 @@ private: QTimer* txAudioTimer=Q_NULLPTR; bool enableTx = true; + QMutex audioMutex; + }; diff --git a/udpserver.cpp b/udpserver.cpp index 30208eb..9f6527c 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -159,7 +159,7 @@ void udpServer::controlReceived() current->commonCap = 0x8010; qInfo(logUdpServer()) << current->ipAddress.toString() << ": New Control connection created"; - if (connMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + if (connMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) { controlClients.append(current); connMutex.unlock(); @@ -1469,14 +1469,22 @@ void udpServer::sendRxAudio() { QByteArray audio; if (rxaudio) { - audio.clear(); - rxaudio->getNextAudioChunk(audio); - int len = 0; - while (len < audio.length()) { - audioPacket partial; - partial.data = audio.mid(len, 1364); - receiveAudioData(partial); - len = len + partial.data.length(); + if (audioMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) + { + audio.clear(); + rxaudio->getNextAudioChunk(audio); + // Now we have the next audio chunk, we can release the mutex. + audioMutex.unlock(); + int len = 0; + while (len < audio.length()) { + audioPacket partial; + partial.data = audio.mid(len, 1364); + receiveAudioData(partial); + len = len + partial.data.length(); + } + } + else { + qInfo(logUdpServer()) << "Unable to lock mutex for rxaudio"; } } } diff --git a/udpserver.h b/udpserver.h index 90bfcda..1bfbacd 100644 --- a/udpserver.h +++ b/udpserver.h @@ -154,6 +154,7 @@ private: QMutex udpMutex; // Used for critical operations. QMutex connMutex; + QMutex audioMutex; QList controlClients = QList(); QList civClients = QList(); From cc2f2b2576331000297cd58dccec0622b42edd6d Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 18 Nov 2021 12:20:36 +0000 Subject: [PATCH 73/79] Remove some extra logging from audio --- audiohandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/audiohandler.cpp b/audiohandler.cpp index 4dd623a..d0381fa 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -448,7 +448,7 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes) audioPacket packet; if (!ringBuf->try_read(packet)) { - qDebug() << "No more data available but buffer is not full! sentlen:" << sentlen << " nBytes:" << nBytes ; + qDebug(logAudio()) << "No more data available but buffer is not full! sentlen:" << sentlen << " nBytes:" << nBytes ; break; } currentLatency = packet.time.msecsTo(QTime::currentTime()); @@ -470,7 +470,7 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes) } if (currentLatency > setup.latency) { - qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Packet " << hex << packet.seq << + qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Packet " << hex << packet.seq << " arrived too late (increase output latency!) " << dec << packet.time.msecsTo(QTime::currentTime()) << "ms"; while (currentLatency > setup.latency/2) { @@ -493,12 +493,14 @@ qint64 audioHandler::readData(char* buffer, qint64 nBytes) break; } + /* if (packet.seq <= lastSeq) { qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Duplicate/early audio packet: " << hex << lastSeq << " got " << hex << packet.seq; } else if (packet.seq != lastSeq + 1) { qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Missing audio packet(s) from: " << hex << lastSeq + 1 << " to " << hex << packet.seq - 1; } + */ lastSeq = packet.seq; } } From 130d10553539e358ecc0e5603e5d1ea1137a90f5 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 18 Nov 2021 14:09:09 +0000 Subject: [PATCH 74/79] Fix silly bug in retransmit code --- udphandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/udphandler.cpp b/udphandler.cpp index 161ce92..bcc7a2e 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -1130,7 +1130,7 @@ void udpBase::dataReceived(QByteArray r) if (match == txSeqBuf.end()) { qDebug(logUdp()) << this->metaObject()->className() << ": Requested packet " << hex << seq << " not found"; // Just send idle packet. - sendControl(false, 0, match->seqNum); + sendControl(false, 0, seq); } else { // Found matching entry? From 62771f6b590e5aa46e4a4891d51c662d01978ec4 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 18 Nov 2021 14:09:09 +0000 Subject: [PATCH 75/79] Fix silly bug in retransmit code --- udphandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/udphandler.cpp b/udphandler.cpp index 6ae6333..7e88181 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -1138,7 +1138,7 @@ void udpBase::dataReceived(QByteArray r) if (match == txSeqBuf.end()) { qDebug(logUdp()) << this->metaObject()->className() << ": Requested packet " << hex << seq << " not found"; // Just send idle packet. - sendControl(false, 0, match->seqNum); + sendControl(false, 0, seq); } else { // Found matching entry? From 39f07414eecd6a2a20ea92416a78df23b574e325 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Fri, 19 Nov 2021 17:52:18 +0000 Subject: [PATCH 76/79] Add --version command line argument and WFVIEW_VERSION #define --- aboutbox.cpp | 2 +- main.cpp | 13 +++++++++++-- wfview.pro | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/aboutbox.cpp b/aboutbox.cpp index a9222b0..dadd943 100644 --- a/aboutbox.cpp +++ b/aboutbox.cpp @@ -12,7 +12,7 @@ aboutbox::aboutbox(QWidget *parent) : ui->logoBtn->setIcon(QIcon(":resources/wfview.png")); ui->logoBtn->setStyleSheet("Text-align:left"); - ui->topText->setText("wfview version 1.2d"); + ui->topText->setText("wfview version " + QString(WFVIEW_VERSION)); QString head = QString(""); QString copyright = QString("Copyright 2017-2021 Elliott H. Liggett, W6EL. All rights reserved. wfview source code is licensed under the GNU GPLv3."); diff --git a/main.cpp b/main.cpp index f98d414..63ffde4 100644 --- a/main.cpp +++ b/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) QString currentArg; - const QString helpText = QString("\nUsage: -p --port /dev/port, -h --host remotehostname, -c --civ 0xAddr, -l --logfile filename.log, -s --settings filename.ini, -d --debug\n"); // TODO... + const QString helpText = QString("\nUsage: -p --port /dev/port, -h --host remotehostname, -c --civ 0xAddr, -l --logfile filename.log, -s --settings filename.ini, -d --debug, -v --version\n"); // TODO... for(int c=1; c Date: Fri, 19 Nov 2021 18:26:45 +0000 Subject: [PATCH 77/79] Fix WFVIEW_VERSION in mac/linux --- main.cpp | 2 +- wfview.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 63ffde4..ba6229b 100644 --- a/main.cpp +++ b/main.cpp @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) #ifdef Q_OS_WIN QMessageBox::information(0, "wfview version", QString(WFVIEW_VERSION)); #else - std::cout << "wfview version: " << QString(WFVIEW_VERSION).toStdString(); + std::cout << "wfview version: " << QString(WFVIEW_VERSION).toStdString() << "\n"; #endif return 0; } else { diff --git a/wfview.pro b/wfview.pro index f1d18df..95862aa 100644 --- a/wfview.pro +++ b/wfview.pro @@ -11,7 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = wfview TEMPLATE = app -DEFINES += WFVIEW_VERSION=\"1.2d\" +DEFINES += WFVIEW_VERSION=\\\"1.2d\\\" CONFIG(debug, release|debug) { # For Debug builds only: From b0ffc94ff977d74b9c774dad00ed2a8d2183b825 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Fri, 19 Nov 2021 18:48:15 +0000 Subject: [PATCH 78/79] Add more version info --- main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index ba6229b..bae6e35 100644 --- a/main.cpp +++ b/main.cpp @@ -38,6 +38,11 @@ int main(int argc, char *argv[]) const QString helpText = QString("\nUsage: -p --port /dev/port, -h --host remotehostname, -c --civ 0xAddr, -l --logfile filename.log, -s --settings filename.ini, -d --debug, -v --version\n"); // TODO... + const QString version = QString("wfview version: %1 (Git:%2 on %3 at %4 by %5@%6)\nOperating System: %7 (%8)\nBuild Qt Version %9. Current Qt Version: %10\n") + .arg(QString(WFVIEW_VERSION)) + .arg(GITSHORT).arg(__DATE__).arg(__TIME__).arg(UNAME).arg(HOST) + .arg(QSysInfo::prettyProductName()).arg(QSysInfo::buildCpuArchitecture()) + .arg(QT_VERSION_STR).arg(qVersion()); for(int c=1; c Date: Fri, 19 Nov 2021 20:50:53 +0100 Subject: [PATCH 79/79] changed debug command --- wfmain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index ff1011f..c579b50 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -5500,8 +5500,8 @@ void wfmain::on_debugBtn_clicked() { qInfo(logSystem()) << "Debug button pressed."; // issueDelayedCommand(cmdGetRigID); - emit getRigCIV(); - //trxadj->show(); + //emit getRigCIV(); + trxadj->show(); //setRadioTimeDatePrep(); //wf->setInteraction(QCP::iRangeZoom, true); //wf->setInteraction(QCP::iRangeDrag, true);