mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
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:
parent
b3f17051e7
commit
2b966c14d1
@ -1740,10 +1740,6 @@ bool Configuration::impl::open_rig ()
|
||||
|
||||
void Configuration::impl::transceiver_frequency (Frequency f)
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "Configuration::transceiver_frequency:" << f;
|
||||
#endif
|
||||
|
||||
if (set_mode () || cached_rig_state_.frequency () != f)
|
||||
{
|
||||
cached_rig_state_.frequency (f);
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
explicit DXLabSuiteCommanderTransceiver (std::unique_ptr<TransceiverBase> wrapped, QString const& address, bool use_for_ptt, int poll_interval);
|
||||
~DXLabSuiteCommanderTransceiver ();
|
||||
|
||||
private:
|
||||
protected:
|
||||
void do_start () override;
|
||||
void do_stop () override;
|
||||
void do_frequency (Frequency) override;
|
||||
@ -38,8 +38,9 @@ private:
|
||||
|
||||
void poll () override;
|
||||
|
||||
void send_command (QByteArray const&, bool no_debug = false);
|
||||
QByteArray read_reply (bool no_debug = false);
|
||||
private:
|
||||
void simple_command (QByteArray const&, bool no_debug = false);
|
||||
QByteArray command_with_reply (QByteArray const&, bool no_debug = false);
|
||||
|
||||
std::unique_ptr<TransceiverBase> wrapped_;
|
||||
bool use_for_ptt_;
|
||||
|
@ -145,14 +145,14 @@ void HRDTransceiver::init_radio ()
|
||||
if (none == protocol_)
|
||||
{
|
||||
try
|
||||
{
|
||||
protocol_ = v5; // try this first (works for v6 too)
|
||||
send_command ("get context", false, false);
|
||||
}
|
||||
{
|
||||
protocol_ = v5; // try this first (works for v6 too)
|
||||
send_command ("get context", false, false);
|
||||
}
|
||||
catch (error const&)
|
||||
{
|
||||
protocol_ = none;
|
||||
}
|
||||
{
|
||||
protocol_ = none;
|
||||
}
|
||||
}
|
||||
|
||||
if (none == protocol_)
|
||||
@ -162,13 +162,13 @@ void HRDTransceiver::init_radio ()
|
||||
protocol_ = v4; // try again with older protocol
|
||||
hrd_->connectToHost (QHostAddress::LocalHost, 7809);
|
||||
if (!hrd_->waitForConnected (socket_wait_time))
|
||||
{
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::init_radio failed to connect:" << hrd_->errorString ();
|
||||
qDebug () << "HRDTransceiver::init_radio failed to connect:" << hrd_->errorString ();
|
||||
#endif
|
||||
|
||||
throw error {"Failed to connect to Ham Radio Deluxe\n" + hrd_->errorString ().toLocal8Bit ()};
|
||||
}
|
||||
throw error {"Failed to connect to Ham Radio Deluxe\n" + hrd_->errorString ().toLocal8Bit ()};
|
||||
}
|
||||
|
||||
send_command ("get context", false, false);
|
||||
}
|
||||
@ -278,16 +278,16 @@ void HRDTransceiver::sync_impl ()
|
||||
auto mo = lookup_mode (get_dropdown (mode_A_dropdown_), mode_A_map_);
|
||||
set_button (vfo_A_button_ >= 0 ? vfo_A_button_ : vfo_toggle_button_);
|
||||
if (f != fo || m != mo)
|
||||
{
|
||||
// we must have started with A/MAIN
|
||||
update_rx_frequency (f);
|
||||
update_mode (m);
|
||||
}
|
||||
{
|
||||
// we must have started with A/MAIN
|
||||
update_rx_frequency (f);
|
||||
update_mode (m);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_rx_frequency (send_command ("get frequency").toUInt ());
|
||||
update_mode (lookup_mode (get_dropdown (mode_A_dropdown_), mode_A_map_));
|
||||
}
|
||||
{
|
||||
update_rx_frequency (send_command ("get frequency").toUInt ());
|
||||
update_mode (lookup_mode (get_dropdown (mode_A_dropdown_), mode_A_map_));
|
||||
}
|
||||
}
|
||||
|
||||
poll ();
|
||||
@ -334,10 +334,10 @@ void HRDTransceiver::map_modes (int dropdown, ModeMap *map)
|
||||
qDebug () << "HRDTransceiver::map_modes: for dropdown" << dropdown_names_[dropdown];
|
||||
|
||||
std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
|
||||
{
|
||||
auto rhs = std::get<1> (item);
|
||||
qDebug () << '\t' << std::get<0> (item) << "<->" << (rhs >= 0 ? dropdowns_[dropdown_names_[dropdown]][rhs] : "None");
|
||||
});
|
||||
{
|
||||
auto rhs = std::get<1> (item);
|
||||
qDebug () << '\t' << std::get<0> (item) << "<->" << (rhs >= 0 ? dropdowns_[dropdown_names_[dropdown]][rhs] : "None");
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -458,48 +458,48 @@ void HRDTransceiver::do_tx_frequency (Frequency tx, bool rationalise_mode)
|
||||
{
|
||||
auto fo_string = QString::number (tx);
|
||||
if (reversed_)
|
||||
{
|
||||
Q_ASSERT (vfo_count_ > 1);
|
||||
{
|
||||
Q_ASSERT (vfo_count_ > 1);
|
||||
|
||||
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts);
|
||||
send_simple_command ("set frequencies-hz " + fo_string + ' ' + QString::number (frequencies[1].toUInt ()));
|
||||
}
|
||||
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts);
|
||||
send_simple_command ("set frequencies-hz " + fo_string + ' ' + QString::number (frequencies[1].toUInt ()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vfo_count_ > 1)
|
||||
{
|
||||
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts);
|
||||
send_simple_command ("set frequencies-hz " + QString::number (frequencies[0].toUInt ()) + ' ' + fo_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we rationalise the modes and VFOs here as well as the frequencies
|
||||
set_button (vfo_B_button_ >= 0 ? vfo_B_button_ : vfo_toggle_button_);
|
||||
send_simple_command ("set frequency-hz " + fo_string);
|
||||
if (rationalise_mode)
|
||||
{
|
||||
set_dropdown (mode_B_dropdown_ >= 0 ? mode_B_dropdown_ : mode_A_dropdown_, lookup_mode (state ().mode (), mode_B_dropdown_ >= 0 ? mode_B_map_ : mode_A_map_));
|
||||
}
|
||||
set_button (vfo_A_button_ >= 0 ? vfo_A_button_ : vfo_toggle_button_);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (vfo_count_ > 1)
|
||||
{
|
||||
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts);
|
||||
send_simple_command ("set frequencies-hz " + QString::number (frequencies[0].toUInt ()) + ' ' + fo_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we rationalise the modes and VFOs here as well as the frequencies
|
||||
set_button (vfo_B_button_ >= 0 ? vfo_B_button_ : vfo_toggle_button_);
|
||||
send_simple_command ("set frequency-hz " + fo_string);
|
||||
if (rationalise_mode)
|
||||
{
|
||||
set_dropdown (mode_B_dropdown_ >= 0 ? mode_B_dropdown_ : mode_A_dropdown_, lookup_mode (state ().mode (), mode_B_dropdown_ >= 0 ? mode_B_map_ : mode_A_map_));
|
||||
}
|
||||
set_button (vfo_A_button_ >= 0 ? vfo_A_button_ : vfo_toggle_button_);
|
||||
}
|
||||
}
|
||||
if (rationalise_mode)
|
||||
{
|
||||
set_dropdown (mode_B_dropdown_ >= 0 ? mode_B_dropdown_ : mode_A_dropdown_, lookup_mode (state ().mode (), mode_B_dropdown_ >= 0 ? mode_B_map_ : mode_A_map_));
|
||||
}
|
||||
{
|
||||
set_dropdown (mode_B_dropdown_ >= 0 ? mode_B_dropdown_ : mode_A_dropdown_, lookup_mode (state ().mode (), mode_B_dropdown_ >= 0 ? mode_B_map_ : mode_A_map_));
|
||||
}
|
||||
}
|
||||
update_other_frequency (tx);
|
||||
|
||||
if (split_mode_button_ >= 0)
|
||||
{
|
||||
if (split_off_button_ >= 0 && !split)
|
||||
{
|
||||
set_button (split_off_button_);
|
||||
}
|
||||
{
|
||||
set_button (split_off_button_);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_button (split_mode_button_, split);
|
||||
}
|
||||
{
|
||||
set_button (split_mode_button_, split);
|
||||
}
|
||||
}
|
||||
else if (split_mode_dropdown_ >= 0)
|
||||
{
|
||||
@ -508,19 +508,19 @@ void HRDTransceiver::do_tx_frequency (Frequency tx, bool rationalise_mode)
|
||||
else if (vfo_A_button_ >= 0 && vfo_B_button_ >= 0 && tx_A_button_ >= 0 && tx_B_button_ >= 0)
|
||||
{
|
||||
if (split)
|
||||
{
|
||||
if (reversed_ != is_button_checked (tx_A_button_))
|
||||
{
|
||||
set_button (reversed_ ? tx_A_button_ : tx_B_button_);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (reversed_ != is_button_checked (tx_A_button_))
|
||||
{
|
||||
set_button (reversed_ ? tx_A_button_ : tx_B_button_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reversed_ != is_button_checked (tx_B_button_))
|
||||
{
|
||||
set_button (reversed_ ? tx_B_button_ : tx_A_button_);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (reversed_ != is_button_checked (tx_B_button_))
|
||||
{
|
||||
set_button (reversed_ ? tx_B_button_ : tx_A_button_);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_split (split);
|
||||
}
|
||||
@ -536,15 +536,15 @@ void HRDTransceiver::do_mode (MODE mode, bool rationalise)
|
||||
if (rationalise && state ().split ()) // rationalise mode if split
|
||||
{
|
||||
if (mode_B_dropdown_ >= 0)
|
||||
{
|
||||
set_dropdown (mode_B_dropdown_, lookup_mode (mode, mode_B_map_));
|
||||
}
|
||||
{
|
||||
set_dropdown (mode_B_dropdown_, lookup_mode (mode, mode_B_map_));
|
||||
}
|
||||
else if (vfo_count_ < 2)
|
||||
{
|
||||
set_button (vfo_B_button_ >= 0 ? vfo_B_button_ : vfo_toggle_button_);
|
||||
set_dropdown (mode_B_dropdown_ >= 0 ? mode_B_dropdown_ : mode_A_dropdown_, lookup_mode (mode, mode_B_dropdown_ >= 0 ? mode_B_map_ : mode_A_map_));
|
||||
set_button (vfo_A_button_ >= 0 ? vfo_A_button_ : vfo_toggle_button_);
|
||||
}
|
||||
{
|
||||
set_button (vfo_B_button_ >= 0 ? vfo_B_button_ : vfo_toggle_button_);
|
||||
set_dropdown (mode_B_dropdown_ >= 0 ? mode_B_dropdown_ : mode_A_dropdown_, lookup_mode (mode, mode_B_dropdown_ >= 0 ? mode_B_map_ : mode_A_map_));
|
||||
set_button (vfo_A_button_ >= 0 ? vfo_A_button_ : vfo_toggle_button_);
|
||||
}
|
||||
}
|
||||
|
||||
update_mode (mode);
|
||||
@ -554,13 +554,13 @@ bool HRDTransceiver::is_button_checked (int button_index, bool no_debug)
|
||||
{
|
||||
auto reply = send_command ("get button-select " + buttons_.value (button_index), no_debug);
|
||||
if ("1" != reply && "0" != reply)
|
||||
{
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::is_button_checked bad response";
|
||||
qDebug () << "HRDTransceiver::is_button_checked bad response";
|
||||
#endif
|
||||
|
||||
throw error {"Ham Radio Deluxe didn't respond as expected"};
|
||||
}
|
||||
throw error {"Ham Radio Deluxe didn't respond as expected"};
|
||||
}
|
||||
return "1" == reply;
|
||||
}
|
||||
|
||||
@ -583,18 +583,18 @@ void HRDTransceiver::poll ()
|
||||
else if (split_mode_dropdown_ >= 0)
|
||||
{
|
||||
if (!split_mode_dropdown_write_only_)
|
||||
{
|
||||
try
|
||||
{
|
||||
update_split (get_dropdown (split_mode_dropdown_, quiet) == split_mode_dropdown_selection_on_);
|
||||
}
|
||||
catch (error const&)
|
||||
{
|
||||
// leave split alone as we can't query it - it should be
|
||||
// correct so long as rig or HRD haven't been changed
|
||||
split_mode_dropdown_write_only_ = true;
|
||||
}
|
||||
}
|
||||
{
|
||||
try
|
||||
{
|
||||
update_split (get_dropdown (split_mode_dropdown_, quiet) == split_mode_dropdown_selection_on_);
|
||||
}
|
||||
catch (error const&)
|
||||
{
|
||||
// leave split alone as we can't query it - it should be
|
||||
// correct so long as rig or HRD haven't been changed
|
||||
split_mode_dropdown_write_only_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (vfo_A_button_ >= 0 && vfo_B_button_ >= 0 && tx_A_button_ >= 0 && tx_B_button_ >= 0)
|
||||
{
|
||||
@ -627,9 +627,8 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
||||
|
||||
if (current_radio_ && prepend_context && vfo_count_ < 2)
|
||||
{
|
||||
// TODO G4WJS: get rid of this or move to a thread required on some
|
||||
// radios because commands don't get executed correctly (ICOM for
|
||||
// example)
|
||||
// required on some radios because commands don't get executed
|
||||
// correctly otherwise (ICOM for example)
|
||||
QThread::msleep (50);
|
||||
}
|
||||
|
||||
@ -646,22 +645,22 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
||||
{
|
||||
auto radio_name = send_command ("get radio", no_debug, current_radio_, true);
|
||||
auto radio_iter = std::find_if (radios_.begin (), radios_.end (), [this, &radio_name] (RadioMap::value_type const& radio)
|
||||
{
|
||||
return std::get<1> (radio) == radio_name;
|
||||
});
|
||||
{
|
||||
return std::get<1> (radio) == radio_name;
|
||||
});
|
||||
if (radio_iter == radios_.end ())
|
||||
{
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command rig disappeared or changed";
|
||||
qDebug () << "HRDTransceiver::send_command rig disappeared or changed";
|
||||
#endif
|
||||
|
||||
throw error {"Ham Radio Deluxe: rig has disappeared or changed"};
|
||||
}
|
||||
throw error {"Ham Radio Deluxe: rig has disappeared or changed"};
|
||||
}
|
||||
|
||||
if (0u == current_radio_ || std::get<0> (*radio_iter) != current_radio_)
|
||||
{
|
||||
current_radio_ = std::get<0> (*radio_iter);
|
||||
}
|
||||
{
|
||||
current_radio_ = std::get<0> (*radio_iter);
|
||||
}
|
||||
}
|
||||
|
||||
auto context = '[' + QString::number (current_radio_) + "] ";
|
||||
@ -675,22 +674,15 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
||||
bytes_sent = hrd_->write (message.data (), bytes_to_send);
|
||||
|
||||
if (!no_debug)
|
||||
{
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command:" << message;
|
||||
qDebug () << "HRDTransceiver::send_command:" << message;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto string = prepend_context ? context + cmd : cmd;
|
||||
if (!no_debug)
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command:" << string;
|
||||
#endif
|
||||
}
|
||||
|
||||
QScopedPointer<HRDMessage> message (new (string) HRDMessage);
|
||||
bytes_to_send = message->size_;
|
||||
bytes_sent = hrd_->write (reinterpret_cast<char *> (message.data ()), bytes_to_send);
|
||||
@ -732,13 +724,13 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
||||
HRDMessage const * reply (new (buffer) HRDMessage);
|
||||
|
||||
if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_)
|
||||
{
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command invalid reply";
|
||||
qDebug () << "HRDTransceiver::send_command invalid reply";
|
||||
#endif
|
||||
|
||||
throw error {"Ham Radio Deluxe sent an invalid reply to our command"};
|
||||
}
|
||||
throw error {"Ham Radio Deluxe sent an invalid reply to our command"};
|
||||
}
|
||||
|
||||
result = QString {reply->payload_}; // this is not a memory leak (honest!)
|
||||
}
|
||||
@ -746,7 +738,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool no_debug, bool pr
|
||||
if (!no_debug)
|
||||
{
|
||||
#if WSJT_TRACE_CAT
|
||||
qDebug () << "HRDTransceiver::send_command: reply: " << result;
|
||||
qDebug () << "HRDTransceiver::send_command(" << cmd << "): ->" << result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
explicit HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped, QString const& server, bool use_for_ptt, int poll_interval);
|
||||
~HRDTransceiver ();
|
||||
|
||||
private:
|
||||
protected:
|
||||
void do_start () override;
|
||||
void do_stop () override;
|
||||
void do_frequency (Frequency) override;
|
||||
@ -43,6 +43,7 @@ private:
|
||||
|
||||
void poll () override;
|
||||
|
||||
private:
|
||||
void init_radio ();
|
||||
QString send_command (QString const&, bool no_debug = false, bool prepend_context = true, bool recurse = false);
|
||||
void send_simple_command (QString const&, bool no_debug = false);
|
||||
|
Loading…
Reference in New Issue
Block a user