Skip to content

Commit

Permalink
Fixed #37 - Rig over network is crashing
Browse files Browse the repository at this point in the history
due to a hamlib issue #855 (Hamlib/Hamlib#855)
get PWR Rig function is disabled for hamlib versions 4.2 and 4.3
  • Loading branch information
foldynl committed Apr 12, 2022
1 parent 54b8e80 commit d5d4c87
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
79 changes: 76 additions & 3 deletions ui/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ void SettingsDialog::doubleClickRigProfile(QModelIndex i)
ui->rigProfileNameEdit->setText(profile.profileName);

ui->rigModelSelect->setCurrentIndex(ui->rigModelSelect->findData(profile.model));

ui->rigPortEdit->setText(profile.portPath);
ui->rigHostNameEdit->setText(profile.hostname);
ui->rigNetPortSpin->setValue(profile.netport);
Expand All @@ -320,6 +321,8 @@ void SettingsDialog::doubleClickRigProfile(QModelIndex i)
ui->rigRXOffsetSpinBox->setValue(profile.ritOffset);
ui->rigTXOffsetSpinBox->setValue(profile.xitOffset);

fixRigCap(rig_get_caps(profile.model));

ui->rigAddProfileButton->setText(tr("Modify"));
}

Expand Down Expand Up @@ -749,6 +752,8 @@ void SettingsDialog::clearStationProfileForm()
ui->stationAddProfileButton->setText(tr("Add"));
}

/* This function is called when an user change Rig Combobox */
/* new rig entered */
void SettingsDialog::rigChanged(int index)
{
FCT_IDENTIFICATION;
Expand All @@ -771,8 +776,11 @@ void SettingsDialog::rigChanged(int index)
else
{
ui->rigStackedWidget->setCurrentIndex(0);
ui->rigDataBitsSelect->setCurrentText(QString::number(caps->serial_data_bits));
ui->rigStopBitsSelect->setCurrentText(QString::number(caps->serial_stop_bits));
}

/* Set rig Caps */
ui->rigGetFreqCheckBox->setEnabled(caps->get_freq);
ui->rigGetFreqCheckBox->setChecked(caps->get_freq);

Expand All @@ -782,16 +790,18 @@ void SettingsDialog::rigChanged(int index)
ui->rigGetVFOCheckBox->setEnabled(caps->get_vfo);
ui->rigGetVFOCheckBox->setChecked(caps->get_vfo);

ui->rigGetPWRCheckBox->setEnabled(caps->get_level && caps->power2mW);
ui->rigGetPWRCheckBox->setChecked(caps->get_level && caps->power2mW);
ui->rigGetPWRCheckBox->setEnabled(caps->get_level
&& caps->power2mW);
ui->rigGetPWRCheckBox->setChecked(caps->get_level
&& caps->power2mW);

ui->rigGetRITCheckBox->setEnabled(caps->get_rit);
ui->rigGetRITCheckBox->setChecked(false);

ui->rigGetXITCheckBox->setEnabled(caps->get_xit);
ui->rigGetXITCheckBox->setChecked(false);

ui->rigDataBitsSelect->setCurrentText(QString::number(caps->serial_data_bits));
fixRigCap(caps);
}
else
{
Expand Down Expand Up @@ -1186,6 +1196,69 @@ void SettingsDialog::writeSettings() {
NetworkNotification::saveNotifWSJTXCQSpotAddrs(ui->notifWSJTXCQSpotsEdit->text());
}

/* this function is called when user modify rig progile
* there may be situations where hamlib change the cap
* for rig and it is necessary to change the settings of the rig.
* This feature does it */
void SettingsDialog::fixRigCap(const struct rig_caps *caps)
{
FCT_IDENTIFICATION;

if ( caps )
{
/* due to a hamlib issue #855 (https://github.com/Hamlib/Hamlib/issues/855)
* the PWR will be disabled for 4.3.x
* if someone tells me how to make a nice version identification of hamlib
* under Win / Lin / Mac , then I'll be happy to change it
*/

if ( (caps->port_type == RIG_PORT_NETWORK
|| caps->port_type == RIG_PORT_UDP_NETWORK)
&& ( QString(hamlib_version).contains("4.2.")
|| QString(hamlib_version).contains("4.3.") ) )
{
ui->rigGetPWRCheckBox->setEnabled(false);
ui->rigGetPWRCheckBox->setChecked(false);
}

if ( ! caps->get_freq )
{
ui->rigGetFreqCheckBox->setEnabled(false);
ui->rigGetFreqCheckBox->setChecked(false);
}

if ( ! caps->get_mode )
{
ui->rigGetModeCheckBox->setEnabled(false);
ui->rigGetModeCheckBox->setChecked(false);
}

if ( ! caps->get_vfo )
{
ui->rigGetVFOCheckBox->setEnabled(false);
ui->rigGetVFOCheckBox->setChecked(false);
}

if ( ! caps->get_level || ! caps->power2mW )
{
ui->rigGetPWRCheckBox->setEnabled(false);
ui->rigGetPWRCheckBox->setChecked(false);
}

if ( ! caps->get_rit )
{
ui->rigGetRITCheckBox->setEnabled(false);
ui->rigGetRITCheckBox->setChecked(false);
}

if ( ! caps->get_xit )
{
ui->rigGetXITCheckBox->setEnabled(false);
ui->rigGetXITCheckBox->setChecked(false);
}
}
}

SettingsDialog::~SettingsDialog() {
FCT_IDENTIFICATION;

Expand Down
2 changes: 2 additions & 0 deletions ui/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QModelIndex>
#include <QSqlTableModel>
#include <QCompleter>
#include <hamlib/rig.h>

#include "data/StationProfile.h"
#include "data/RigProfile.h"
Expand Down Expand Up @@ -69,6 +70,7 @@ public slots:
private:
void readSettings();
void writeSettings();
void fixRigCap(const struct rig_caps *caps);

QSqlTableModel* modeTableModel;
QSqlTableModel* bandTableModel;
Expand Down

0 comments on commit d5d4c87

Please sign in to comment.