Add support for Hamlib USB rig types

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6144 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-11-21 20:23:30 +00:00
parent 6c6a758b8b
commit 19779fa002
3 changed files with 57 additions and 24 deletions

View File

@ -1249,6 +1249,7 @@ void Configuration::impl::read_settings ()
rig_params_.rig_name = settings_->value ("Rig", TransceiverFactory::basic_transceiver_name_).toString ();
rig_is_dummy_ = TransceiverFactory::basic_transceiver_name_ == rig_params_.rig_name;
rig_params_.network_port = settings_->value ("CATNetworkPort").toString ();
rig_params_.usb_port = settings_->value ("CATUSBPort").toString ();
rig_params_.serial_port = settings_->value ("CATSerialPort").toString ();
rig_params_.baud = settings_->value ("CATSerialRate", 4800).toInt ();
rig_params_.data_bits = settings_->value ("CATDataBits", QVariant::fromValue (TransceiverFactory::eight_data_bits)).value<TransceiverFactory::DataBits> ();
@ -1345,6 +1346,7 @@ void Configuration::impl::write_settings ()
settings_->setValue ("dBtoComments", report_in_comments_);
settings_->setValue ("Rig", rig_params_.rig_name);
settings_->setValue ("CATNetworkPort", rig_params_.network_port);
settings_->setValue ("CATUSBPort", rig_params_.usb_port);
settings_->setValue ("CATSerialPort", rig_params_.serial_port);
settings_->setValue ("CATSerialRate", rig_params_.baud);
settings_->setValue ("CATDataBits", QVariant::fromValue (rig_params_.data_bits));
@ -1476,6 +1478,17 @@ void Configuration::impl::set_rig_invariants ()
ui_->CAT_port_combo_box->setEnabled (true);
break;
case TransceiverFactory::Capabilities::usb:
ui_->CAT_port_combo_box->clear ();
ui_->CAT_port_combo_box->setCurrentText (rig_params_.usb_port);
ui_->CAT_port_label->setText (tr ("USB Device:"));
ui_->CAT_port_combo_box->setToolTip (tr ("Optional device identification.\n"
"Leave blank for a sensible default for the rig.\n"
"Format:\n"
"\t[VID[:PID[:VENDOR[:PRODUCT]]]]"));
ui_->CAT_port_combo_box->setEnabled (true);
break;
default:
ui_->CAT_port_combo_box->clear ();
ui_->CAT_port_combo_box->setEnabled (false);
@ -1554,12 +1567,20 @@ TransceiverFactory::ParameterPack Configuration::impl::gather_rig_data ()
{
case TransceiverFactory::Capabilities::network:
result.network_port = ui_->CAT_port_combo_box->currentText ();
result.usb_port = rig_params_.usb_port;
result.serial_port = rig_params_.serial_port;
break;
case TransceiverFactory::Capabilities::usb:
result.usb_port = ui_->CAT_port_combo_box->currentText ();
result.network_port = rig_params_.network_port;
result.serial_port = rig_params_.serial_port;
break;
default:
result.serial_port = ui_->CAT_port_combo_box->currentText ();
result.network_port = rig_params_.network_port;
result.usb_port = rig_params_.usb_port;
break;
}

View File

@ -84,6 +84,10 @@ namespace
port_type = TransceiverFactory::Capabilities::network;
break;
case RIG_PORT_USB:
port_type = TransceiverFactory::Capabilities::usb;
break;
default: break;
}
(*rigs)[key] = TransceiverFactory::Capabilities (caps->rig_model
@ -233,6 +237,28 @@ HamlibTransceiver::HamlibTransceiver (int model_number, TransceiverFactory::Para
{
set_conf ("rig_pathname", params.serial_port.toLatin1 ().data ());
}
set_conf ("serial_speed", QByteArray::number (params.baud).data ());
set_conf ("data_bits", TransceiverFactory::seven_data_bits == params.data_bits ? "7" : "8");
set_conf ("stop_bits", TransceiverFactory::one_stop_bit == params.stop_bits ? "1" : "2");
switch (params.handshake)
{
case TransceiverFactory::handshake_none: set_conf ("serial_handshake", "None"); break;
case TransceiverFactory::handshake_XonXoff: set_conf ("serial_handshake", "XONXOFF"); break;
case TransceiverFactory::handshake_hardware: set_conf ("serial_handshake", "Hardware"); break;
}
if (params.force_dtr)
{
set_conf ("dtr_state", params.dtr_high ? "ON" : "OFF");
}
if (params.force_rts)
{
if (TransceiverFactory::handshake_hardware != params.handshake)
{
set_conf ("rts_state", params.rts_high ? "ON" : "OFF");
}
}
break;
case RIG_PORT_NETWORK:
@ -242,33 +268,17 @@ HamlibTransceiver::HamlibTransceiver (int model_number, TransceiverFactory::Para
}
break;
case RIG_PORT_USB:
if (!params.usb_port.isEmpty ())
{
set_conf ("rig_pathname", params.usb_port.toLatin1 ().data ());
}
break;
default:
throw error {tr ("Unsupported CAT type")};
break;
}
set_conf ("serial_speed", QByteArray::number (params.baud).data ());
set_conf ("data_bits", TransceiverFactory::seven_data_bits == params.data_bits ? "7" : "8");
set_conf ("stop_bits", TransceiverFactory::one_stop_bit == params.stop_bits ? "1" : "2");
switch (params.handshake)
{
case TransceiverFactory::handshake_none: set_conf ("serial_handshake", "None"); break;
case TransceiverFactory::handshake_XonXoff: set_conf ("serial_handshake", "XONXOFF"); break;
case TransceiverFactory::handshake_hardware: set_conf ("serial_handshake", "Hardware"); break;
}
if (params.force_dtr)
{
set_conf ("dtr_state", params.dtr_high ? "ON" : "OFF");
}
if (params.force_rts)
{
if (TransceiverFactory::handshake_hardware != params.handshake)
{
set_conf ("rts_state", params.rts_high ? "ON" : "OFF");
}
}
}
switch (params.ptt_type)

View File

@ -31,7 +31,7 @@ public:
//
struct Capabilities
{
enum PortType {none, serial, network};
enum PortType {none, serial, network, usb};
explicit Capabilities (int model_number = 0
, PortType port_type = none
@ -92,6 +92,7 @@ public:
QString rig_name; // from supported_transceivers () key
QString serial_port; // serial port device name or empty
QString network_port; // hostname:port or empty
QString usb_port; // [vid[:pid[:vendor[:product]]]]
int baud;
DataBits data_bits;
StopBits stop_bits;
@ -114,6 +115,7 @@ public:
return rhs.rig_name == rig_name
&& rhs.serial_port == serial_port
&& rhs.network_port == network_port
&& rhs.usb_port == usb_port
&& rhs.baud == baud
&& rhs.data_bits == data_bits
&& rhs.stop_bits == stop_bits