From 88430db9ac342a298ea3943272c3c614cbaccbea Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sat, 6 Nov 2021 23:59:03 -0700 Subject: [PATCH] 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