Synchronize with rig PTT state when using DX Lab Suite Commander

Because Commander  queues up CAT commands  the timing of Tx  audio was
not being correctly synchronized to the rig PTT. This change polls the
rig  PTT state  after changing  PTT  and waits  for  it to  go to  the
expected state.   As it happens, just  doing a query does  most of the
synchronization  as the  query gets  queued behind  the PTT  directive
within  Commander,  with  the  reply being  delayed  until  the  query
completes.  This change goes further  and checks the PTT state changes
within one second.

Note  that users  using  Commander  will should  not  suffer from  ALC
overshoot issues on rigs that suffer such a problem since Tx audio now
only  commences after  the rig  has switched  to transmit.  Users with
hardware sequencers  may need to adjust  their "Settings->Advanced->Tx
Delay" parameter, this change does not introduce any new timing hazard
but there may be a slight lengthening  of the delay to Tx audio if the
rig reports PTT via  CAT as the audio delay may now  be timed from the
actual PTT on the rig rather than the assertion of RTS/DTR.

Still outstanding  is the  slow processing  of Commander  CAT requests
which can cause considerable delays before Tx audio can start.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7764 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2017-07-01 16:04:25 +00:00
parent 624ef493a8
commit ff6b29f3df
2 changed files with 52 additions and 14 deletions

View File

@ -2311,7 +2311,7 @@ Right click for insert and delete options.</string>
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>2.000000000000000</double>
<double>0.500000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
@ -2617,11 +2617,11 @@ soundcard changes</string>
</connections>
<buttongroups>
<buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="TX_mode_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="PTT_method_button_group"/>
</buttongroups>
</ui>

View File

@ -4,6 +4,7 @@
#include <QRegularExpression>
#include <QLocale>
#include <QThread>
#include <QDateTime>
#include "NetworkServerLookup.hpp"
@ -122,8 +123,8 @@ int DXLabSuiteCommanderTransceiver::do_start ()
}
else
{
TRACE_CAT ("DXLabSuiteCommanderTransceiver", "get frequency unexpected response");
throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency")};
TRACE_CAT ("DXLabSuiteCommanderTransceiver", "get frequency unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency: ") + reply};
}
poll ();
@ -156,7 +157,44 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
new_state.ptt (on);
wrapped_->set (new_state, 0);
}
update_PTT (on);
bool tx {!on};
auto start = QDateTime::currentMSecsSinceEpoch ();
// we must now wait for Tx on the rig, we will wait a short while
// before bailing out
while (tx != on && QDateTime::currentMSecsSinceEpoch () - start < 1000)
{
auto reply = command_with_reply ("<command:9>CmdSendTx<parameters:0>");
if (0 == reply.indexOf ("<CmdTX:"))
{
auto state = reply.mid (reply.indexOf ('>') + 1);
if ("ON" == state)
{
tx = true;
}
else if ("OFF" == state)
{
tx = false;
}
else
{
TRACE_CAT ("DXLabSuiteCommanderTransceiver", "unexpected TX state" << state);
throw error {tr ("DX Lab Suite Commander sent an unrecognised TX state: ") + state};
}
}
else
{
TRACE_CAT ("DXLabSuiteCommanderTransceiver", "get TX unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX status: ") + reply};
}
if (tx != on) QThread::msleep (10); // don't thrash Commander
}
update_PTT (tx);
if (tx != on)
{
TRACE_CAT ("DXLabSuiteCommanderTransceiver", "rig failed to respond to PTT: " << on);
throw error {tr ("DX Lab Suite Commander rig did not respond to PTT: ") + (on ? "ON" : "OFF")};
}
}
void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
@ -231,8 +269,8 @@ void DXLabSuiteCommanderTransceiver::poll ()
}
else
{
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "get frequency unexpected response");
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency")};
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "get frequency unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency: ") + reply};
}
if (state ().split ())
@ -252,8 +290,8 @@ void DXLabSuiteCommanderTransceiver::poll ()
}
else
{
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "get tx frequency unexpected response");
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency")};
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "get tx frequency unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency: ") + reply};
}
}
@ -277,8 +315,8 @@ void DXLabSuiteCommanderTransceiver::poll ()
}
else
{
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "get split mode unexpected response");
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling split status")};
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "get split mode unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling split status: ") + reply};
}
get_mode (quiet);
@ -340,8 +378,8 @@ auto DXLabSuiteCommanderTransceiver::get_mode (bool no_debug) -> MODE
}
else
{
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "unexpected response");
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode")};
TRACE_CAT_POLL ("DXLabSuiteCommanderTransceiver", "unexpected response" << reply);
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode: ") + reply};
}
return m;
}