Make use of different severities for rig control logging

This commit is contained in:
Bill Somerville 2020-09-26 14:56:37 +01:00
parent 1d43ddd38b
commit 396f128ece
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
7 changed files with 189 additions and 185 deletions

View File

@ -2752,7 +2752,7 @@ void Configuration::impl::handle_transceiver_update (TransceiverState const& sta
void Configuration::impl::handle_transceiver_failure (QString const& reason) void Configuration::impl::handle_transceiver_failure (QString const& reason)
{ {
LOG_TRACE ("handle_transceiver_failure: reason: " << reason.toStdWString ()); LOG_ERROR ("handle_transceiver_failure: reason: " << reason.toStdWString ());
close_rig (); close_rig ();
ui_->test_PTT_push_button->setChecked (false); ui_->test_PTT_push_button->setChecked (false);

View File

@ -58,7 +58,7 @@ DXLabSuiteCommanderTransceiver::DXLabSuiteCommanderTransceiver (logger_type * lo
int DXLabSuiteCommanderTransceiver::do_start () int DXLabSuiteCommanderTransceiver::do_start ()
{ {
TRACE_CAT ("starting"); CAT_TRACE ("starting");
if (wrapped_) wrapped_->start (0); if (wrapped_) wrapped_->start (0);
auto server_details = network_server_lookup (server_, 52002u, QHostAddress::LocalHost, QAbstractSocket::IPv4Protocol); auto server_details = network_server_lookup (server_, 52002u, QHostAddress::LocalHost, QAbstractSocket::IPv4Protocol);
@ -71,7 +71,7 @@ int DXLabSuiteCommanderTransceiver::do_start ()
commander_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); commander_->connectToHost (std::get<0> (server_details), std::get<1> (server_details));
if (!commander_->waitForConnected ()) if (!commander_->waitForConnected ())
{ {
TRACE_CAT ("failed to connect" << commander_->errorString ().toStdWString ()); CAT_ERROR ("failed to connect" << commander_->errorString ().toStdWString ());
throw error {tr ("Failed to connect to DX Lab Suite Commander\n") + commander_->errorString ()}; throw error {tr ("Failed to connect to DX Lab Suite Commander\n") + commander_->errorString ()};
} }
@ -127,7 +127,7 @@ int DXLabSuiteCommanderTransceiver::do_start ()
} }
else else
{ {
TRACE_CAT ("get frequency unexpected response" << reply.toStdWString ()); CAT_ERROR ("get frequency unexpected response" << reply.toStdWString ());
throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency: ") + reply};
} }
@ -144,12 +144,12 @@ void DXLabSuiteCommanderTransceiver::do_stop ()
} }
if (wrapped_) wrapped_->stop (); if (wrapped_) wrapped_->stop ();
TRACE_CAT ("stopped"); CAT_TRACE ("stopped");
} }
void DXLabSuiteCommanderTransceiver::do_ptt (bool on) void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
{ {
TRACE_CAT (on << state ()); CAT_TRACE (on << state ());
if (use_for_ptt_) if (use_for_ptt_)
{ {
simple_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>");
@ -174,13 +174,13 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
} }
else else
{ {
TRACE_CAT ("unexpected TX state" << state.toStdWString ()); CAT_ERROR ("unexpected TX state" << state.toStdWString ());
throw error {tr ("DX Lab Suite Commander sent an unrecognised TX state: ") + state}; throw error {tr ("DX Lab Suite Commander sent an unrecognised TX state: ") + state};
} }
} }
else else
{ {
TRACE_CAT ("get TX unexpected response" << reply.toStdWString ()); CAT_ERROR ("get TX unexpected response" << reply.toStdWString ());
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX status: ") + 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 if (tx != on) QThread::msleep (10); // don't thrash Commander
@ -188,7 +188,7 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
update_PTT (tx); update_PTT (tx);
if (tx != on) if (tx != on)
{ {
TRACE_CAT ("rig failed to respond to PTT: " << on); CAT_ERROR ("rig failed to respond to PTT: " << on);
throw error {tr ("DX Lab Suite Commander rig did not respond to PTT: ") + (on ? "ON" : "OFF")}; throw error {tr ("DX Lab Suite Commander rig did not respond to PTT: ") + (on ? "ON" : "OFF")};
} }
} }
@ -204,7 +204,7 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/) void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
{ {
TRACE_CAT (f << state ()); CAT_TRACE (f << state ());
auto f_string = frequency_to_string (f); auto f_string = frequency_to_string (f);
if (UNK != m && m != get_mode ()) if (UNK != m && m != get_mode ())
{ {
@ -223,7 +223,7 @@ void DXLabSuiteCommanderTransceiver::do_frequency (Frequency f, MODE m, bool /*n
void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*/) void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*/)
{ {
TRACE_CAT (tx << state ()); CAT_TRACE (tx << state ());
if (tx) if (tx)
{ {
auto f_string = frequency_to_string (tx); auto f_string = frequency_to_string (tx);
@ -244,7 +244,7 @@ void DXLabSuiteCommanderTransceiver::do_tx_frequency (Frequency tx, MODE mode, b
void DXLabSuiteCommanderTransceiver::do_mode (MODE m) void DXLabSuiteCommanderTransceiver::do_mode (MODE m)
{ {
TRACE_CAT (m << state ()); CAT_TRACE (m << state ());
auto m_string = map_mode (m); auto m_string = map_mode (m);
auto params = ("<1:%1>" + m_string).arg (m_string.size ()); auto params = ("<1:%1>" + m_string).arg (m_string.size ());
simple_command (("<command:10>CmdSetMode<parameters:%1>" + params).arg (params.size ())); simple_command (("<command:10>CmdSetMode<parameters:%1>" + params).arg (params.size ()));
@ -268,7 +268,7 @@ void DXLabSuiteCommanderTransceiver::do_poll ()
} }
else else
{ {
TRACE_CAT_POLL ("get frequency unexpected response" << reply.toStdWString ()); CAT_ERROR ("get frequency unexpected response" << reply.toStdWString ());
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling frequency: ") + reply};
} }
@ -289,7 +289,7 @@ void DXLabSuiteCommanderTransceiver::do_poll ()
} }
else else
{ {
TRACE_CAT_POLL ("get tx frequency unexpected response" << reply.toStdWString ()); CAT_ERROR ("get tx frequency unexpected response" << reply.toStdWString ());
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling TX frequency: ") + reply};
} }
} }
@ -308,13 +308,13 @@ void DXLabSuiteCommanderTransceiver::do_poll ()
} }
else else
{ {
TRACE_CAT_POLL ("unexpected split state" << split.toStdWString ()); CAT_ERROR ("unexpected split state" << split.toStdWString ());
throw error {tr ("DX Lab Suite Commander sent an unrecognised split state: ") + split}; throw error {tr ("DX Lab Suite Commander sent an unrecognised split state: ") + split};
} }
} }
else else
{ {
TRACE_CAT_POLL ("get split mode unexpected response" << reply.toStdWString ()); CAT_ERROR ("get split mode unexpected response" << reply.toStdWString ());
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling split status: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling split status: ") + reply};
} }
@ -370,14 +370,14 @@ auto DXLabSuiteCommanderTransceiver::get_mode () -> MODE
} }
else else
{ {
TRACE_CAT_POLL ("unexpected mode name" << mode.toStdWString ()); CAT_ERROR ("unexpected mode name" << mode.toStdWString ());
throw error {tr ("DX Lab Suite Commander sent an unrecognised mode: \"") + mode + '"'}; throw error {tr ("DX Lab Suite Commander sent an unrecognised mode: \"") + mode + '"'};
} }
update_mode (m); update_mode (m);
} }
else else
{ {
TRACE_CAT_POLL ("unexpected response" << reply.toStdWString ()); CAT_ERROR ("unexpected response" << reply.toStdWString ());
throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode: ") + reply}; throw error {tr ("DX Lab Suite Commander didn't respond correctly polling mode: ") + reply};
} }
return m; return m;
@ -387,11 +387,11 @@ void DXLabSuiteCommanderTransceiver::simple_command (QString const& cmd)
{ {
Q_ASSERT (commander_); Q_ASSERT (commander_);
TRACE_CAT (cmd.toStdWString ()); CAT_TRACE (cmd.toStdWString ());
if (!write_to_port (cmd)) if (!write_to_port (cmd))
{ {
TRACE_CAT ("failed:" << commander_->errorString ().toStdWString ()); CAT_ERROR ("failed:" << commander_->errorString ().toStdWString ());
throw error {tr ("DX Lab Suite Commander send command failed\n") + commander_->errorString ()}; throw error {tr ("DX Lab Suite Commander send command failed\n") + commander_->errorString ()};
} }
} }
@ -402,7 +402,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
if (!write_to_port (cmd)) if (!write_to_port (cmd))
{ {
TRACE_CAT ("failed to send command:" << commander_->errorString ().toStdWString ()); CAT_ERROR ("failed to send command:" << commander_->errorString ().toStdWString ());
throw error { throw error {
tr ("DX Lab Suite Commander send command failed \"%1\": %2\n") tr ("DX Lab Suite Commander send command failed \"%1\": %2\n")
.arg (cmd) .arg (cmd)
@ -419,7 +419,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
replied = commander_->waitForReadyRead (); replied = commander_->waitForReadyRead ();
if (!replied && commander_->error () != commander_->SocketTimeoutError) if (!replied && commander_->error () != commander_->SocketTimeoutError)
{ {
TRACE_CAT (cmd.toStdWString () << "failed to read reply:" << commander_->errorString ().toStdWString ()); CAT_ERROR (cmd.toStdWString () << "failed to read reply:" << commander_->errorString ().toStdWString ());
throw error { throw error {
tr ("DX Lab Suite Commander send command \"%1\" read reply failed: %2\n") tr ("DX Lab Suite Commander send command \"%1\" read reply failed: %2\n")
.arg (cmd) .arg (cmd)
@ -430,7 +430,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
if (!replied) if (!replied)
{ {
TRACE_CAT (cmd.toStdWString () << "retries exhausted"); CAT_ERROR (cmd.toStdWString () << "retries exhausted");
throw error { throw error {
tr ("DX Lab Suite Commander retries exhausted sending command \"%1\"") tr ("DX Lab Suite Commander retries exhausted sending command \"%1\"")
.arg (cmd) .arg (cmd)
@ -444,7 +444,7 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
// qDebug () << i << ":" << hex << int (result[i]); // qDebug () << i << ":" << hex << int (result[i]);
// } // }
TRACE_CAT (cmd.toStdWString () << "->" << QString {result}.toStdWString ()); CAT_TRACE (cmd.toStdWString () << "->" << QString {result}.toStdWString ());
return result; // converting raw UTF-8 bytes to QString return result; // converting raw UTF-8 bytes to QString
} }

View File

@ -114,7 +114,7 @@ HRDTransceiver::HRDTransceiver (logger_type * logger
int HRDTransceiver::do_start () int HRDTransceiver::do_start ()
{ {
TRACE_CAT ("starting"); CAT_TRACE ("starting");
if (wrapped_) wrapped_->start (0); if (wrapped_) wrapped_->start (0);
auto server_details = network_server_lookup (server_, 7809u); auto server_details = network_server_lookup (server_, 7809u);
@ -125,7 +125,7 @@ int HRDTransceiver::do_start ()
hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details));
if (!hrd_->waitForConnected ()) if (!hrd_->waitForConnected ())
{ {
TRACE_CAT ("failed to connect:" << hrd_->errorString ().toStdWString ()); CAT_ERROR ("failed to connect:" << hrd_->errorString ().toStdWString ());
throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()}; throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()};
} }
@ -150,7 +150,7 @@ int HRDTransceiver::do_start ()
hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details)); hrd_->connectToHost (std::get<0> (server_details), std::get<1> (server_details));
if (!hrd_->waitForConnected ()) if (!hrd_->waitForConnected ())
{ {
TRACE_CAT ("failed to connect:" << hrd_->errorString ().toStdWString ()); CAT_ERROR ("failed to connect:" << hrd_->errorString ().toStdWString ());
throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()}; throw error {tr ("Failed to connect to Ham Radio Deluxe\n") + hrd_->errorString ()};
} }
@ -167,14 +167,14 @@ int HRDTransceiver::do_start ()
auto id = send_command ("get id", false, false); auto id = send_command ("get id", false, false);
auto version = send_command ("get version", false, false); auto version = send_command ("get version", false, false);
TRACE_CAT ("Id:" << id.toStdWString () << "Version:" << version.toStdWString ()); CAT_INFO ("Id: " << id.toStdWString () << "Version: " << version.toStdWString ());
HRD_info << "Id: " << id << "\n"; HRD_info << "Id: " << id << "\n";
HRD_info << "Version: " << version << "\n"; HRD_info << "Version: " << version << "\n";
auto radios = send_command ("get radios", false, false).trimmed ().split (',', SkipEmptyParts); auto radios = send_command ("get radios", false, false).trimmed ().split (',', SkipEmptyParts);
if (radios.isEmpty ()) if (radios.isEmpty ())
{ {
TRACE_CAT ("no rig found"); CAT_ERROR ("no rig found");
throw error {tr ("Ham Radio Deluxe: no rig found")}; throw error {tr ("Ham Radio Deluxe: no rig found")};
} }
@ -186,46 +186,46 @@ int HRDTransceiver::do_start ()
radios_.push_back (std::forward_as_tuple (entries[0].toUInt (), entries[1])); radios_.push_back (std::forward_as_tuple (entries[0].toUInt (), entries[1]));
} }
TRACE_CAT ("radios:-"); CAT_TRACE ("radios:-");
Q_FOREACH (auto const& radio, radios_) Q_FOREACH (auto const& radio, radios_)
{ {
TRACE_CAT ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio).toStdWString ()); CAT_TRACE ("\t[" << std::get<0> (radio) << "] " << std::get<1> (radio).toStdWString ());
} }
auto current_radio_name = send_command ("get radio", false, false); auto current_radio_name = send_command ("get radio", false, false);
HRD_info << "Current radio: " << current_radio_name << "\n"; HRD_info << "Current radio: " << current_radio_name << "\n";
if (current_radio_name.isEmpty ()) if (current_radio_name.isEmpty ())
{ {
TRACE_CAT ("no rig found"); CAT_ERROR ("no rig found");
throw error {tr ("Ham Radio Deluxe: no rig found")}; throw error {tr ("Ham Radio Deluxe: no rig found")};
} }
vfo_count_ = send_command ("get vfo-count").toUInt (); vfo_count_ = send_command ("get vfo-count").toUInt ();
HRD_info << "VFO count: " << vfo_count_ << "\n"; HRD_info << "VFO count: " << vfo_count_ << "\n";
TRACE_CAT ("vfo count:" << vfo_count_); CAT_TRACE ("vfo count:" << vfo_count_);
buttons_ = send_command ("get buttons").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~"); buttons_ = send_command ("get buttons").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~");
TRACE_CAT ("HRD Buttons: " << buttons_.join (", ").toStdWString ()); CAT_TRACE ("HRD Buttons: " << buttons_.join (", ").toStdWString ());
HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n"; HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n";
dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', SkipEmptyParts); dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', SkipEmptyParts);
TRACE_CAT ("Dropdowns:"); CAT_TRACE ("Dropdowns:");
HRD_info << "Dropdowns:\n"; HRD_info << "Dropdowns:\n";
Q_FOREACH (auto const& dd, dropdown_names_) Q_FOREACH (auto const& dd, dropdown_names_)
{ {
auto selections = send_command ("get dropdown-list {" + dd + "}").trimmed ().split (','); auto selections = send_command ("get dropdown-list {" + dd + "}").trimmed ().split (',');
TRACE_CAT ("\t" << dd.toStdWString () << ": {" << selections.join (", ").toStdWString () << "}"); CAT_TRACE ("\t" << dd.toStdWString () << ": {" << selections.join (", ").toStdWString () << "}");
HRD_info << "\t" << dd << ": {" << selections.join (", ") << "}\n"; HRD_info << "\t" << dd << ": {" << selections.join (", ") << "}\n";
dropdowns_[dd] = selections; dropdowns_[dd] = selections;
} }
slider_names_ = send_command ("get sliders").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~"); slider_names_ = send_command ("get sliders").trimmed ().split (',', SkipEmptyParts).replaceInStrings (" ", "~");
TRACE_CAT ("Sliders:-"); CAT_TRACE ("Sliders:-");
HRD_info << "Sliders:\n"; HRD_info << "Sliders:\n";
Q_FOREACH (auto const& s, slider_names_) Q_FOREACH (auto const& s, slider_names_)
{ {
auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', SkipEmptyParts); auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', SkipEmptyParts);
TRACE_CAT ("\t" << s.toStdWString () << ": {" << range.join (", ").toStdWString () << "}"); CAT_TRACE ("\t" << s.toStdWString () << ": {" << range.join (", ").toStdWString () << "}");
HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n"; HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n";
sliders_[s] = range; sliders_[s] = range;
} }
@ -359,7 +359,7 @@ void HRDTransceiver::do_stop ()
} }
if (wrapped_) wrapped_->stop (); if (wrapped_) wrapped_->stop ();
TRACE_CAT ("stopped" << state () << "reversed" << reversed_); CAT_TRACE ("stopped" << state () << "reversed" << reversed_);
} }
int HRDTransceiver::find_button (QRegExp const& re) const int HRDTransceiver::find_button (QRegExp const& re) const
@ -406,11 +406,11 @@ void HRDTransceiver::map_modes (int dropdown, ModeMap *map)
map->push_back (std::forward_as_tuple (FM, find_dropdown_selection (dropdown, QRegExp ("^(FM|FM\\(N\\)|FM-N|WFM)$")))); map->push_back (std::forward_as_tuple (FM, find_dropdown_selection (dropdown, QRegExp ("^(FM|FM\\(N\\)|FM-N|WFM)$"))));
map->push_back (std::forward_as_tuple (DIG_FM, find_dropdown_selection (dropdown, QRegExp ("^(PKT-FM|PKT|DATA\\(FM\\)|FM)$")))); map->push_back (std::forward_as_tuple (DIG_FM, find_dropdown_selection (dropdown, QRegExp ("^(PKT-FM|PKT|DATA\\(FM\\)|FM)$"))));
TRACE_CAT ("for dropdown" << dropdown_names_[dropdown].toStdWString ()); CAT_TRACE ("for dropdown" << dropdown_names_[dropdown].toStdWString ());
std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item) std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
{ {
auto const& rhs = std::get<1> (item); auto const& rhs = std::get<1> (item);
TRACE_CAT ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()].toStdWString () : L"None")); CAT_TRACE ('\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()].toStdWString () : L"None"));
}); });
} }
@ -472,14 +472,14 @@ void HRDTransceiver::set_dropdown (int dd, int value)
} }
else else
{ {
TRACE_CAT ("item" << value << "not found in" << dd_name.toStdWString ()); CAT_ERROR ("item" << value << "not found in" << dd_name.toStdWString ());
throw error {tr ("Ham Radio Deluxe: item not found in %1 dropdown list").arg (dd_name)}; throw error {tr ("Ham Radio Deluxe: item not found in %1 dropdown list").arg (dd_name)};
} }
} }
void HRDTransceiver::do_ptt (bool on) void HRDTransceiver::do_ptt (bool on)
{ {
TRACE_CAT (on); CAT_TRACE (on);
if (use_for_ptt_) if (use_for_ptt_)
{ {
if (alt_ptt_button_ >= 0 && TransceiverFactory::TX_audio_source_rear == audio_source_) if (alt_ptt_button_ >= 0 && TransceiverFactory::TX_audio_source_rear == audio_source_)
@ -516,7 +516,7 @@ void HRDTransceiver::set_button (int button_index, bool checked)
} }
else else
{ {
TRACE_CAT ("invalid button"); CAT_ERROR ("invalid button");
throw error {tr ("Ham Radio Deluxe: button not available")}; throw error {tr ("Ham Radio Deluxe: button not available")};
} }
} }
@ -593,7 +593,7 @@ auto HRDTransceiver::get_data_mode (MODE m) -> MODE
void HRDTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/) void HRDTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
{ {
TRACE_CAT (f << "reversed" << reversed_); CAT_TRACE (f << "reversed" << reversed_);
if (UNK != m) if (UNK != m)
{ {
do_mode (m); do_mode (m);
@ -613,7 +613,7 @@ void HRDTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
void HRDTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*/) void HRDTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*/)
{ {
TRACE_CAT (tx << "reversed" << reversed_); CAT_TRACE (tx << "reversed" << reversed_);
// re-check if reversed VFOs // re-check if reversed VFOs
bool rx_A {true}; bool rx_A {true};
@ -780,7 +780,7 @@ void HRDTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*
void HRDTransceiver::do_mode (MODE mode) void HRDTransceiver::do_mode (MODE mode)
{ {
TRACE_CAT (mode); CAT_TRACE (mode);
if (reversed_ && mode_B_dropdown_ >= 0) if (reversed_ && 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_));
@ -882,7 +882,7 @@ bool HRDTransceiver::is_button_checked (int button_index)
auto reply = send_command ("get button-select " + buttons_.value (button_index)); auto reply = send_command ("get button-select " + buttons_.value (button_index));
if ("1" != reply && "0" != reply) if ("1" != reply && "0" != reply)
{ {
TRACE_CAT ("bad response"); CAT_ERROR ("bad response");
throw error {tr ("Ham Radio Deluxe didn't respond as expected")}; throw error {tr ("Ham Radio Deluxe didn't respond as expected")};
} }
return "1" == reply; return "1" == reply;
@ -890,8 +890,8 @@ bool HRDTransceiver::is_button_checked (int button_index)
void HRDTransceiver::do_poll () void HRDTransceiver::do_poll ()
{ {
TRACE_CAT ("+++++++ poll dump +++++++"); CAT_TRACE ("+++++++ poll dump +++++++");
TRACE_CAT ("reversed:" << reversed_); CAT_TRACE ("reversed:" << reversed_);
is_button_checked (vfo_A_button_); is_button_checked (vfo_A_button_);
is_button_checked (vfo_B_button_); is_button_checked (vfo_B_button_);
is_button_checked (vfo_toggle_button_); is_button_checked (vfo_toggle_button_);
@ -919,7 +919,7 @@ void HRDTransceiver::do_poll ()
{ {
get_dropdown (split_mode_dropdown_); get_dropdown (split_mode_dropdown_);
} }
TRACE_CAT ("------- poll dump -------"); CAT_TRACE ("------- poll dump -------");
if (split_off_button_ >= 0) if (split_off_button_ >= 0)
{ {
@ -1026,7 +1026,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
}); });
if (radio_iter == radios_.end ()) if (radio_iter == radios_.end ())
{ {
TRACE_CAT ("rig disappeared or changed"); CAT_TRACE ("rig disappeared or changed");
throw error {tr ("Ham Radio Deluxe: rig has disappeared or changed")}; throw error {tr ("Ham Radio Deluxe: rig has disappeared or changed")};
} }
@ -1040,7 +1040,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
if (QTcpSocket::ConnectedState != hrd_->state ()) if (QTcpSocket::ConnectedState != hrd_->state ())
{ {
TRACE_CAT (cmd.toStdWString () << "failed" << hrd_->errorString ().toStdWString ()); CAT_ERROR (cmd.toStdWString () << "failed" << hrd_->errorString ().toStdWString ());
throw error { throw error {
tr ("Ham Radio Deluxe send command \"%1\" failed %2\n") tr ("Ham Radio Deluxe send command \"%1\" failed %2\n")
.arg (cmd) .arg (cmd)
@ -1053,7 +1053,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
auto message = ((prepend_context ? context + cmd : cmd) + "\r").toLocal8Bit (); auto message = ((prepend_context ? context + cmd : cmd) + "\r").toLocal8Bit ();
if (!write_to_port (message.constData (), message.size ())) if (!write_to_port (message.constData (), message.size ()))
{ {
TRACE_CAT ("failed to write command" << cmd.toStdWString () << "to HRD"); CAT_ERROR ("failed to write command" << cmd.toStdWString () << "to HRD");
throw error { throw error {
tr ("Ham Radio Deluxe: failed to write command \"%1\"") tr ("Ham Radio Deluxe: failed to write command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1066,7 +1066,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
QScopedPointer<HRDMessage> message {new (string) HRDMessage}; QScopedPointer<HRDMessage> message {new (string) HRDMessage};
if (!write_to_port (reinterpret_cast<char const *> (message.data ()), message->size_)) if (!write_to_port (reinterpret_cast<char const *> (message.data ()), message->size_))
{ {
TRACE_CAT ("failed to write command" << cmd.toStdWString () << "to HRD"); CAT_ERROR ("failed to write command" << cmd.toStdWString () << "to HRD");
throw error { throw error {
tr ("Ham Radio Deluxe: failed to write command \"%1\"") tr ("Ham Radio Deluxe: failed to write command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1083,7 +1083,7 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
HRDMessage const * reply {new (buffer) HRDMessage}; HRDMessage const * reply {new (buffer) HRDMessage};
if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_) if (reply->magic_1_value_ != reply->magic_1_ && reply->magic_2_value_ != reply->magic_2_)
{ {
TRACE_CAT (cmd.toStdWString () << "invalid reply"); CAT_ERROR (cmd.toStdWString () << "invalid reply");
throw error { throw error {
tr ("Ham Radio Deluxe sent an invalid reply to our command \"%1\"") tr ("Ham Radio Deluxe sent an invalid reply to our command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1093,14 +1093,14 @@ QString HRDTransceiver::send_command (QString const& cmd, bool prepend_context,
// keep reading until expected size arrives // keep reading until expected size arrives
while (buffer.size () - offsetof (HRDMessage, size_) < reply->size_) while (buffer.size () - offsetof (HRDMessage, size_) < reply->size_)
{ {
TRACE_CAT (cmd.toStdWString () << "reading more reply data"); CAT_TRACE (cmd.toStdWString () << "reading more reply data");
buffer += read_reply (cmd); buffer += read_reply (cmd);
reply = new (buffer) HRDMessage; reply = new (buffer) HRDMessage;
} }
result = QString {reply->payload_}; // this is not a memory leak (honest!) result = QString {reply->payload_}; // this is not a memory leak (honest!)
} }
TRACE_CAT (cmd.toStdWString () << " ->" << result.toStdWString ()); CAT_TRACE (cmd.toStdWString () << " ->" << result.toStdWString ());
return result; return result;
} }
@ -1131,7 +1131,7 @@ QByteArray HRDTransceiver::read_reply (QString const& cmd)
replied = hrd_->waitForReadyRead (); replied = hrd_->waitForReadyRead ();
if (!replied && hrd_->error () != hrd_->SocketTimeoutError) if (!replied && hrd_->error () != hrd_->SocketTimeoutError)
{ {
TRACE_CAT (cmd.toStdWString () << "failed to reply" << hrd_->errorString ().toStdWString ()); CAT_ERROR (cmd.toStdWString () << "failed to reply" << hrd_->errorString ().toStdWString ());
throw error { throw error {
tr ("Ham Radio Deluxe failed to reply to command \"%1\" %2\n") tr ("Ham Radio Deluxe failed to reply to command \"%1\" %2\n")
.arg (cmd) .arg (cmd)
@ -1141,7 +1141,7 @@ QByteArray HRDTransceiver::read_reply (QString const& cmd)
} }
if (!replied) if (!replied)
{ {
TRACE_CAT (cmd.toStdWString () << "retries exhausted"); CAT_ERROR (cmd.toStdWString () << "retries exhausted");
throw error { throw error {
tr ("Ham Radio Deluxe retries exhausted sending command \"%1\"") tr ("Ham Radio Deluxe retries exhausted sending command \"%1\"")
.arg (cmd) .arg (cmd)
@ -1154,7 +1154,7 @@ void HRDTransceiver::send_simple_command (QString const& command)
{ {
if ("OK" != send_command (command)) if ("OK" != send_command (command))
{ {
TRACE_CAT (command.toStdWString () << "unexpected response"); CAT_ERROR (command.toStdWString () << "unexpected response");
throw error { throw error {
tr ("Ham Radio Deluxe didn't respond to command \"%1\" as expected") tr ("Ham Radio Deluxe didn't respond to command \"%1\" as expected")
.arg (command) .arg (command)

View File

@ -407,14 +407,14 @@ void HamlibTransceiver::error_check (int ret_code, QString const& doing) const
{ {
if (RIG_OK != ret_code) if (RIG_OK != ret_code)
{ {
TRACE_CAT_POLL ("error: " << rigerror (ret_code)); CAT_ERROR ("error: " << rigerror (ret_code));
throw error {tr ("Hamlib error: %1 while %2").arg (rigerror (ret_code)).arg (doing)}; throw error {tr ("Hamlib error: %1 while %2").arg (rigerror (ret_code)).arg (doing)};
} }
} }
int HamlibTransceiver::do_start () int HamlibTransceiver::do_start ()
{ {
TRACE_CAT ("starting: " << rig_->caps->mfg_name CAT_TRACE ("starting: " << rig_->caps->mfg_name
<< ": " << rig_->caps->model_name); << ": " << rig_->caps->model_name);
error_check (rig_open (rig_.data ()), tr ("opening connection to rig")); error_check (rig_open (rig_.data ()), tr ("opening connection to rig"));
@ -466,25 +466,25 @@ int HamlibTransceiver::do_start ()
// here. We also gather/set other initial state. // here. We also gather/set other initial state.
error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f1), tr ("getting current frequency")); error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f1), tr ("getting current frequency"));
f1 = std::round (f1); f1 = std::round (f1);
TRACE_CAT ("current frequency=" << f1); CAT_TRACE ("current frequency=" << f1);
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w), tr ("getting current mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w), tr ("getting current mode"));
TRACE_CAT ("current mode=" << rig_strrmode (m) << " bw=" << w); CAT_TRACE ("current mode=" << rig_strrmode (m) << " bw=" << w);
if (!rig_->caps->set_vfo) if (!rig_->caps->set_vfo)
{ {
TRACE_CAT ("rig_vfo_op TOGGLE"); CAT_TRACE ("rig_vfo_op TOGGLE");
rc = rig_vfo_op (rig_.data (), RIG_VFO_CURR, RIG_OP_TOGGLE); rc = rig_vfo_op (rig_.data (), RIG_VFO_CURR, RIG_OP_TOGGLE);
} }
else else
{ {
TRACE_CAT ("rig_set_vfo to other VFO"); CAT_TRACE ("rig_set_vfo to other VFO");
rc = rig_set_vfo (rig_.data (), rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB); rc = rig_set_vfo (rig_.data (), rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB);
if (-RIG_ENAVAIL == rc || -RIG_ENIMPL == rc) if (-RIG_ENAVAIL == rc || -RIG_ENIMPL == rc)
{ {
// if we are talking to netrigctl then toggle VFO op // if we are talking to netrigctl then toggle VFO op
// may still work // may still work
TRACE_CAT ("rig_vfo_op TOGGLE"); CAT_TRACE ("rig_vfo_op TOGGLE");
rc = rig_vfo_op (rig_.data (), RIG_VFO_CURR, RIG_OP_TOGGLE); rc = rig_vfo_op (rig_.data (), RIG_VFO_CURR, RIG_OP_TOGGLE);
} }
} }
@ -507,21 +507,21 @@ int HamlibTransceiver::do_start ()
// need to execute this block // need to execute this block
error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f2), tr ("getting other VFO frequency")); error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f2), tr ("getting other VFO frequency"));
f2 = std::round (f2); f2 = std::round (f2);
TRACE_CAT ("rig_get_freq other frequency=" << f2); CAT_TRACE ("rig_get_freq other frequency=" << f2);
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &mb, &wb), tr ("getting other VFO mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &mb, &wb), tr ("getting other VFO mode"));
TRACE_CAT ("rig_get_mode other mode=" << rig_strrmode (mb) << " bw=" << wb); CAT_TRACE ("rig_get_mode other mode=" << rig_strrmode (mb) << " bw=" << wb);
update_other_frequency (f2); update_other_frequency (f2);
if (!rig_->caps->set_vfo) if (!rig_->caps->set_vfo)
{ {
TRACE_CAT ("rig_vfo_op TOGGLE"); CAT_TRACE ("rig_vfo_op TOGGLE");
error_check (rig_vfo_op (rig_.data (), RIG_VFO_CURR, RIG_OP_TOGGLE), tr ("exchanging VFOs")); error_check (rig_vfo_op (rig_.data (), RIG_VFO_CURR, RIG_OP_TOGGLE), tr ("exchanging VFOs"));
} }
else else
{ {
TRACE_CAT ("rig_set_vfo A/MAIN"); CAT_TRACE ("rig_set_vfo A/MAIN");
error_check (rig_set_vfo (rig_.data (), rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN), tr ("setting current VFO")); error_check (rig_set_vfo (rig_.data (), rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN), tr ("setting current VFO"));
} }
@ -533,10 +533,10 @@ int HamlibTransceiver::do_start ()
{ {
error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f1), tr ("getting frequency")); error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f1), tr ("getting frequency"));
f1 = std::round (f1); f1 = std::round (f1);
TRACE_CAT ("rig_get_freq frequency=" << f1); CAT_TRACE ("rig_get_freq frequency=" << f1);
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w), tr ("getting mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w), tr ("getting mode"));
TRACE_CAT ("rig_get_mode mode=" << rig_strrmode (m) << " bw=" << w); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (m) << " bw=" << w);
update_rx_frequency (f1); update_rx_frequency (f1);
} }
@ -553,7 +553,7 @@ int HamlibTransceiver::do_start ()
if (get_vfo_works_ && rig_->caps->get_vfo) if (get_vfo_works_ && rig_->caps->get_vfo)
{ {
error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib
TRACE_CAT ("rig_get_vfo current VFO=" << rig_strvfo (v)); CAT_TRACE ("rig_get_vfo current VFO=" << rig_strvfo (v));
} }
reversed_ = RIG_VFO_B == v; reversed_ = RIG_VFO_B == v;
@ -562,7 +562,7 @@ int HamlibTransceiver::do_start ()
{ {
if (RIG_OK == rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w)) if (RIG_OK == rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w))
{ {
TRACE_CAT ("rig_get_mode current mode=" << rig_strrmode (m) << " bw=" << w); CAT_TRACE ("rig_get_mode current mode=" << rig_strrmode (m) << " bw=" << w);
} }
else else
{ {
@ -570,7 +570,7 @@ int HamlibTransceiver::do_start ()
// Some rigs (HDSDR) don't have a working way of // Some rigs (HDSDR) don't have a working way of
// reporting MODE so we give up on mode queries - // reporting MODE so we give up on mode queries -
// sets will still cause an error // sets will still cause an error
TRACE_CAT ("rig_get_mode can't do on this rig"); CAT_TRACE ("rig_get_mode can't do on this rig");
} }
} }
} }
@ -646,7 +646,7 @@ int HamlibTransceiver::do_start ()
do_poll (); do_poll ();
TRACE_CAT ("finished start " << state () << " reversed=" << reversed_ << " resolution=" << resolution); CAT_TRACE ("finished start " << state () << " reversed=" << reversed_ << " resolution=" << resolution);
return resolution; return resolution;
} }
@ -667,7 +667,7 @@ void HamlibTransceiver::do_stop ()
rig_close (rig_.data ()); rig_close (rig_.data ());
} }
TRACE_CAT ("state: " << state () << " reversed=" << reversed_); CAT_TRACE ("state: " << state () << " reversed=" << reversed_);
} }
std::tuple<vfo_t, vfo_t> HamlibTransceiver::get_vfos (bool for_split) const std::tuple<vfo_t, vfo_t> HamlibTransceiver::get_vfos (bool for_split) const
@ -676,7 +676,7 @@ std::tuple<vfo_t, vfo_t> HamlibTransceiver::get_vfos (bool for_split) const
{ {
vfo_t v; vfo_t v;
error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib
TRACE_CAT ("rig_get_vfo VFO=" << rig_strvfo (v)); CAT_TRACE ("rig_get_vfo VFO=" << rig_strvfo (v));
reversed_ = RIG_VFO_B == v; reversed_ = RIG_VFO_B == v;
} }
@ -686,7 +686,7 @@ std::tuple<vfo_t, vfo_t> HamlibTransceiver::get_vfos (bool for_split) const
// frequency if split since these type of radios can only // frequency if split since these type of radios can only
// support this way around // support this way around
TRACE_CAT ("rig_set_vfo VFO=A/MAIN"); CAT_TRACE ("rig_set_vfo VFO=A/MAIN");
error_check (rig_set_vfo (rig_.data (), rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN), tr ("setting current VFO")); error_check (rig_set_vfo (rig_.data (), rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN), tr ("setting current VFO"));
} }
// else only toggle available but VFOs should be substitutable // else only toggle available but VFOs should be substitutable
@ -697,17 +697,17 @@ std::tuple<vfo_t, vfo_t> HamlibTransceiver::get_vfos (bool for_split) const
: rx_vfo; : rx_vfo;
if (reversed_) if (reversed_)
{ {
TRACE_CAT ("reversing VFOs"); CAT_TRACE ("reversing VFOs");
std::swap (rx_vfo, tx_vfo); std::swap (rx_vfo, tx_vfo);
} }
TRACE_CAT ("RX VFO=" << rig_strvfo (rx_vfo) << " TX VFO=" << rig_strvfo (tx_vfo)); CAT_TRACE ("RX VFO=" << rig_strvfo (rx_vfo) << " TX VFO=" << rig_strvfo (tx_vfo));
return std::make_tuple (rx_vfo, tx_vfo); return std::make_tuple (rx_vfo, tx_vfo);
} }
void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore)
{ {
TRACE_CAT ("f: " << f << " mode: " << m << " reversed: " << reversed_); CAT_TRACE ("f: " << f << " mode: " << m << " reversed: " << reversed_);
// only change when receiving or simplex or direct VFO addressing // only change when receiving or simplex or direct VFO addressing
// unavailable or forced // unavailable or forced
@ -724,11 +724,11 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore)
pbwidth_t current_width; pbwidth_t current_width;
auto new_mode = map_mode (m); auto new_mode = map_mode (m);
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode"));
TRACE_CAT ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width);
if (new_mode != current_mode) if (new_mode != current_mode)
{ {
TRACE_CAT ("rig_set_mode mode=" << rig_strrmode (new_mode)); CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode));
error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode"));
// for the 2nd time because a mode change may have caused a // for the 2nd time because a mode change may have caused a
@ -737,7 +737,7 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore)
// for the second time because some rigs change mode according // for the second time because some rigs change mode according
// to frequency such as the TS-2000 auto mode setting // to frequency such as the TS-2000 auto mode setting
TRACE_CAT ("rig_set_mode mode=" << rig_strrmode (new_mode)); CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode));
error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode"));
} }
update_mode (m); update_mode (m);
@ -747,7 +747,7 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore)
void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore) void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore)
{ {
TRACE_CAT ("txf: " << tx << " reversed: " << reversed_); CAT_TRACE ("txf: " << tx << " reversed: " << reversed_);
if (WSJT_RIG_NONE_CAN_SPLIT || !is_dummy_) // split is meaningless if you can't see it if (WSJT_RIG_NONE_CAN_SPLIT || !is_dummy_) // split is meaningless if you can't see it
{ {
@ -771,7 +771,7 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore
// much we can do since the Hamlib Library needs this // much we can do since the Hamlib Library needs this
// call at least once to establish the Tx VFO. Best we // call at least once to establish the Tx VFO. Best we
// can do is only do this once per session. // can do is only do this once per session.
TRACE_CAT ("rig_set_split_vfo split=" << split); CAT_TRACE ("rig_set_split_vfo split=" << split);
auto rc = rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo); auto rc = rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo);
if (tx || (-RIG_ENAVAIL != rc && -RIG_ENIMPL != rc)) if (tx || (-RIG_ENAVAIL != rc && -RIG_ENIMPL != rc))
{ {
@ -791,7 +791,7 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore
// addressing // addressing
if (state ().ptt () && one_VFO_) if (state ().ptt () && one_VFO_)
{ {
TRACE_CAT ("rig_set_split_vfo split=" << split); CAT_TRACE ("rig_set_split_vfo split=" << split);
error_check (rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo), tr ("setting split mode")); error_check (rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo), tr ("setting split mode"));
error_check (rig_set_freq (rig_.data (), RIG_VFO_CURR, tx), tr ("setting frequency")); error_check (rig_set_freq (rig_.data (), RIG_VFO_CURR, tx), tr ("setting frequency"));
@ -802,11 +802,11 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore
pbwidth_t current_width; pbwidth_t current_width;
auto new_mode = map_mode (mode); auto new_mode = map_mode (mode);
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode"));
TRACE_CAT ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width);
if (new_mode != current_mode) if (new_mode != current_mode)
{ {
TRACE_CAT ("rig_set_mode mode=" << rig_strrmode (new_mode)); CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode));
error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode"));
} }
} }
@ -818,20 +818,20 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore
if (UNK != mode) if (UNK != mode)
{ {
auto new_mode = map_mode (mode); auto new_mode = map_mode (mode);
TRACE_CAT ("rig_set_split_freq_mode freq=" << tx CAT_TRACE ("rig_set_split_freq_mode freq=" << tx
<< " mode = " << rig_strrmode (new_mode)); << " mode = " << rig_strrmode (new_mode));
error_check (rig_set_split_freq_mode (rig_.data (), RIG_VFO_CURR, tx, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting split TX frequency and mode")); error_check (rig_set_split_freq_mode (rig_.data (), RIG_VFO_CURR, tx, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting split TX frequency and mode"));
} }
else else
{ {
TRACE_CAT ("rig_set_split_freq freq=" << tx); CAT_TRACE ("rig_set_split_freq freq=" << tx);
error_check (rig_set_split_freq (rig_.data (), RIG_VFO_CURR, tx), tr ("setting split TX frequency")); error_check (rig_set_split_freq (rig_.data (), RIG_VFO_CURR, tx), tr ("setting split TX frequency"));
} }
// Enable split last since some rigs (Kenwood for one) come out // Enable split last since some rigs (Kenwood for one) come out
// of split when you switch RX VFO (to set split mode above for // of split when you switch RX VFO (to set split mode above for
// example). Also the Elecraft K3 will refuse to go to split // example). Also the Elecraft K3 will refuse to go to split
// with certain VFO A/B mode combinations. // with certain VFO A/B mode combinations.
TRACE_CAT ("rig_set_split_vfo split=" << split); CAT_TRACE ("rig_set_split_vfo split=" << split);
error_check (rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo), tr ("setting split mode")); error_check (rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo), tr ("setting split mode"));
update_other_frequency (tx); update_other_frequency (tx);
update_split (tx); update_split (tx);
@ -840,7 +840,7 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore
else else
{ {
// Disable split // Disable split
TRACE_CAT ("rig_set_split_vfo split=" << split); CAT_TRACE ("rig_set_split_vfo split=" << split);
auto rc = rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo); auto rc = rig_set_split_vfo (rig_.data (), RIG_VFO_CURR, split, tx_vfo);
if (tx || (-RIG_ENAVAIL != rc && -RIG_ENIMPL != rc)) if (tx || (-RIG_ENAVAIL != rc && -RIG_ENIMPL != rc))
{ {
@ -860,7 +860,7 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore
void HamlibTransceiver::do_mode (MODE mode) void HamlibTransceiver::do_mode (MODE mode)
{ {
TRACE_CAT (mode); CAT_TRACE (mode);
auto vfos = get_vfos (state ().split ()); auto vfos = get_vfos (state ().split ());
// auto rx_vfo = std::get<0> (vfos); // auto rx_vfo = std::get<0> (vfos);
@ -874,11 +874,11 @@ void HamlibTransceiver::do_mode (MODE mode)
if (!(state ().ptt () && state ().split () && one_VFO_)) if (!(state ().ptt () && state ().split () && one_VFO_))
{ {
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode"));
TRACE_CAT ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width);
if (new_mode != current_mode) if (new_mode != current_mode)
{ {
TRACE_CAT ("rig_set_mode mode=" << rig_strrmode (new_mode)); CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode));
error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode"));
} }
} }
@ -887,22 +887,22 @@ void HamlibTransceiver::do_mode (MODE mode)
if (state ().ptt () && state ().split () && one_VFO_) if (state ().ptt () && state ().split () && one_VFO_)
{ {
error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode")); error_check (rig_get_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting current VFO mode"));
TRACE_CAT ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width);
if (new_mode != current_mode) if (new_mode != current_mode)
{ {
TRACE_CAT ("rig_set_mode mode=" << rig_strrmode (new_mode)); CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode));
error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); error_check (rig_set_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode"));
} }
} }
else if (state ().split () && !one_VFO_) else if (state ().split () && !one_VFO_)
{ {
error_check (rig_get_split_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting split TX VFO mode")); error_check (rig_get_split_mode (rig_.data (), RIG_VFO_CURR, &current_mode, &current_width), tr ("getting split TX VFO mode"));
TRACE_CAT ("rig_get_split_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); CAT_TRACE ("rig_get_split_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width);
if (new_mode != current_mode) if (new_mode != current_mode)
{ {
TRACE_CAT ("rig_set_split_mode mode=" << rig_strrmode (new_mode)); CAT_TRACE ("rig_set_split_mode mode=" << rig_strrmode (new_mode));
hamlib_tx_vfo_fixup fixup (rig_.data (), tx_vfo); hamlib_tx_vfo_fixup fixup (rig_.data (), tx_vfo);
error_check (rig_set_split_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting split TX VFO mode")); error_check (rig_set_split_mode (rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting split TX VFO mode"));
} }
@ -921,7 +921,7 @@ void HamlibTransceiver::do_poll ()
{ {
vfo_t v; vfo_t v;
error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib
TRACE_CAT_POLL ("VFO=" << rig_strvfo (v)); CAT_TRACE ("VFO=" << rig_strvfo (v));
reversed_ = RIG_VFO_B == v; reversed_ = RIG_VFO_B == v;
} }
@ -932,7 +932,7 @@ void HamlibTransceiver::do_poll ()
auto rc = rig_get_split_vfo (rig_.data (), RIG_VFO_CURR, &s, &v); auto rc = rig_get_split_vfo (rig_.data (), RIG_VFO_CURR, &s, &v);
if (-RIG_OK == rc && RIG_SPLIT_ON == s) if (-RIG_OK == rc && RIG_SPLIT_ON == s)
{ {
TRACE_CAT_POLL ("rig_get_split_vfo split=" << s << " VFO=" << rig_strvfo (v)); CAT_TRACE ("rig_get_split_vfo split=" << s << " VFO=" << rig_strvfo (v));
update_split (true); update_split (true);
// if (RIG_VFO_A == v) // if (RIG_VFO_A == v)
// { // {
@ -941,14 +941,14 @@ void HamlibTransceiver::do_poll ()
} }
else if (-RIG_OK == rc) // not split else if (-RIG_OK == rc) // not split
{ {
TRACE_CAT_POLL ("rig_get_split_vfo split=" << s << " VFO=" << rig_strvfo (v)); CAT_TRACE ("rig_get_split_vfo split=" << s << " VFO=" << rig_strvfo (v));
update_split (false); update_split (false);
} }
else else
{ {
// Some rigs (Icom) don't have a way of reporting SPLIT // Some rigs (Icom) don't have a way of reporting SPLIT
// mode // mode
TRACE_CAT_POLL ("rig_get_split_vfo can't do on this rig"); CAT_TRACE ("rig_get_split_vfo can't do on this rig");
// just report how we see it based on prior commands // just report how we see it based on prior commands
split_query_works_ = false; split_query_works_ = false;
} }
@ -961,7 +961,7 @@ void HamlibTransceiver::do_poll ()
{ {
error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f), tr ("getting current VFO frequency")); error_check (rig_get_freq (rig_.data (), RIG_VFO_CURR, &f), tr ("getting current VFO frequency"));
f = std::round (f); f = std::round (f);
TRACE_CAT_POLL ("rig_get_freq frequency=" << f); CAT_TRACE ("rig_get_freq frequency=" << f);
update_rx_frequency (f); update_rx_frequency (f);
} }
@ -982,7 +982,7 @@ void HamlibTransceiver::do_poll ()
: (rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB) : (rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB)
, &f), tr ("getting other VFO frequency")); , &f), tr ("getting other VFO frequency"));
f = std::round (f); f = std::round (f);
TRACE_CAT_POLL ("rig_get_freq other VFO=" << f); CAT_TRACE ("rig_get_freq other VFO=" << f);
update_other_frequency (f); update_other_frequency (f);
} }
} }
@ -1000,12 +1000,12 @@ void HamlibTransceiver::do_poll ()
auto rc = rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w); auto rc = rig_get_mode (rig_.data (), RIG_VFO_CURR, &m, &w);
if (RIG_OK == rc) if (RIG_OK == rc)
{ {
TRACE_CAT_POLL ("rig_get_mode mode=" << rig_strrmode (m) << " bw=" << w); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (m) << " bw=" << w);
update_mode (map_mode (m)); update_mode (map_mode (m));
} }
else else
{ {
TRACE_CAT_POLL ("rig_get_mode mode failed with rc: " << rc << " ignoring"); CAT_TRACE ("rig_get_mode mode failed with rc: " << rc << " ignoring");
} }
} }
@ -1018,7 +1018,7 @@ void HamlibTransceiver::do_poll ()
// support command // support command
{ {
error_check (rc, tr ("getting PTT state")); error_check (rc, tr ("getting PTT state"));
TRACE_CAT_POLL ("rig_get_ptt PTT=" << p); CAT_TRACE ("rig_get_ptt PTT=" << p);
update_PTT (!(RIG_PTT_OFF == p)); update_PTT (!(RIG_PTT_OFF == p));
} }
} }
@ -1026,12 +1026,12 @@ void HamlibTransceiver::do_poll ()
void HamlibTransceiver::do_ptt (bool on) void HamlibTransceiver::do_ptt (bool on)
{ {
TRACE_CAT ("PTT: " << on << " " << state () << " reversed=" << reversed_); CAT_TRACE ("PTT: " << on << " " << state () << " reversed=" << reversed_);
if (on) if (on)
{ {
if (RIG_PTT_NONE != rig_->state.pttport.type.ptt) if (RIG_PTT_NONE != rig_->state.pttport.type.ptt)
{ {
TRACE_CAT ("rig_set_ptt PTT=true"); CAT_TRACE ("rig_set_ptt PTT=true");
error_check (rig_set_ptt (rig_.data (), RIG_VFO_CURR error_check (rig_set_ptt (rig_.data (), RIG_VFO_CURR
, RIG_PTT_RIG_MICDATA == rig_->caps->ptt_type && back_ptt_port_ , RIG_PTT_RIG_MICDATA == rig_->caps->ptt_type && back_ptt_port_
? RIG_PTT_ON_DATA : RIG_PTT_ON), tr ("setting PTT on")); ? RIG_PTT_ON_DATA : RIG_PTT_ON), tr ("setting PTT on"));
@ -1041,7 +1041,7 @@ void HamlibTransceiver::do_ptt (bool on)
{ {
if (RIG_PTT_NONE != rig_->state.pttport.type.ptt) if (RIG_PTT_NONE != rig_->state.pttport.type.ptt)
{ {
TRACE_CAT ("rig_set_ptt PTT=false"); CAT_TRACE ("rig_set_ptt PTT=false");
error_check (rig_set_ptt (rig_.data (), RIG_VFO_CURR, RIG_PTT_OFF), tr ("setting PTT off")); error_check (rig_set_ptt (rig_.data (), RIG_VFO_CURR, RIG_PTT_OFF), tr ("setting PTT off"));
} }
} }

View File

@ -49,7 +49,7 @@ auto OmniRigTransceiver::map_mode (OmniRig::RigParamX param) -> MODE
{ {
return FM; return FM;
} }
TRACE_CAT ("unrecognized mode"); CAT_ERROR ("unrecognized mode");
throw_qstring (tr ("OmniRig: unrecognized mode")); throw_qstring (tr ("OmniRig: unrecognized mode"));
return UNK; return UNK;
} }
@ -129,14 +129,14 @@ bool OmniRigTransceiver::await_notification_with_timeout (int timeout)
int OmniRigTransceiver::do_start () int OmniRigTransceiver::do_start ()
{ {
TRACE_CAT ("starting"); CAT_TRACE ("starting");
if (wrapped_) wrapped_->start (0); if (wrapped_) wrapped_->start (0);
omni_rig_.reset (new OmniRig::OmniRigX {this}); omni_rig_.reset (new OmniRig::OmniRigX {this});
if (omni_rig_->isNull ()) if (omni_rig_->isNull ())
{ {
TRACE_CAT ("failed to start COM server"); CAT_ERROR ("failed to start COM server");
throw_qstring (tr ("Failed to start OmniRig COM server")); throw_qstring (tr ("Failed to start OmniRig COM server"));
} }
@ -152,8 +152,8 @@ int OmniRigTransceiver::do_start ()
, SIGNAL (CustomReply (int, QVariant const&, QVariant const&)) , SIGNAL (CustomReply (int, QVariant const&, QVariant const&))
, this, SLOT (handle_custom_reply (int, QVariant const&, QVariant const&))); , this, SLOT (handle_custom_reply (int, QVariant const&, QVariant const&)));
TRACE_CAT ("OmniRig s/w version:" << omni_rig_->SoftwareVersion () CAT_INFO ("OmniRig s/w version: " << omni_rig_->SoftwareVersion ()
<< "i/f version:" << omni_rig_->InterfaceVersion ()); << "i/f version: " << omni_rig_->InterfaceVersion ());
// fetch the interface of the RigX CoClass and instantiate a proxy object // fetch the interface of the RigX CoClass and instantiate a proxy object
switch (rig_number_) switch (rig_number_)
@ -185,12 +185,12 @@ int OmniRigTransceiver::do_start ()
// COM/OLE exceptions get signaled // COM/OLE exceptions get signaled
connect (&*port_, SIGNAL (exception (int, QString, QString, QString)), this, SLOT (handle_COM_exception (int, QString, QString, QString))); connect (&*port_, SIGNAL (exception (int, QString, QString, QString)), this, SLOT (handle_COM_exception (int, QString, QString, QString)));
TRACE_CAT ("OmniRig RTS state:" << port_->Rts ()); CAT_TRACE ("OmniRig RTS state: " << port_->Rts ());
// remove locking because it doesn't seem to work properly // remove locking because it doesn't seem to work properly
// if (!port_->Lock ()) // try to take exclusive use of the OmniRig serial port for PTT // if (!port_->Lock ()) // try to take exclusive use of the OmniRig serial port for PTT
// { // {
// TRACE_CAT ("Failed to get exclusive use of serial port for PTT from OmniRig"); // CAT_WARNING ("Failed to get exclusive use of serial port for PTT from OmniRig");
// } // }
// start off so we don't accidentally key the radio // start off so we don't accidentally key the radio
@ -208,7 +208,7 @@ int OmniRigTransceiver::do_start ()
readable_params_ = rig_->ReadableParams (); readable_params_ = rig_->ReadableParams ();
writable_params_ = rig_->WriteableParams (); writable_params_ = rig_->WriteableParams ();
TRACE_CAT (QString {"OmniRig initial rig type: %1 readable params = 0x%2 writable params = 0x%3 for rig %4"} CAT_INFO (QString {"OmniRig initial rig type: %1 readable params=0x%2 writable params=0x%3 for rig %4"}
.arg (rig_type_) .arg (rig_type_)
.arg (readable_params_, 8, 16, QChar ('0')) .arg (readable_params_, 8, 16, QChar ('0'))
.arg (writable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0'))
@ -264,7 +264,7 @@ int OmniRigTransceiver::do_start ()
} }
if (!await_notification_with_timeout (1000)) if (!await_notification_with_timeout (1000))
{ {
TRACE_CAT ("do_start 1: wait timed out"); CAT_ERROR ("do_start 1: wait timed out");
throw_qstring (tr ("OmniRig: timeout waiting for update from rig")); throw_qstring (tr ("OmniRig: timeout waiting for update from rig"));
} }
switch (rig_->GetRxFrequency () - test_frequency) switch (rig_->GetRxFrequency () - test_frequency)
@ -292,7 +292,7 @@ int OmniRigTransceiver::do_start ()
} }
if (!await_notification_with_timeout (2000)) if (!await_notification_with_timeout (2000))
{ {
TRACE_CAT ("do_start 2: wait timed out"); CAT_ERROR ("do_start 2: wait timed out");
throw_qstring (tr ("OmniRig: timeout waiting for update from rig")); throw_qstring (tr ("OmniRig: timeout waiting for update from rig"));
} }
if (9 == rig_->GetRxFrequency () - test_frequency) if (9 == rig_->GetRxFrequency () - test_frequency)
@ -344,30 +344,30 @@ void OmniRigTransceiver::do_stop ()
if (wrapped_) wrapped_->stop (); if (wrapped_) wrapped_->stop ();
TRACE_CAT ("stopped"); CAT_TRACE ("stopped");
} }
void OmniRigTransceiver::handle_COM_exception (int code, QString source, QString desc, QString help) void OmniRigTransceiver::handle_COM_exception (int code, QString source, QString desc, QString help)
{ {
TRACE_CAT ((QString::number (code) + " at " + source + ": " + desc + " (" + help + ')').toStdWString ()); CAT_ERROR ((QString::number (code) + " at " + source + ": " + desc + " (" + help + ')').toStdWString ());
throw_qstring (tr ("OmniRig COM/OLE error: %1 at %2: %3 (%4)").arg (QString::number (code)).arg (source). arg (desc). arg (help)); throw_qstring (tr ("OmniRig COM/OLE error: %1 at %2: %3 (%4)").arg (QString::number (code)).arg (source). arg (desc). arg (help));
} }
void OmniRigTransceiver::handle_visible_change () void OmniRigTransceiver::handle_visible_change ()
{ {
if (!omni_rig_ || omni_rig_->isNull ()) return; if (!omni_rig_ || omni_rig_->isNull ()) return;
TRACE_CAT ("visibility change: visibility =" << omni_rig_->DialogVisible ()); CAT_TRACE ("visibility change: visibility =" << omni_rig_->DialogVisible ());
} }
void OmniRigTransceiver::handle_rig_type_change (int rig_number) void OmniRigTransceiver::handle_rig_type_change (int rig_number)
{ {
TRACE_CAT ("rig type change: rig =" << rig_number); CAT_TRACE ("rig type change: rig =" << rig_number);
if (rig_number_ == rig_number) if (rig_number_ == rig_number)
{ {
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
readable_params_ = rig_->ReadableParams (); readable_params_ = rig_->ReadableParams ();
writable_params_ = rig_->WriteableParams (); writable_params_ = rig_->WriteableParams ();
TRACE_CAT (QString {"rig type change to: %1 readable params = 0x%2 writable params = 0x%3 for rig %4"} CAT_INFO (QString {"rig type change to: %1 readable params = 0x%2 writable params = 0x%3 for rig %4"}
.arg (rig_->RigType ()) .arg (rig_->RigType ())
.arg (readable_params_, 8, 16, QChar ('0')) .arg (readable_params_, 8, 16, QChar ('0'))
.arg (writable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0'))
@ -377,12 +377,12 @@ void OmniRigTransceiver::handle_rig_type_change (int rig_number)
void OmniRigTransceiver::handle_status_change (int rig_number) void OmniRigTransceiver::handle_status_change (int rig_number)
{ {
TRACE_CAT (QString {"status change for rig %1"}.arg (rig_number).toStdWString ()); CAT_TRACE (QString {"status change for rig %1"}.arg (rig_number).toStdWString ());
if (rig_number_ == rig_number) if (rig_number_ == rig_number)
{ {
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
auto const& status = rig_->StatusStr (); auto const& status = rig_->StatusStr ();
TRACE_CAT ("OmniRig status change: new status = " << status.toStdWString ()); CAT_TRACE ("OmniRig status change: new status = " << status.toStdWString ());
if (OmniRig::ST_ONLINE != rig_->Status ()) if (OmniRig::ST_ONLINE != rig_->Status ())
{ {
if (!offline_timer_->isActive ()) if (!offline_timer_->isActive ())
@ -402,14 +402,14 @@ void OmniRigTransceiver::handle_status_change (int rig_number)
// { // {
// update_rx_frequency (rig_->GetRxFrequency ()); // update_rx_frequency (rig_->GetRxFrequency ());
// update_complete (); // update_complete ();
// TRACE_CAT ("frequency:" << state ().frequency ()); // CAT_TRACE ("frequency:" << state ().frequency ());
// } // }
} }
} }
void OmniRigTransceiver::handle_params_change (int rig_number, int params) void OmniRigTransceiver::handle_params_change (int rig_number, int params)
{ {
TRACE_CAT (QString {"params change: params = 0x%1 for rig %2"} CAT_TRACE (QString {"params change: params=0x%1 for rig %2"}
.arg (params, 8, 16, QChar ('0')) .arg (params, 8, 16, QChar ('0'))
.arg (rig_number).toStdWString () .arg (rig_number).toStdWString ()
<< "state before:" << state ()); << "state before:" << state ());
@ -422,7 +422,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
if (params & OmniRig::PM_VFOAA) if (params & OmniRig::PM_VFOAA)
{ {
TRACE_CAT ("VFOAA"); CAT_TRACE ("VFOAA");
update_split (false); update_split (false);
reversed_ = false; reversed_ = false;
update_rx_frequency (rig_->FreqA ()); update_rx_frequency (rig_->FreqA ());
@ -430,7 +430,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
} }
if (params & OmniRig::PM_VFOAB) if (params & OmniRig::PM_VFOAB)
{ {
TRACE_CAT ("VFOAB"); CAT_TRACE ("VFOAB");
update_split (true); update_split (true);
reversed_ = false; reversed_ = false;
update_rx_frequency (rig_->FreqA ()); update_rx_frequency (rig_->FreqA ());
@ -438,7 +438,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
} }
if (params & OmniRig::PM_VFOBA) if (params & OmniRig::PM_VFOBA)
{ {
TRACE_CAT ("VFOBA"); CAT_TRACE ("VFOBA");
update_split (true); update_split (true);
reversed_ = true; reversed_ = true;
update_other_frequency (rig_->FreqA ()); update_other_frequency (rig_->FreqA ());
@ -446,7 +446,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
} }
if (params & OmniRig::PM_VFOBB) if (params & OmniRig::PM_VFOBB)
{ {
TRACE_CAT ("VFOBB"); CAT_TRACE ("VFOBB");
update_split (false); update_split (false);
reversed_ = true; reversed_ = true;
update_other_frequency (rig_->FreqA ()); update_other_frequency (rig_->FreqA ());
@ -454,26 +454,26 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
} }
if (params & OmniRig::PM_VFOA) if (params & OmniRig::PM_VFOA)
{ {
TRACE_CAT ("VFOA"); CAT_TRACE ("VFOA");
reversed_ = false; reversed_ = false;
need_frequency = true; need_frequency = true;
} }
if (params & OmniRig::PM_VFOB) if (params & OmniRig::PM_VFOB)
{ {
TRACE_CAT ("VFOB"); CAT_TRACE ("VFOB");
reversed_ = true; reversed_ = true;
need_frequency = true; need_frequency = true;
} }
if (params & OmniRig::PM_FREQ) if (params & OmniRig::PM_FREQ)
{ {
TRACE_CAT ("FREQ"); CAT_TRACE ("FREQ");
need_frequency = true; need_frequency = true;
} }
if (params & OmniRig::PM_FREQA) if (params & OmniRig::PM_FREQA)
{ {
auto f = rig_->FreqA (); auto f = rig_->FreqA ();
TRACE_CAT ("FREQA = " << f); CAT_TRACE ("FREQA = " << f);
if (reversed_) if (reversed_)
{ {
update_other_frequency (f); update_other_frequency (f);
@ -486,7 +486,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
if (params & OmniRig::PM_FREQB) if (params & OmniRig::PM_FREQB)
{ {
auto f = rig_->FreqB (); auto f = rig_->FreqB ();
TRACE_CAT ("FREQB = " << f); CAT_TRACE ("FREQB = " << f);
if (reversed_) if (reversed_)
{ {
update_rx_frequency (f); update_rx_frequency (f);
@ -503,7 +503,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
auto f = rig_->FreqA (); auto f = rig_->FreqA ();
if (f) if (f)
{ {
TRACE_CAT ("FREQA = " << f); CAT_TRACE ("FREQA = " << f);
if (reversed_) if (reversed_)
{ {
update_other_frequency (f); update_other_frequency (f);
@ -519,7 +519,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
auto f = rig_->FreqB (); auto f = rig_->FreqB ();
if (f) if (f)
{ {
TRACE_CAT ("FREQB = " << f); CAT_TRACE ("FREQB = " << f);
if (reversed_) if (reversed_)
{ {
update_rx_frequency (f); update_rx_frequency (f);
@ -535,35 +535,35 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
auto f = rig_->Freq (); auto f = rig_->Freq ();
if (f) if (f)
{ {
TRACE_CAT ("FREQ = " << f); CAT_TRACE ("FREQ = " << f);
update_rx_frequency (f); update_rx_frequency (f);
} }
} }
} }
if (params & OmniRig::PM_PITCH) if (params & OmniRig::PM_PITCH)
{ {
TRACE_CAT ("PITCH"); CAT_TRACE ("PITCH");
} }
if (params & OmniRig::PM_RITOFFSET) if (params & OmniRig::PM_RITOFFSET)
{ {
TRACE_CAT ("RITOFFSET"); CAT_TRACE ("RITOFFSET");
} }
if (params & OmniRig::PM_RIT0) if (params & OmniRig::PM_RIT0)
{ {
TRACE_CAT ("RIT0"); CAT_TRACE ("RIT0");
} }
if (params & OmniRig::PM_VFOEQUAL) if (params & OmniRig::PM_VFOEQUAL)
{ {
auto f = readable_params_ & OmniRig::PM_FREQA ? rig_->FreqA () : rig_->Freq (); auto f = readable_params_ & OmniRig::PM_FREQA ? rig_->FreqA () : rig_->Freq ();
auto m = map_mode (rig_->Mode ()); auto m = map_mode (rig_->Mode ());
TRACE_CAT (QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m).toStdWString ()); CAT_TRACE (QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m).toStdWString ());
update_rx_frequency (f); update_rx_frequency (f);
update_other_frequency (f); update_other_frequency (f);
update_mode (m); update_mode (m);
} }
if (params & OmniRig::PM_VFOSWAP) if (params & OmniRig::PM_VFOSWAP)
{ {
TRACE_CAT ("VFOSWAP"); CAT_TRACE ("VFOSWAP");
auto f = state ().tx_frequency (); auto f = state ().tx_frequency ();
update_other_frequency (state ().frequency ()); update_other_frequency (state ().frequency ());
update_rx_frequency (f); update_rx_frequency (f);
@ -571,78 +571,78 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
} }
if (params & OmniRig::PM_SPLITON) if (params & OmniRig::PM_SPLITON)
{ {
TRACE_CAT ("SPLITON"); CAT_TRACE ("SPLITON");
update_split (true); update_split (true);
} }
if (params & OmniRig::PM_SPLITOFF) if (params & OmniRig::PM_SPLITOFF)
{ {
TRACE_CAT ("SPLITOFF"); CAT_TRACE ("SPLITOFF");
update_split (false); update_split (false);
} }
if (params & OmniRig::PM_RITON) if (params & OmniRig::PM_RITON)
{ {
TRACE_CAT ("RITON"); CAT_TRACE ("RITON");
} }
if (params & OmniRig::PM_RITOFF) if (params & OmniRig::PM_RITOFF)
{ {
TRACE_CAT ("RITOFF"); CAT_TRACE ("RITOFF");
} }
if (params & OmniRig::PM_XITON) if (params & OmniRig::PM_XITON)
{ {
TRACE_CAT ("XITON"); CAT_TRACE ("XITON");
} }
if (params & OmniRig::PM_XITOFF) if (params & OmniRig::PM_XITOFF)
{ {
TRACE_CAT ("XITOFF"); CAT_TRACE ("XITOFF");
} }
if (params & OmniRig::PM_RX) if (params & OmniRig::PM_RX)
{ {
TRACE_CAT ("RX"); CAT_TRACE ("RX");
update_PTT (false); update_PTT (false);
} }
if (params & OmniRig::PM_TX) if (params & OmniRig::PM_TX)
{ {
TRACE_CAT ("TX"); CAT_TRACE ("TX");
update_PTT (); update_PTT ();
} }
if (params & OmniRig::PM_CW_U) if (params & OmniRig::PM_CW_U)
{ {
TRACE_CAT ("CW-R"); CAT_TRACE ("CW-R");
update_mode (CW_R); update_mode (CW_R);
} }
if (params & OmniRig::PM_CW_L) if (params & OmniRig::PM_CW_L)
{ {
TRACE_CAT ("CW"); CAT_TRACE ("CW");
update_mode (CW); update_mode (CW);
} }
if (params & OmniRig::PM_SSB_U) if (params & OmniRig::PM_SSB_U)
{ {
TRACE_CAT ("USB"); CAT_TRACE ("USB");
update_mode (USB); update_mode (USB);
} }
if (params & OmniRig::PM_SSB_L) if (params & OmniRig::PM_SSB_L)
{ {
TRACE_CAT ("LSB"); CAT_TRACE ("LSB");
update_mode (LSB); update_mode (LSB);
} }
if (params & OmniRig::PM_DIG_U) if (params & OmniRig::PM_DIG_U)
{ {
TRACE_CAT ("DATA-U"); CAT_TRACE ("DATA-U");
update_mode (DIG_U); update_mode (DIG_U);
} }
if (params & OmniRig::PM_DIG_L) if (params & OmniRig::PM_DIG_L)
{ {
TRACE_CAT ("DATA-L"); CAT_TRACE ("DATA-L");
update_mode (DIG_L); update_mode (DIG_L);
} }
if (params & OmniRig::PM_AM) if (params & OmniRig::PM_AM)
{ {
TRACE_CAT ("AM"); CAT_TRACE ("AM");
update_mode (AM); update_mode (AM);
} }
if (params & OmniRig::PM_FM) if (params & OmniRig::PM_FM)
{ {
TRACE_CAT ("FM"); CAT_TRACE ("FM");
update_mode (FM); update_mode (FM);
} }
@ -651,7 +651,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params)
update_complete (); update_complete ();
send_update_signal_ = false; send_update_signal_ = false;
} }
TRACE_CAT ("OmniRig params change: state after:" << state ()); CAT_TRACE ("OmniRig params change: state after:" << state ());
} }
Q_EMIT notified (); Q_EMIT notified ();
} }
@ -664,19 +664,19 @@ void OmniRigTransceiver::handle_custom_reply (int rig_number, QVariant const& co
if (rig_number_ == rig_number) if (rig_number_ == rig_number)
{ {
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
TRACE_CAT ("custom command" << command.toString ().toStdWString () CAT_TRACE ("custom command" << command.toString ().toStdWString ()
<< "with reply" << reply.toString ().toStdWString () << "with reply" << reply.toString ().toStdWString ()
<< QString ("for rig %1").arg (rig_number).toStdWString ()); << QString ("for rig %1").arg (rig_number).toStdWString ());
TRACE_CAT ("rig number:" << rig_number_ << ':' << state ()); CAT_TRACE ("rig number:" << rig_number_ << ':' << state ());
} }
} }
void OmniRigTransceiver::do_ptt (bool on) void OmniRigTransceiver::do_ptt (bool on)
{ {
TRACE_CAT (on << state ()); CAT_TRACE (on << state ());
if (use_for_ptt_ && TransceiverFactory::PTT_method_CAT == ptt_type_) if (use_for_ptt_ && TransceiverFactory::PTT_method_CAT == ptt_type_)
{ {
TRACE_CAT ("set PTT"); CAT_TRACE ("set PTT");
if (rig_ && !rig_->isNull ()) if (rig_ && !rig_->isNull ())
{ {
rig_->SetTx (on ? OmniRig::PM_TX : OmniRig::PM_RX); rig_->SetTx (on ? OmniRig::PM_TX : OmniRig::PM_RX);
@ -688,18 +688,18 @@ void OmniRigTransceiver::do_ptt (bool on)
{ {
if (TransceiverFactory::PTT_method_RTS == ptt_type_) if (TransceiverFactory::PTT_method_RTS == ptt_type_)
{ {
TRACE_CAT ("set RTS"); CAT_TRACE ("set RTS");
port_->SetRts (on); port_->SetRts (on);
} }
else // "DTR" else // "DTR"
{ {
TRACE_CAT ("set DTR"); CAT_TRACE ("set DTR");
port_->SetDtr (on); port_->SetDtr (on);
} }
} }
else if (wrapped_) else if (wrapped_)
{ {
TRACE_CAT ("set PTT using basic transceiver"); CAT_TRACE ("set PTT using basic transceiver");
TransceiverState new_state {wrapped_->state ()}; TransceiverState new_state {wrapped_->state ()};
new_state.ptt (on); new_state.ptt (on);
wrapped_->set (new_state, 0); wrapped_->set (new_state, 0);
@ -710,7 +710,7 @@ void OmniRigTransceiver::do_ptt (bool on)
void OmniRigTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/) void OmniRigTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
{ {
TRACE_CAT (f << state ()); CAT_TRACE (f << state ());
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
if (UNK != m) if (UNK != m)
{ {
@ -739,7 +739,7 @@ void OmniRigTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
void OmniRigTransceiver::do_tx_frequency (Frequency tx, MODE m, bool /*no_ignore*/) void OmniRigTransceiver::do_tx_frequency (Frequency tx, MODE m, bool /*no_ignore*/)
{ {
TRACE_CAT (tx << state ()); CAT_TRACE (tx << state ());
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
bool split {tx != 0}; bool split {tx != 0};
if (split) if (split)
@ -769,14 +769,14 @@ void OmniRigTransceiver::do_tx_frequency (Frequency tx, MODE m, bool /*no_ignore
} }
} }
} }
TRACE_CAT ("set SPLIT mode on"); CAT_TRACE ("set SPLIT mode on");
rig_->SetSplitMode (state ().frequency (), tx); rig_->SetSplitMode (state ().frequency (), tx);
update_other_frequency (tx); update_other_frequency (tx);
update_split (true); update_split (true);
} }
else else
{ {
TRACE_CAT ("set SPLIT mode off"); CAT_TRACE ("set SPLIT mode off");
rig_->SetSimplexMode (state ().frequency ()); rig_->SetSimplexMode (state ().frequency ());
update_split (false); update_split (false);
} }
@ -791,7 +791,7 @@ void OmniRigTransceiver::do_tx_frequency (Frequency tx, MODE m, bool /*no_ignore
} }
if (!((OmniRig::PM_VFOAB | OmniRig::PM_VFOBA | OmniRig::PM_SPLITON) & readable_params_)) if (!((OmniRig::PM_VFOAB | OmniRig::PM_VFOBA | OmniRig::PM_SPLITON) & readable_params_))
{ {
TRACE_CAT ("setting SPLIT manually"); CAT_TRACE ("setting SPLIT manually");
update_split (split); // we can't read it so just set and update_split (split); // we can't read it so just set and
// hope op doesn't change it // hope op doesn't change it
notify = true; notify = true;
@ -804,7 +804,7 @@ void OmniRigTransceiver::do_tx_frequency (Frequency tx, MODE m, bool /*no_ignore
void OmniRigTransceiver::do_mode (MODE mode) void OmniRigTransceiver::do_mode (MODE mode)
{ {
TRACE_CAT (mode << state ()); CAT_TRACE (mode << state ());
if (!rig_ || rig_->isNull ()) return; if (!rig_ || rig_->isNull ()) return;
// TODO: G4WJS OmniRig doesn't seem to have any capability of tracking/setting VFO B mode // TODO: G4WJS OmniRig doesn't seem to have any capability of tracking/setting VFO B mode
auto mapped = map_mode (mode); auto mapped = map_mode (mode);

View File

@ -41,7 +41,7 @@ void TransceiverBase::start (unsigned sequence_number) noexcept
void TransceiverBase::set (TransceiverState const& s, void TransceiverBase::set (TransceiverState const& s,
unsigned sequence_number) noexcept unsigned sequence_number) noexcept
{ {
TRACE_CAT ("#: " << sequence_number << " " << s); CAT_TRACE ("#: " << sequence_number << " " << s);
QString message; QString message;
try try

View File

@ -153,8 +153,12 @@ private:
unsigned last_sequence_number_; // from set state operation unsigned last_sequence_number_; // from set state operation
}; };
// some trace macros // some loggimg macros
#define TRACE_CAT(MSG) LOG_LOG_LOCATION (logger (), trace, MSG) #define CAT_TRACE(MSG) LOG_LOG_LOCATION (logger (), trace, MSG)
#define TRACE_CAT_POLL(MSG) LOG_LOG_LOCATION (logger (), trace, MSG) #define CAT_DEBUG(MSG) LOG_LOG_LOCATION (logger (), debug, MSG)
#define CAT_INFO(MSG) LOG_LOG_LOCATION (logger (), info, MSG)
#define CAT_WARNING(MSG) LOG_LOG_LOCATION (logger (), warning, MSG)
#define CAT_ERROR(MSG) LOG_LOG_LOCATION (logger (), error, MSG)
#define CAT_FATAL(MSG) LOG_LOG_LOCATION (logger (), fatal, MSG)
#endif #endif