Igonored CAT polls of RX frequency from Commander when transmitting as

they are unreliable on Icom radios.

Simplified diagnostic output for HRD CAT interface and DX Labs Suite
Commander CAT interface.

Removed duplicate diagnostic message from configuration CAT control.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3983 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville
2014-04-04 17:02:18 +00:00
parent badcdd563d
commit 3ddf0d64d3
5 changed files with 210 additions and 202 deletions
+92 -74
View File
@@ -25,7 +25,7 @@ namespace
case Transceiver::DIG_U: return "DATA-U";
case Transceiver::FM:
case Transceiver::DIG_FM:
return "FM";
return "FM";
default: break;
}
return "USB";
@@ -101,7 +101,7 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
if (use_for_ptt_)
{
send_command (on ? "<command:5>CmdTX<parameters:0>" : "<command:5>CmdRX<parameters:0>");
simple_command (on ? "<command:5>CmdTX<parameters:0>" : "<command:5>CmdRX<parameters:0>");
}
else
{
@@ -109,6 +109,8 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
}
update_PTT (on);
do_frequency (state ().frequency ()); // gets Commander synchronized
}
void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f)
@@ -119,7 +121,7 @@ void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f)
// number is localised
// avoid floating point translation errors by adding a small number (0.1Hz)
send_command ("<command:10>CmdSetFreq<parameters:23><xcvrfreq:10>" + QString ("%L1").arg (f / 1e3 + 1e-4, 10, 'f', 3).toLocal8Bit ());
simple_command ("<command:10>CmdSetFreq<parameters:23><xcvrfreq:10>" + QString ("%L1").arg (f / 1e3 + 1e-4, 10, 'f', 3).toLocal8Bit ());
update_rx_frequency (f);
}
@@ -131,7 +133,7 @@ void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, bool /* rati
if (tx)
{
send_command ("<command:8>CmdSplit<parameters:7><1:2>on");
simple_command ("<command:8>CmdSplit<parameters:7><1:2>on");
update_split (true);
// number is localised
@@ -140,13 +142,15 @@ void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, bool /* rati
// set TX frequency after going split because going split
// rationalises TX VFO mode and that can change the frequency on
// Yaesu rigs if CW is involved
send_command ("<command:12>CmdSetTxFreq<parameters:23><xcvrfreq:10>" + QString ("%L1").arg (tx / 1e3 + 1e-4, 10, 'f', 3).toLocal8Bit ());
simple_command ("<command:12>CmdSetTxFreq<parameters:23><xcvrfreq:10>" + QString ("%L1").arg (tx / 1e3 + 1e-4, 10, 'f', 3).toLocal8Bit ());
}
else
{
send_command ("<command:8>CmdSplit<parameters:8><1:3>off");
simple_command ("<command:8>CmdSplit<parameters:8><1:3>off");
}
update_other_frequency (tx);
do_frequency (state ().frequency ()); // gets Commander synchronized
}
void DXLabSuiteCommanderTransceiver::do_mode (MODE mode, bool /* rationalise */)
@@ -156,15 +160,17 @@ void DXLabSuiteCommanderTransceiver::do_mode (MODE mode, bool /* rationalise */)
#endif
auto mapped = map_mode (mode);
send_command ((QString ("<command:10>CmdSetMode<parameters:%1><1:%2>").arg (5 + mapped.size ()).arg (mapped.size ()) + mapped).toLocal8Bit ());
simple_command ((QString ("<command:10>CmdSetMode<parameters:%1><1:%2>").arg (5 + mapped.size ()).arg (mapped.size ()) + mapped).toLocal8Bit ());
if (state ().split ())
{
// this toggle ensures that the TX VFO mode is the same as the RX VFO
send_command ("<command:8>CmdSplit<parameters:8><1:3>off");
send_command ("<command:8>CmdSplit<parameters:7><1:2>on");
simple_command ("<command:8>CmdSplit<parameters:8><1:3>off");
simple_command ("<command:8>CmdSplit<parameters:7><1:2>on");
}
do_frequency (state ().frequency ()); // gets Commander synchronized
// setting TX frequency rationalises the mode on Icoms so get current and set
poll ();
}
@@ -177,13 +183,18 @@ void DXLabSuiteCommanderTransceiver::poll ()
bool quiet {true};
#endif
send_command ("<command:11>CmdSendFreq<parameters:0>", quiet);
auto reply = read_reply (quiet);
auto reply = command_with_reply ("<command:11>CmdSendFreq<parameters:0>", quiet);
if (0 == reply.indexOf ("<CmdFreq:"))
{
// remove thousands separator and DP - relies of n.nnn kHz format so we can do uint conversion
// remove thousands separator and DP - relies of n.nnn kHz
// format so we can do uint conversion
reply = reply.mid (reply.indexOf ('>') + 1).replace (",", "").replace (".", "");
update_rx_frequency (reply.toUInt ());
if (!state ().ptt ()) // Commander is not reliable on frequency
// polls while transmitting
{
update_rx_frequency (reply.toUInt ());
}
}
else
{
@@ -194,16 +205,15 @@ void DXLabSuiteCommanderTransceiver::poll ()
throw error {"DX Lab Suite Commander didn't respond correctly polling frequency"};
}
send_command ("<command:13>CmdSendTXFreq<parameters:0>", quiet);
reply = read_reply (quiet);
reply = command_with_reply ("<command:13>CmdSendTXFreq<parameters:0>", quiet);
if (0 == reply.indexOf ("<CmdTXFreq:"))
{
// remove thousands separator and DP - relies of n.nnn kHz format so we ca do uint conversion
auto text = reply.mid (reply.indexOf ('>') + 1).replace (",", "").replace (".", "");
if ("000" != text)
{
update_other_frequency (text.toUInt ());
}
{
update_other_frequency (text.toUInt ());
}
}
else
{
@@ -214,27 +224,26 @@ void DXLabSuiteCommanderTransceiver::poll ()
throw error {"DX Lab Suite Commander didn't respond correctly polling TX frequency"};
}
send_command ("<command:12>CmdSendSplit<parameters:0>", quiet);
reply = read_reply (quiet);
reply = command_with_reply ("<command:12>CmdSendSplit<parameters:0>", quiet);
if (0 == reply.indexOf ("<CmdSplit:"))
{
auto split = reply.mid (reply.indexOf ('>') + 1);
if ("ON" == split)
{
update_split (true);
}
{
update_split (true);
}
else if ("OFF" == split)
{
update_split (false);
}
{
update_split (false);
}
else
{
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::poll: unexpected split state" << split;
qDebug () << "DXLabSuiteCommanderTransceiver::poll: unexpected split state" << split;
#endif
throw error {"DX Lab Suite Commander sent an unrecognised split state: " + split};
}
throw error {"DX Lab Suite Commander sent an unrecognised split state: " + split};
}
}
else
{
@@ -245,60 +254,59 @@ void DXLabSuiteCommanderTransceiver::poll ()
throw error {"DX Lab Suite Commander didn't respond correctly polling split status"};
}
send_command ("<command:11>CmdSendMode<parameters:0>", quiet);
reply = read_reply (quiet);
reply = command_with_reply ("<command:11>CmdSendMode<parameters:0>", quiet);
if (0 == reply.indexOf ("<CmdMode:"))
{
auto mode = reply.mid (reply.indexOf ('>') + 1);
MODE m {UNK};
if ("AM" == mode)
{
m = AM;
}
{
m = AM;
}
else if ("CW" == mode)
{
m = CW;
}
{
m = CW;
}
else if ("CW-R" == mode)
{
m = CW_R;
}
{
m = CW_R;
}
else if ("FM" == mode || "WBFM" == mode)
{
m = FM;
}
{
m = FM;
}
else if ("LSB" == mode)
{
m = LSB;
}
{
m = LSB;
}
else if ("USB" == mode)
{
m = USB;
}
{
m = USB;
}
else if ("RTTY" == mode)
{
m = FSK;
}
{
m = FSK;
}
else if ("RTTY-R" == mode)
{
m = FSK_R;
}
{
m = FSK_R;
}
else if ("PKT" == mode || "DATA-L" == mode || "Data-L" == mode)
{
m = DIG_L;
}
{
m = DIG_L;
}
else if ("PKT-R" == mode || "DATA-U" == mode || "Data-U" == mode)
{
m = DIG_U;
}
{
m = DIG_U;
}
else
{
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::poll: unexpected mode name" << mode;
qDebug () << "DXLabSuiteCommanderTransceiver::poll: unexpected mode name" << mode;
#endif
throw error {"DX Lab Suite Commander sent an unrecognised mode: " + mode};
}
throw error {"DX Lab Suite Commander sent an unrecognised mode: " + mode};
}
update_mode (m);
}
else
@@ -311,21 +319,21 @@ void DXLabSuiteCommanderTransceiver::poll ()
}
}
void DXLabSuiteCommanderTransceiver::send_command (QByteArray const& cmd, bool no_debug)
void DXLabSuiteCommanderTransceiver::simple_command (QByteArray const& cmd, bool no_debug)
{
Q_ASSERT (commander_);
if (!no_debug)
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver:send_command(" << cmd << ')';
qDebug () << "DXLabSuiteCommanderTransceiver:simple_command(" << cmd << ')';
#endif
}
if (QTcpSocket::ConnectedState != commander_->state ())
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::send_command failed:" << commander_->errorString ();
qDebug () << "DXLabSuiteCommanderTransceiver::simple_command failed:" << commander_->errorString ();
#endif
throw error {"DX Lab Suite Commander send command failed\n" + commander_->errorString ().toLocal8Bit ()};
@@ -335,30 +343,40 @@ void DXLabSuiteCommanderTransceiver::send_command (QByteArray const& cmd, bool n
if (!commander_->waitForBytesWritten (socket_wait_time))
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::send_command failed:" << commander_->errorString ();
qDebug () << "DXLabSuiteCommanderTransceiver::simple_command failed:" << commander_->errorString ();
#endif
throw error {"DX Lab Suite Commander send command failed\n" + commander_->errorString ().toLocal8Bit ()};
}
}
QByteArray DXLabSuiteCommanderTransceiver::read_reply (bool no_debug)
QByteArray DXLabSuiteCommanderTransceiver::command_with_reply (QByteArray const& cmd, bool no_debug)
{
Q_ASSERT (commander_);
if (QTcpSocket::ConnectedState != commander_->state ())
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::read_reply failed:" << commander_->errorString ();
qDebug () << "DXLabSuiteCommanderTransceiver::command_with_reply failed:" << commander_->errorString ();
#endif
throw error {"DX Lab Suite Commander read reply failed\n" + commander_->errorString ().toLocal8Bit ()};
}
commander_->write (cmd);
if (!commander_->waitForBytesWritten (socket_wait_time) || QTcpSocket::ConnectedState != commander_->state ())
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::simple_command failed:" << commander_->errorString ();
#endif
throw error {"DX Lab Suite Commander send command failed\n" + commander_->errorString ().toLocal8Bit ()};
}
if (!commander_->waitForReadyRead (socket_wait_time))
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver::read_reply failed:" << commander_->errorString ();
qDebug () << "DXLabSuiteCommanderTransceiver::command_with_reply failed:" << commander_->errorString ();
#endif
throw error {"DX Lab Suite Commander read reply failed\n" + commander_->errorString ().toLocal8Bit ()};
@@ -369,7 +387,7 @@ QByteArray DXLabSuiteCommanderTransceiver::read_reply (bool no_debug)
if (!no_debug)
{
#if WSJT_TRACE_CAT
qDebug () << "DXLabSuiteCommanderTransceiver:read_reply() ->" << result;
qDebug () << "DXLabSuiteCommanderTransceiver:command_with_reply(" << cmd << ") ->" << result;
#endif
}