Generate a file with HRD interface information.

To aid rapid  diagnosis of missing HRD support in  WSJT-X for untested
rigs the HRD  interface now writes a text file  with the available HRD
facilities for the  rig to the data directory.  The  intent is to have
users experiencing  problems interfacing  untested rigs to  sub,it the
file to us  (the developers) for analysis and updating  the regexps in
teh HRD interface to support their rig in the next release.

The text file is called "HRD Interface Information.txt".

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4330 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2014-09-17 15:17:32 +00:00
parent 44ce626cd6
commit c58ee3b909
5 changed files with 220 additions and 168 deletions

View File

@ -1746,7 +1746,9 @@ bool Configuration::impl::open_rig ()
, static_cast<TransceiverFactory::SplitMode> (ui_->split_mode_button_group->checkedId ())
, ui_->PTT_port_combo_box->currentText ()
, ui_->CAT_poll_interval_spin_box->value () * 1000
, &transceiver_thread_);
, data_path_
, &transceiver_thread_
);
// hook up Configuration transceiver control signals to Transceiver slots
//

View File

@ -63,11 +63,16 @@ struct HRDMessage
qint32 const HRDMessage::magic_1_value_ (0x1234ABCD);
qint32 const HRDMessage::magic_2_value_ (0xABCD1234);
HRDTransceiver::HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped, QString const& server, bool use_for_ptt, int poll_interval)
HRDTransceiver::HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped
, QString const& server
, bool use_for_ptt
, int poll_interval
, QDir const& data_path)
: PollingTransceiver {poll_interval}
, wrapped_ {std::move (wrapped)}
, use_for_ptt_ {use_for_ptt}
, server_ {server}
, data_path_ {data_path}
, hrd_ {0}
, protocol_ {none}
, current_radio_ {0}
@ -150,11 +155,25 @@ void HRDTransceiver::do_start ()
send_command ("get context", false, false);
}
QString HRD_info_path {data_path_.absoluteFilePath ("HRD Interface Information.txt")};
QFile HRD_info_file {HRD_info_path};
if (!HRD_info_file.open (QFile::WriteOnly | QFile::Text | QFile::Truncate))
{
throw error {tr ("Failed to open file \"%1\".").arg (HRD_info_path)};
}
QTextStream HRD_info {&HRD_info_file};
auto id = send_command ("get id", false, false);
auto version = send_command ("get version", false, false);
#if WSJT_TRACE_CAT
qDebug () << send_command ("get id", false, false);
qDebug () << send_command ("get version", false, false);
qDebug () << "Id:" << id;
qDebug () << "Version:" << version;
#endif
HRD_info << "Id: " << id << "\n";
HRD_info << "Version: " << version << "\n";
auto radios = send_command ("get radios", false, false).trimmed ().split (',', QString::SkipEmptyParts);
if (radios.isEmpty ())
{
@ -165,8 +184,10 @@ void HRDTransceiver::do_start ()
throw error {tr ("Ham Radio Deluxe: no rig found")};
}
HRD_info << "Radios:\n";
Q_FOREACH (auto const& radio, radios)
{
HRD_info << "\t" << radio << "\n";
auto entries = radio.trimmed ().split (':', QString::SkipEmptyParts);
radios_.push_back (std::forward_as_tuple (entries[0].toUInt (), entries[1]));
}
@ -179,7 +200,9 @@ void HRDTransceiver::do_start ()
}
#endif
if (send_command ("get radio", false, false, true).isEmpty ())
auto current_radio_name = send_command ("get radio", false, false, true);
HRD_info << "Current radio: " << current_radio_name << "\n";
if (current_radio_name.isEmpty ())
{
#if WSJT_TRACE_CAT
qDebug () << "HRDTransceiver::do_start no rig found";
@ -189,23 +212,37 @@ void HRDTransceiver::do_start ()
}
vfo_count_ = send_command ("get vfo-count").toUInt ();
HRD_info << "VFO count: " << vfo_count_ << "\n";
#if WSJT_TRACE_CAT
qDebug () << "vfo count:" << vfo_count_;
#endif
buttons_ = send_command ("get buttons").trimmed ().split (',', QString::SkipEmptyParts).replaceInStrings (" ", "~");
#if WSJT_TRACE_CAT
qDebug () << "HRD Buttons: " << buttons_;
#endif
HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n";
dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', QString::SkipEmptyParts);
Q_FOREACH (auto d, dropdown_names_)
HRD_info << "Dropdowns:\n";
Q_FOREACH (auto const& dd, dropdown_names_)
{
dropdowns_[d] = send_command ("get dropdown-list {" + d + "}").trimmed ().split (',', QString::SkipEmptyParts);
auto selections = send_command ("get dropdown-list {" + dd + "}").trimmed ().split (',', QString::SkipEmptyParts);
HRD_info << "\t" << dd << ": {" << selections.join (", ") << "}\n";
dropdowns_[dd] = selections;
}
#if WSJT_TRACE_CAT
qDebug () << "HRD Dropdowns: " << dropdowns_;
#endif
sliders_ = send_command ("get sliders").trimmed ().split (',', QString::SkipEmptyParts).replaceInStrings (" ", "~");
HRD_info << "Sliders:\n";
HRD_info << "Sliders: {" << sliders_.join (", ") << "}\n";
Q_FOREACH (auto const& s, sliders_)
{
auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', QString::SkipEmptyParts);
HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n";
}
#if WSJT_TRACE_CAT
qDebug () << "HRD Dropdowns: " << dropdowns_;
#endif

