Fix mode setting with OmniRig and allow rig type changes

The OmniRig interface now  tries to set the Tx VFO  mode when in split
operating. OmniRig already  does this for some types of  rigs where it
doesn't glitch  the Rx, this  change also  deals with those  that will
glitch the Rx e.g. where VFO swap is needed.

This change also  tries to set the  VFO to A where the  rig only split
Tx's on the other.

OmniRig allows the rig  type to be changed on the  fly, this change no
longer treats that  as a rig control error and  tries to continue with
the new  rig type. Also better  handling of OmniRig reporting  the rig
offline now allows up to five seconds for OmniRig to return the rig to
online.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7032 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2016-08-13 23:34:10 +00:00
parent b4cdecdd47
commit 20ee2b1fca
2 changed files with 69 additions and 9 deletions

View File

@ -104,6 +104,7 @@ OmniRigTransceiver::OmniRigTransceiver (std::unique_ptr<TransceiverBase> wrapped
, rig_number_ {n}
, readable_params_ {0}
, writable_params_ {0}
, rig_offline_ {true}
, send_update_signal_ {false}
, reversed_ {false}
{
@ -123,7 +124,7 @@ int OmniRigTransceiver::do_start ()
throw_qstring (tr ("Failed to start OmniRig COM server"));
}
// COM/OLE exceptions get signalled
// COM/OLE exceptions get signaled
connect (&*omni_rig_, SIGNAL (exception (int, QString, QString, QString)), this, SLOT (handle_COM_exception (int, QString, QString, QString)));
// IOmniRigXEvent interface signals
@ -173,11 +174,12 @@ int OmniRigTransceiver::do_start ()
}
}
rig_type_ = rig_->RigType ();
readable_params_ = rig_->ReadableParams ();
writable_params_ = rig_->WriteableParams ();
TRACE_CAT ("OmniRigTransceiver", QString {"OmniRig initial rig type: %1 readable params = 0x%2 writable params = 0x%3 for rig %4"}
.arg (rig_->RigType ())
.arg (rig_type_)
.arg (readable_params_, 8, 16, QChar ('0'))
.arg (writable_params_, 8, 16, QChar ('0'))
.arg (rig_number_).toLocal8Bit ());
@ -189,6 +191,14 @@ int OmniRigTransceiver::do_start ()
int resolution {0};
if (f)
{
if (OmniRig::PM_UNKNOWN == rig_->Vfo ()
&& (writable_params_ & (OmniRig::PM_VFOA | OmniRig::PM_VFOB))
== (OmniRig::PM_VFOA | OmniRig::PM_VFOB))
{
// start with VFO A (probably MAIN) on rigs that we
// can't query VFO but can set explicitly
rig_->SetVfo (OmniRig::PM_VFOA);
}
if (f % 10) return resolution; // 1Hz resolution
auto test_frequency = f - f % 100 + 55;
if (OmniRig::PM_FREQ & writable_params_)
@ -227,6 +237,7 @@ int OmniRigTransceiver::do_start ()
rig_->SetFreqA (f);
}
update_rx_frequency (f);
rig_offline_ = false;
return resolution;
}
}
@ -242,10 +253,19 @@ void OmniRigTransceiver::do_stop ()
{
port_->Unlock (); // release serial port
port_->clear ();
port_.reset ();
}
if (omni_rig_)
{
if (rig_)
{
rig_->clear ();
rig_.reset ();
}
omni_rig_->clear ();
omni_rig_.reset ();
CoUninitialize ();
}
if (rig_) rig_->clear ();
if (omni_rig_) omni_rig_->clear ();
CoUninitialize ();
if (wrapped_) wrapped_->stop ();
TRACE_CAT ("OmniRigTransceiver", "stopped");
}
@ -283,7 +303,6 @@ void OmniRigTransceiver::handle_rig_type_change (int rig_number)
.arg (readable_params_, 8, 16, QChar ('0'))
.arg (writable_params_, 8, 16, QChar ('0'))
.arg (rig_number).toLocal8Bit ());
offline ("OmniRig rig changed");
}
}
@ -291,18 +310,35 @@ void OmniRigTransceiver::handle_status_change (int rig_number)
{
if (rig_number_ == rig_number)
{
TRACE_CAT ("OmniRigTransceiver", QString {"OmniRig status change: new status for rig %1 = "}.arg (rig_number).toLocal8Bit () << rig_->StatusStr ().toLocal8Bit ());
auto const& status = rig_->StatusStr ().toLocal8Bit ();
TRACE_CAT ("OmniRigTransceiver", QString {"OmniRig status change: new status for rig %1 = "}.arg (rig_number).toLocal8Bit () << status);
if (OmniRig::ST_ONLINE != rig_->Status ())
{
QTimer::singleShot (5000, this, SLOT (online_check ()));
if (!rig_offline_)
{
rig_offline_ = true;
// give OmniRig 5 seconds to recover
QTimer::singleShot (5 * 1000, this, SLOT (timeout_check ()));
}
}
else
{
TRACE_CAT ("OmniRigTransceiver", "OmniRig frequency:" << rig_->GetRxFrequency ());
rig_offline_ = false;
update_rx_frequency (rig_->GetRxFrequency ());
update_complete ();
TRACE_CAT ("OmniRigTransceiver", "OmniRig frequency:" << state ().frequency ());
}
}
}
void OmniRigTransceiver::timeout_check ()
{
if (rig_offline_)
{
offline ("Rig went offline");
}
}
void OmniRigTransceiver::handle_params_change (int rig_number, int params)
{
if (rig_number_ == rig_number)
@ -593,6 +629,27 @@ void OmniRigTransceiver::do_tx_frequency (Frequency tx, MODE m, bool /*no_ignore
if (UNK != m)
{
do_mode (m);
if (OmniRig::PM_UNKNOWN == rig_->Vfo ())
{
if (writable_params_ & OmniRig::PM_VFOEQUAL)
{
// nothing to do here because OmniRig will use VFO
// equalize to set the mode of the Tx VFO for us
}
else if ((writable_params_ & (OmniRig::PM_VFOA | OmniRig::PM_VFOB))
== (OmniRig::PM_VFOA | OmniRig::PM_VFOB))
{
rig_->SetVfo (OmniRig::PM_VFOB);
do_mode (m);
rig_->SetVfo (OmniRig::PM_VFOA);
}
else if (writable_params_ & OmniRig::PM_VFOSWAP)
{
rig_->SetVfo (OmniRig::PM_VFOSWAP);
do_mode (m);
rig_->SetVfo (OmniRig::PM_VFOSWAP);
}
}
}
TRACE_CAT ("OmniRigTransceiver", "set SPLIT mode on");
rig_->SetSplitMode (state ().frequency (), tx);

View File

@ -41,6 +41,7 @@ public:
void do_sync (bool force_signal, bool no_poll) override;
private:
Q_SLOT void timeout_check ();
Q_SLOT void handle_COM_exception (int, QString, QString, QString);
Q_SLOT void handle_visible_change ();
Q_SLOT void handle_rig_type_change (int rig_number);
@ -58,8 +59,10 @@ private:
RigNumber rig_number_;
QScopedPointer<OmniRig::RigX> rig_;
QScopedPointer<OmniRig::PortBits> port_;
QString rig_type_;
int readable_params_;
int writable_params_;
bool rig_offline_;
bool send_update_signal_;
bool reversed_; // some rigs can reverse VFOs
};