From 929d40c9ed9da303dffb0ed886655cf637495e0e Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Sat, 7 Dec 2024 19:06:04 +0100 Subject: [PATCH 1/4] Fixed #480 - DXC DIGI spot tunes USB DIGI Mode The new feature is implemented only for TCI and Hamlib. Omnirig is currently on hold because it is not clear how to distinguish between a Rig with DIGI mode and a Rig without DIGI mode. --- rig/Rig.cpp | 12 +++--- rig/Rig.h | 4 +- rig/drivers/GenericRigDrv.h | 2 +- rig/drivers/HamlibRigDrv.cpp | 73 ++++++++++++++++----------------- rig/drivers/HamlibRigDrv.h | 3 +- rig/drivers/OmnirigRigDrv.cpp | 4 +- rig/drivers/OmnirigRigDrv.h | 2 +- rig/drivers/Omnirigv2RigDrv.cpp | 4 +- rig/drivers/Omnirigv2RigDrv.h | 2 +- rig/drivers/TCIRigDrv.cpp | 28 +++++++++---- rig/drivers/TCIRigDrv.h | 4 +- ui/NewContactWidget.cpp | 5 ++- 12 files changed, 77 insertions(+), 66 deletions(-) diff --git a/rig/Rig.cpp b/rig/Rig.cpp index da1cb789..7802d174 100644 --- a/rig/Rig.cpp +++ b/rig/Rig.cpp @@ -387,32 +387,32 @@ void Rig::setRawModeImpl(const QString &rawMode) rigDriver->setRawMode(rawMode); } -void Rig::setMode(const QString &newMode, const QString &newSubMode) +void Rig::setMode(const QString &newMode, const QString &newSubMode, bool digiVariant) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << newMode << newSubMode; + qCDebug(function_parameters) << newMode << newSubMode << digiVariant; if ( newMode.isEmpty() && newSubMode.isEmpty() ) return; QMetaObject::invokeMethod(this, "setModeImpl", - Qt::QueuedConnection, Q_ARG(QString, newMode), Q_ARG(QString, newSubMode)); + Qt::QueuedConnection, Q_ARG(QString, newMode), Q_ARG(QString, newSubMode), Q_ARG(bool, digiVariant)); } -void Rig::setModeImpl(const QString &newMode, const QString &newSubMode) +void Rig::setModeImpl(const QString &newMode, const QString &newSubMode, bool digiVariant) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << newMode << newSubMode; + qCDebug(function_parameters) << newMode << newSubMode << digiVariant; MUTEXLOCKER; if ( ! rigDriver ) return; - rigDriver->setMode(newMode, newSubMode); + rigDriver->setMode(newMode, newSubMode, digiVariant); } void Rig::setPTT(bool active) diff --git a/rig/Rig.h b/rig/Rig.h index bcdca501..699efac2 100644 --- a/rig/Rig.h +++ b/rig/Rig.h @@ -59,7 +59,7 @@ public slots: void setFrequency(double); void setRawMode(const QString &rawMode); - void setMode(const QString &, const QString &); + void setMode(const QString &, const QString &, bool = false); void setPTT(bool); void setKeySpeed(qint16 wpm); void syncKeySpeed(qint16 wpm); @@ -90,7 +90,7 @@ private slots: void setFrequencyImpl(double); void setRawModeImpl(const QString&); - void setModeImpl(const QString &, const QString &); + void setModeImpl(const QString &, const QString &, bool); void setPTTImpl(bool); void setKeySpeedImpl(qint16 wpm); void syncKeySpeedImpl(qint16 wpm); diff --git a/rig/drivers/GenericRigDrv.h b/rig/drivers/GenericRigDrv.h index 01278c1a..0eb23877 100644 --- a/rig/drivers/GenericRigDrv.h +++ b/rig/drivers/GenericRigDrv.h @@ -22,7 +22,7 @@ class GenericRigDrv : public QObject virtual void setFrequency(double) = 0; virtual void setRawMode(const QString &) = 0; - virtual void setMode(const QString &, const QString &) = 0; + virtual void setMode(const QString &, const QString &, bool) = 0; virtual void setPTT(bool) = 0; virtual void setKeySpeed(qint16 wpm) = 0; virtual void syncKeySpeed(qint16 wpm) = 0; diff --git a/rig/drivers/HamlibRigDrv.cpp b/rig/drivers/HamlibRigDrv.cpp index 99883e5a..95bc0317 100644 --- a/rig/drivers/HamlibRigDrv.cpp +++ b/rig/drivers/HamlibRigDrv.cpp @@ -136,8 +136,33 @@ HamlibRigDrv::HamlibRigDrv(const RigProfile &profile, rig_set_debug(RIG_DEBUG_BUG); + rmode_t localRigModes = RIG_MODE_NONE; + + if ( rig->caps->rig_model == RIG_MODEL_NETRIGCTL ) + { + /* Limit a set of modes for network rig */ + localRigModes = static_cast(RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_AM); + } + else if ( rig->state.mode_list != RIG_MODE_NONE ) + localRigModes = static_cast(rig->state.mode_list); + + /* hamlib 3.x and 4.x are very different - workaround */ + for ( unsigned char i = 0; i < (sizeof(rmode_t)*8)-1; i++ ) + { + /* hamlib 3.x and 4.x are very different - workaround */ + const char *ms = rig_strrmode(static_cast(localRigModes & rig_idx2setting(i))); + + if (!ms || !ms[0]) + { + continue; + } + qCDebug(runtime) << "Supported Mode :" << ms; + + modeList.append(QString(ms)); + } + connect(&errorTimer, &QTimer::timeout, - this, &HamlibRigDrv::checkErrorCounter); + this, &HamlibRigDrv::checkErrorCounter); } HamlibRigDrv::~HamlibRigDrv() @@ -254,40 +279,6 @@ QStringList HamlibRigDrv::getAvailableModes() MUTEXLOCKER; - if ( !rig ) - { - qCWarning(runtime) << "Rig is not active"; - return QStringList(); - } - - rmode_t localRigModes = RIG_MODE_NONE; - QStringList modeList; - - if ( rig->caps->rig_model == RIG_MODEL_NETRIGCTL ) - { - /* Limit a set of modes for network rig */ - localRigModes = static_cast(RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_AM); - } - else if ( rig->state.mode_list != RIG_MODE_NONE ) - { - localRigModes = static_cast(rig->state.mode_list); - } - - /* hamlib 3.x and 4.x are very different - workaround */ - for ( unsigned char i = 0; i < (sizeof(rmode_t)*8)-1; i++ ) - { - /* hamlib 3.x and 4.x are very different - workaround */ - const char *ms = rig_strrmode(static_cast(localRigModes & rig_idx2setting(i))); - - if (!ms || !ms[0]) - { - continue; - } - qCDebug(runtime) << "Supported Mode :" << ms; - - modeList.append(QString(ms)); - } - return modeList; } @@ -337,13 +328,19 @@ void HamlibRigDrv::setRawMode(const QString &rawMode) __setMode(rig_parse_mode(rawMode.toLatin1())); } -void HamlibRigDrv::setMode(const QString &mode, const QString &subMode) +void HamlibRigDrv::setMode(const QString &mode, const QString &subMode, bool digiVariant) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << mode << subMode; + qCDebug(function_parameters) << mode << subMode << digiVariant; + QString innerSubmode(subMode); + + if ( digiVariant + && (innerSubmode == "USB" || innerSubmode == "LSB") + && modeList.contains("PKT" + subMode) ) + innerSubmode.prepend("PKT"); - setRawMode((subMode.isEmpty()) ? mode : subMode); + setRawMode((innerSubmode.isEmpty()) ? mode : innerSubmode); } void HamlibRigDrv::__setMode(rmode_t newModeID) diff --git a/rig/drivers/HamlibRigDrv.h b/rig/drivers/HamlibRigDrv.h index c99898c4..c4978af6 100644 --- a/rig/drivers/HamlibRigDrv.h +++ b/rig/drivers/HamlibRigDrv.h @@ -24,7 +24,7 @@ class HamlibRigDrv : public GenericRigDrv virtual void setFrequency(double) override; virtual void setRawMode(const QString &) override; - virtual void setMode(const QString &, const QString &) override; + virtual void setMode(const QString &, const QString &, bool) override; virtual void setPTT(bool) override; virtual void setKeySpeed(qint16 wpm) override; virtual void syncKeySpeed(qint16 wpm) override; @@ -92,6 +92,7 @@ private slots: bool morseOverCatSupported; QMutex drvLock; QHashpostponedErrors; + QStringList modeList; }; #endif // RIG_DRIVERS_HAMLIBRIGDRV_H diff --git a/rig/drivers/OmnirigRigDrv.cpp b/rig/drivers/OmnirigRigDrv.cpp index 1a160285..6209da7f 100644 --- a/rig/drivers/OmnirigRigDrv.cpp +++ b/rig/drivers/OmnirigRigDrv.cpp @@ -256,11 +256,11 @@ void OmnirigRigDrv::setRawMode(const QString &rawMode) } } -void OmnirigRigDrv::setMode(const QString &mode, const QString &submode) +void OmnirigRigDrv::setMode(const QString &mode, const QString &submode, bool digiVariant) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << mode << submode; + qCDebug(function_parameters) << mode << submode << digiVariant; setRawMode((submode.isEmpty()) ? mode.toUpper() : submode.toUpper()); } diff --git a/rig/drivers/OmnirigRigDrv.h b/rig/drivers/OmnirigRigDrv.h index 0e2a52dd..4a48b33e 100644 --- a/rig/drivers/OmnirigRigDrv.h +++ b/rig/drivers/OmnirigRigDrv.h @@ -26,7 +26,7 @@ class OmnirigRigDrv : public GenericRigDrv virtual void setFrequency(double) override; virtual void setRawMode(const QString &) override; - virtual void setMode(const QString &, const QString &) override; + virtual void setMode(const QString &, const QString &, bool) override; virtual void setPTT(bool) override; virtual void setKeySpeed(qint16 wpm) override; virtual void syncKeySpeed(qint16 wpm) override; diff --git a/rig/drivers/Omnirigv2RigDrv.cpp b/rig/drivers/Omnirigv2RigDrv.cpp index f7fe96f2..2febeede 100644 --- a/rig/drivers/Omnirigv2RigDrv.cpp +++ b/rig/drivers/Omnirigv2RigDrv.cpp @@ -259,11 +259,11 @@ void OmnirigV2RigDrv::setRawMode(const QString &rawMode) } } -void OmnirigV2RigDrv::setMode(const QString &mode, const QString &submode) +void OmnirigV2RigDrv::setMode(const QString &mode, const QString &submode, bool digiVariant) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << mode << submode; + qCDebug(function_parameters) << mode << submode << digiVariant; setRawMode((submode.isEmpty()) ? mode.toUpper() : submode.toUpper()); } diff --git a/rig/drivers/Omnirigv2RigDrv.h b/rig/drivers/Omnirigv2RigDrv.h index 9ebfd882..30cfd5b3 100644 --- a/rig/drivers/Omnirigv2RigDrv.h +++ b/rig/drivers/Omnirigv2RigDrv.h @@ -30,7 +30,7 @@ class OmnirigV2RigDrv : public GenericRigDrv virtual void setFrequency(double) override; virtual void setRawMode(const QString &) override; - virtual void setMode(const QString &, const QString &) override; + virtual void setMode(const QString &, const QString &, bool digiVariant) override; virtual void setPTT(bool) override; virtual void setKeySpeed(qint16 wpm) override; virtual void syncKeySpeed(qint16 wpm) override; diff --git a/rig/drivers/TCIRigDrv.cpp b/rig/drivers/TCIRigDrv.cpp index e8fca959..b3616fc9 100644 --- a/rig/drivers/TCIRigDrv.cpp +++ b/rig/drivers/TCIRigDrv.cpp @@ -142,13 +142,13 @@ void TCIRigDrv::setRawMode(const QString &rawMode) sendCmd("modulation", true, args); } -void TCIRigDrv::setMode(const QString &mode, const QString &subMode) +void TCIRigDrv::setMode(const QString &mode, const QString &subMode, bool digiVariant) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << mode << subMode; + qCDebug(function_parameters) << mode << subMode << digiVariant; - setRawMode(mode2RawMode(mode, subMode)); + setRawMode(mode2RawMode(mode, subMode, digiVariant)); } void TCIRigDrv::setPTT(bool newPTTState) @@ -285,7 +285,7 @@ void TCIRigDrv::sendDXSpot(const DxSpot &spot) QStringList args = { spot.callsign, - mode2RawMode(mode, submode), + mode2RawMode(mode, submode, (spot.bandPlanMode == BandPlan::BAND_MODE_FT8 || spot.bandPlanMode == BandPlan::BAND_MODE_DIGITAL)), QString::number(internalFreq), QString::number(spotColor.rgba()), spot.callsign @@ -478,13 +478,21 @@ const QString TCIRigDrv::getModeNormalizedText(const QString &rawMode, QString & return QString(); } -const QString TCIRigDrv::mode2RawMode(const QString &mode, const QString &submode) +const QString TCIRigDrv::mode2RawMode(const QString &mode, const QString &submode, bool digiVariant) { FCT_IDENTIFICATION; - - if ( mode == "SSB" ) - return submode; + if (mode == "SSB") + { + QString innerSubmode = submode; + if ( digiVariant ) + { + const QString digMode = QLatin1String("DIG") + submode.at(0); + if ( modeList.contains(digMode) ) + innerSubmode = digMode; + } + return innerSubmode; + } if ( mode == "CW" ) return mode; @@ -499,6 +507,10 @@ const QString TCIRigDrv::mode2RawMode(const QString &mode, const QString &submod { if ( modeList.contains("FT8") ) return "FT8"; + + if ( modeList.contains("DIGU") ) + return "DIGU"; + return "USB"; } diff --git a/rig/drivers/TCIRigDrv.h b/rig/drivers/TCIRigDrv.h index d945a07c..14c7df46 100644 --- a/rig/drivers/TCIRigDrv.h +++ b/rig/drivers/TCIRigDrv.h @@ -24,7 +24,7 @@ class TCIRigDrv : public GenericRigDrv virtual void setFrequency(double) override; virtual void setRawMode(const QString &) override; - virtual void setMode(const QString &, const QString &) override; + virtual void setMode(const QString &, const QString &, bool) override; virtual void setPTT(bool) override; virtual void setKeySpeed(qint16 wpm) override; virtual void syncKeySpeed(qint16 wpm) override; @@ -46,7 +46,7 @@ private slots: bool addRigID, const QStringList &args = QStringList()); const QString getModeNormalizedText(const QString& rawMode, QString &submode); - const QString mode2RawMode(const QString &mode, const QString &submode); + const QString mode2RawMode(const QString &mode, const QString &submode, bool digiVariant); // commands functions void rspPROTOCOL(const QStringList &); diff --git a/ui/NewContactWidget.cpp b/ui/NewContactWidget.cpp index 36864705..c6061943 100644 --- a/ui/NewContactWidget.cpp +++ b/ui/NewContactWidget.cpp @@ -2714,12 +2714,13 @@ void NewContactWidget::tuneDx(const DxSpot &spot) // therefore change Mode without signals and then set the // final mode changeModeWithoutSignals(mode, subMode); - if ( mode == "FT8" ) + if (spot.bandPlanMode == BandPlan::BAND_MODE_FT8 + || spot.bandPlanMode == BandPlan::BAND_MODE_DIGITAL ) { // if rig is connected then FT8 mode is overwrotten by rit // but it the rig is not connected then mode contains a correct // mode - rig->setMode("SSB", "USB"); + rig->setMode("SSB", "USB", true); } else { From b2f12735105e05c810d71c51354a47858764d256 Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Sun, 8 Dec 2024 17:47:21 +0100 Subject: [PATCH 2/4] Omnirig: Fixed issue with an incorrect DIGI mode --- rig/drivers/OmnirigRigDrv.cpp | 4 ++-- rig/drivers/Omnirigv2RigDrv.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rig/drivers/OmnirigRigDrv.cpp b/rig/drivers/OmnirigRigDrv.cpp index 6209da7f..f7f58756 100644 --- a/rig/drivers/OmnirigRigDrv.cpp +++ b/rig/drivers/OmnirigRigDrv.cpp @@ -398,14 +398,14 @@ const QString OmnirigRigDrv::getModeNormalizedText(const QString &rawMode, QStri return "FM"; // maybe bad maybe good - if ( rawMode == "DIGI_U" ) + if ( rawMode == "DIG_U" ) { submode = "USB"; return "SSB"; } // maybe bad maybe good - if ( rawMode == "DIGI_L" ) + if ( rawMode == "DIG_L" ) { submode = "LSB"; return "SSB"; diff --git a/rig/drivers/Omnirigv2RigDrv.cpp b/rig/drivers/Omnirigv2RigDrv.cpp index 2febeede..6e47d70d 100644 --- a/rig/drivers/Omnirigv2RigDrv.cpp +++ b/rig/drivers/Omnirigv2RigDrv.cpp @@ -498,14 +498,14 @@ const QString OmnirigV2RigDrv::getModeNormalizedText(const QString &rawMode, QSt return "FM"; // maybe bad maybe good - if ( rawMode == "DIGI_U" ) + if ( rawMode == "DIG_U" ) { submode = "USB"; return "SSB"; } // maybe bad maybe good - if ( rawMode == "DIGI_L" ) + if ( rawMode == "DIG_L" ) { submode = "LSB"; return "SSB"; From e8f6ee7cfd6c419e5132c9bd5b7878cfd1e6aad9 Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Sun, 8 Dec 2024 17:48:00 +0100 Subject: [PATCH 3/4] Fixed #480 - DXC DIGI spot tunes USB DIGI Mode (2) Added also Omnirig support --- rig/drivers/OmnirigRigDrv.cpp | 11 ++++++++++- rig/drivers/Omnirigv2RigDrv.cpp | 13 +++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rig/drivers/OmnirigRigDrv.cpp b/rig/drivers/OmnirigRigDrv.cpp index f7f58756..a9dbf632 100644 --- a/rig/drivers/OmnirigRigDrv.cpp +++ b/rig/drivers/OmnirigRigDrv.cpp @@ -250,7 +250,7 @@ void OmnirigRigDrv::setRawMode(const QString &rawMode) if ( rawMode & writableParams ) { qCDebug(runtime) << "Setting Mode"; - rig->SetMode(mappedMode.at(0)); + rig->SetMode(rawMode); commandSleep(); } } @@ -262,6 +262,15 @@ void OmnirigRigDrv::setMode(const QString &mode, const QString &submode, bool di qCDebug(function_parameters) << mode << submode << digiVariant; + QString innerSubmode(submode); + + if ( digiVariant ) + { + const QString digMode = QLatin1String("DIG_") + innerSubmode.at(0); + if ( modeMap.key(digMode) & writableParams ) + innerSubmode = digMode; + } + setRawMode((submode.isEmpty()) ? mode.toUpper() : submode.toUpper()); } diff --git a/rig/drivers/Omnirigv2RigDrv.cpp b/rig/drivers/Omnirigv2RigDrv.cpp index 6e47d70d..51a79989 100644 --- a/rig/drivers/Omnirigv2RigDrv.cpp +++ b/rig/drivers/Omnirigv2RigDrv.cpp @@ -253,7 +253,7 @@ void OmnirigV2RigDrv::setRawMode(const QString &rawMode) if ( rawMode & writableParams ) { qCDebug(runtime) << "Setting Mode"; - rig->SetMode(mappedMode.at(0)); + rig->SetMode(rawMode); commandSleep(); } } @@ -265,7 +265,16 @@ void OmnirigV2RigDrv::setMode(const QString &mode, const QString &submode, bool qCDebug(function_parameters) << mode << submode << digiVariant; - setRawMode((submode.isEmpty()) ? mode.toUpper() : submode.toUpper()); + QString innerSubmode(submode); + + if ( digiVariant ) + { + const QString digMode = QLatin1String("DIG_") + innerSubmode.at(0); + if ( modeMap.key(digMode) & writableParams ) + innerSubmode = digMode; + } + + setRawMode((submode.isEmpty()) ? mode.toUpper() : innerSubmode.toUpper()); } void OmnirigV2RigDrv::setPTT(bool newPTTSTate) From 1e0f28d912de7f9336960dc639a4818b97685bbb Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Wed, 11 Dec 2024 10:14:56 +0100 Subject: [PATCH 4/4] Omnirigv1 v2: Show only available Rig modes --- rig/drivers/OmnirigRigDrv.cpp | 8 +++++--- rig/drivers/Omnirigv2RigDrv.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rig/drivers/OmnirigRigDrv.cpp b/rig/drivers/OmnirigRigDrv.cpp index a9dbf632..397f4a8b 100644 --- a/rig/drivers/OmnirigRigDrv.cpp +++ b/rig/drivers/OmnirigRigDrv.cpp @@ -171,10 +171,10 @@ QStringList OmnirigRigDrv::getAvailableModes() FCT_IDENTIFICATION; QStringList ret; - const QStringList &modes = modeMap.values(); - for ( const QString& mode : modes ) - ret << mode; + for ( auto it = modeMap.constBegin(); it != modeMap.constEnd(); ++it ) + if ( it.key() & writableParams ) + ret.append(it.value()); return ret; } @@ -463,6 +463,8 @@ void OmnirigRigDrv::rigStatusChange(int rigID) emit errorOccured(tr("Rig status changed"), tr("Rig is not connected")); } + else + emit rigIsReady(); } void OmnirigRigDrv::COMException(int code, diff --git a/rig/drivers/Omnirigv2RigDrv.cpp b/rig/drivers/Omnirigv2RigDrv.cpp index 51a79989..223d1db4 100644 --- a/rig/drivers/Omnirigv2RigDrv.cpp +++ b/rig/drivers/Omnirigv2RigDrv.cpp @@ -174,10 +174,10 @@ QStringList OmnirigV2RigDrv::getAvailableModes() FCT_IDENTIFICATION; QStringList ret; - const QStringList &modes = modeMap.values(); - for ( const QString& mode : modes ) - ret << mode; + for ( auto it = modeMap.constBegin(); it != modeMap.constEnd(); ++it ) + if ( it.key() & writableParams ) + ret.append(it.value()); return ret; } @@ -415,6 +415,8 @@ void OmnirigV2RigDrv::rigStatusChange(int rigID) emit errorOccured(tr("Rig status changed"), tr("Rig is not connected")); } + else + emit rigIsReady(); } void OmnirigV2RigDrv::COMException(int code,