View File

@ -8,6 +8,7 @@
#include <QScopedPointer>
#include <QString>
#include <QStringList>
#include <QDir>
#include "TransceiverFactory.hpp"
#include "PollingTransceiver.hpp"
@ -30,7 +31,11 @@ public:
static void register_transceivers (TransceiverFactory::Transceivers *, int id);
// takes ownership of wrapped Transceiver
explicit HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped, QString const& server, bool use_for_ptt, int poll_interval);
explicit HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped
, QString const& server
, bool use_for_ptt
, int poll_interval
, QDir const& data_path);
~HRDTransceiver ();
protected:
@ -77,6 +82,8 @@ private:
QString server_; // The TCP/IP addrress and port for
// the HRD server.
QDir data_path_; // Directory to write files to
QTcpSocket * hrd_; // The TCP/IP client that links to the
// HRD server.
@ -100,6 +107,8 @@ private:
// drop down selections
// available.
QStringList sliders_; // The sliders available.
int vfo_A_button_; // The button we use to select VFO
// A. May be -1 if none available.

View File

@ -107,7 +107,9 @@ std::unique_ptr<Transceiver> TransceiverFactory::create (QString const& name
, SplitMode split_mode
, QString const& ptt_port
, int poll_interval
, QThread * target_thread)
, QDir const& data_path
, QThread * target_thread
)
{
std::unique_ptr<Transceiver> result;
switch (supported_transceivers ()[name].model_number_)
@ -168,7 +170,7 @@ std::unique_ptr<Transceiver> TransceiverFactory::create (QString const& name
}
// wrap the basic Transceiver object instance with a decorator object that talks to ham Radio Deluxe
result.reset (new HRDTransceiver {std::move (basic_transceiver), cat_port, PTT_method_CAT == ptt_type, poll_interval});
result.reset (new HRDTransceiver {std::move (basic_transceiver), cat_port, PTT_method_CAT == ptt_type, poll_interval, data_path});
if (target_thread)
{
result.get ()->moveToThread (target_thread);

View File

@ -12,6 +12,7 @@
class QString;
class QThread;
class QDir;
//
// Transceiver Factory
@ -111,6 +112,7 @@ public:
, SplitMode split_mode // how to support split TX mode
, QString const& ptt_port // serial port device name or special value "CAT"
, int poll_interval // in milliseconds for interfaces that require polling for parameter changes
, QDir const& data_path
, QThread * target_thread = nullptr
);