Skip to content

Commit

Permalink
Merge branch 'bugfix-480' into testing_0.41
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Dec 13, 2024
2 parents e06480b + 1e0f28d commit 0d6c2ee
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 79 deletions.
12 changes: 6 additions & 6 deletions rig/Rig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions rig/Rig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion rig/drivers/GenericRigDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
73 changes: 35 additions & 38 deletions rig/drivers/HamlibRigDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rmode_t>(RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_AM);
}
else if ( rig->state.mode_list != RIG_MODE_NONE )
localRigModes = static_cast<rmode_t>(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<rmode_t>(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()
Expand Down Expand Up @@ -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<rmode_t>(RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_AM);
}
else if ( rig->state.mode_list != RIG_MODE_NONE )
{
localRigModes = static_cast<rmode_t>(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<rmode_t>(localRigModes & rig_idx2setting(i)));

if (!ms || !ms[0])
{
continue;
}
qCDebug(runtime) << "Supported Mode :" << ms;

modeList.append(QString(ms));
}

return modeList;
}

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion rig/drivers/HamlibRigDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,6 +92,7 @@ private slots:
bool morseOverCatSupported;
QMutex drvLock;
QHash<QString, QString>postponedErrors;
QStringList modeList;
};

#endif // RIG_DRIVERS_HAMLIBRIGDRV_H
27 changes: 19 additions & 8 deletions rig/drivers/OmnirigRigDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -250,17 +250,26 @@ void OmnirigRigDrv::setRawMode(const QString &rawMode)
if ( rawMode & writableParams )
{
qCDebug(runtime) << "Setting Mode";
rig->SetMode(mappedMode.at(0));
rig->SetMode(rawMode);
commandSleep();
}
}
}

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;

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());
}
Expand Down Expand Up @@ -398,14 +407,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";
Expand Down Expand Up @@ -454,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,
Expand Down
2 changes: 1 addition & 1 deletion rig/drivers/OmnirigRigDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 20 additions & 9 deletions rig/drivers/Omnirigv2RigDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -253,19 +253,28 @@ void OmnirigV2RigDrv::setRawMode(const QString &rawMode)
if ( rawMode & writableParams )
{
qCDebug(runtime) << "Setting Mode";
rig->SetMode(mappedMode.at(0));
rig->SetMode(rawMode);
commandSleep();
}
}
}

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());
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)
Expand Down Expand Up @@ -406,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,
Expand Down Expand Up @@ -498,14 +509,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";
Expand Down
2 changes: 1 addition & 1 deletion rig/drivers/Omnirigv2RigDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 0d6c2ee

Please sign in to comment.