From 74ada0ff4c4899b79f5a7c65f000f2d6aa05ebc6 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 9 Sep 2015 12:16:22 +0000 Subject: [PATCH] Resolve a long standing rig control corner case This change allows serial control lines to be forced high or low (DTR or RTS) while using the other (RTS, DTR) for PTT on the CAT serial port. It is only needed for some very obscure and rare serial line powered interfaces. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5869 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 99 +++++++++++++++++++++++------------------- Configuration.ui | 97 +++++++++++++++++++++++++++++------------ HamlibTransceiver.cpp | 5 ++- TransceiverFactory.hpp | 6 ++- 4 files changed, 132 insertions(+), 75 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index 7999c72cd..717ac6542 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -394,9 +394,8 @@ private: Q_SLOT void on_split_mode_button_group_buttonClicked (int); Q_SLOT void on_test_CAT_push_button_clicked (); Q_SLOT void on_test_PTT_push_button_clicked (bool checked); - Q_SLOT void on_CAT_control_lines_group_box_toggled (bool); - Q_SLOT void on_CAT_DTR_check_box_toggled (bool); - Q_SLOT void on_CAT_RTS_check_box_toggled (bool); + Q_SLOT void on_force_DTR_combo_box_currentIndexChanged (int); + Q_SLOT void on_force_RTS_combo_box_currentIndexChanged (int); Q_SLOT void on_rig_combo_box_currentIndexChanged (int); Q_SLOT void on_sound_input_combo_box_currentTextChanged (QString const&); Q_SLOT void on_sound_output_combo_box_currentTextChanged (QString const&); @@ -1048,9 +1047,22 @@ void Configuration::impl::initialize_models () ui_->CAT_data_bits_button_group->button (rig_params_.data_bits)->setChecked (true); ui_->CAT_stop_bits_button_group->button (rig_params_.stop_bits)->setChecked (true); ui_->CAT_handshake_button_group->button (rig_params_.handshake)->setChecked (true); - ui_->CAT_control_lines_group_box->setChecked (rig_params_.force_line_control); - ui_->CAT_DTR_check_box->setChecked (rig_params_.dtr_high); - ui_->CAT_RTS_check_box->setChecked (rig_params_.rts_high); + if (rig_params_.force_dtr) + { + ui_->force_DTR_combo_box->setCurrentIndex (rig_params_.dtr_high ? 1 : 2); + } + else + { + ui_->force_DTR_combo_box->setCurrentIndex (0); + } + if (rig_params_.force_rts) + { + ui_->force_RTS_combo_box->setCurrentIndex (rig_params_.rts_high ? 1 : 2); + } + else + { + ui_->force_RTS_combo_box->setCurrentIndex (0); + } ui_->TX_audio_source_button_group->button (rig_params_.audio_source)->setChecked (true); ui_->CAT_poll_interval_spin_box->setValue (rig_params_.poll_interval); ui_->udp_server_line_edit->setText (udp_server_name_); @@ -1223,8 +1235,9 @@ void Configuration::impl::read_settings () rig_params_.data_bits = settings_->value ("CATDataBits", QVariant::fromValue (TransceiverFactory::eight_data_bits)).value (); rig_params_.stop_bits = settings_->value ("CATStopBits", QVariant::fromValue (TransceiverFactory::two_stop_bits)).value (); rig_params_.handshake = settings_->value ("CATHandshake", QVariant::fromValue (TransceiverFactory::handshake_none)).value (); - rig_params_.force_line_control = settings_->value ("CATForceControlLines", false).toBool (); + rig_params_.force_dtr = settings_->value ("CATForceDTR", false).toBool (); rig_params_.dtr_high = settings_->value ("DTR", false).toBool (); + rig_params_.force_rts = settings_->value ("CATForceRTS", false).toBool (); rig_params_.rts_high = settings_->value ("RTS", false).toBool (); rig_params_.ptt_type = settings_->value ("PTTMethod", QVariant::fromValue (TransceiverFactory::PTT_method_VOX)).value (); rig_params_.audio_source = settings_->value ("TXAudioSource", QVariant::fromValue (TransceiverFactory::TX_audio_source_front)).value (); @@ -1322,8 +1335,9 @@ void Configuration::impl::write_settings () settings_->setValue ("73TxDisable", disable_TX_on_73_); settings_->setValue ("Runaway", watchdog_); settings_->setValue ("Tx2QSO", TX_messages_); - settings_->setValue ("CATForceControlLines", rig_params_.force_line_control); + settings_->setValue ("CATForceDTR", rig_params_.force_dtr); settings_->setValue ("DTR", rig_params_.dtr_high); + settings_->setValue ("CATForceRTS", rig_params_.force_rts); settings_->setValue ("RTS", rig_params_.rts_high); settings_->setValue ("TXAudioSource", QVariant::fromValue (rig_params_.audio_source)); settings_->setValue ("Polling", rig_params_.poll_interval); @@ -1360,6 +1374,23 @@ void Configuration::impl::set_rig_invariants () auto port_type = transceiver_factory_.CAT_port_type (rig); bool is_serial_CAT (TransceiverFactory::Capabilities::serial == port_type); + auto const& cat_port = ui_->CAT_port_combo_box->currentText (); + + // only enable CAT option if transceiver has CAT PTT + ui_->PTT_CAT_radio_button->setEnabled (CAT_PTT_enabled); + + auto enable_ptt_port = TransceiverFactory::PTT_method_CAT != ptt_method && TransceiverFactory::PTT_method_VOX != ptt_method; + ui_->PTT_port_combo_box->setEnabled (enable_ptt_port); + ui_->PTT_port_label->setEnabled (enable_ptt_port); + + ui_->PTT_port_combo_box->setItemData (ui_->PTT_port_combo_box->findText ("CAT") + , CAT_indirect_serial_PTT ? combo_box_item_enabled : combo_box_item_disabled + , Qt::UserRole - 1); + + ui_->PTT_DTR_radio_button->setEnabled (!("CAT" == ptt_port && !CAT_indirect_serial_PTT)); + + ui_->PTT_RTS_radio_button->setEnabled (!((is_serial_CAT && ptt_port == cat_port && is_hw_handshake) + || ("CAT" == ptt_port && !CAT_indirect_serial_PTT))); if (TransceiverFactory::basic_transceiver_name_ == rig) { @@ -1420,34 +1451,16 @@ void Configuration::impl::set_rig_invariants () } } ui_->CAT_serial_port_parameters_group_box->setEnabled (is_serial_CAT); - ui_->CAT_control_lines_group_box->setEnabled (is_serial_CAT); - ui_->CAT_RTS_check_box->setEnabled (is_serial_CAT - && ui_->CAT_control_lines_group_box->isChecked () - && !is_hw_handshake); + ui_->force_DTR_combo_box->setEnabled (is_serial_CAT + && (cat_port != ptt_port + || !ui_->PTT_DTR_radio_button->isEnabled () + || !ui_->PTT_DTR_radio_button->isChecked ())); + ui_->force_RTS_combo_box->setEnabled (is_serial_CAT + && !is_hw_handshake + && (cat_port != ptt_port + || !ui_->PTT_RTS_radio_button->isEnabled () + || !ui_->PTT_RTS_radio_button->isChecked ())); } - - auto const& cat_port = ui_->CAT_port_combo_box->currentText (); - - // only enable CAT option if transceiver has CAT PTT - ui_->PTT_CAT_radio_button->setEnabled (CAT_PTT_enabled); - - auto enable_ptt_port = TransceiverFactory::PTT_method_CAT != ptt_method && TransceiverFactory::PTT_method_VOX != ptt_method; - ui_->PTT_port_combo_box->setEnabled (enable_ptt_port); - ui_->PTT_port_label->setEnabled (enable_ptt_port); - - ui_->PTT_port_combo_box->setItemData (ui_->PTT_port_combo_box->findText ("CAT") - , CAT_indirect_serial_PTT ? combo_box_item_enabled : combo_box_item_disabled - , Qt::UserRole - 1); - - auto control_lines_available = !ui_->CAT_control_lines_group_box->isEnabled () - || !ui_->CAT_control_lines_group_box->isChecked (); - ui_->PTT_DTR_radio_button->setEnabled (!(((is_serial_CAT && ptt_port == cat_port) - && !control_lines_available) - || ("CAT" == ptt_port && !CAT_indirect_serial_PTT))); - - ui_->PTT_RTS_radio_button->setEnabled (!(((is_serial_CAT && ptt_port == cat_port) - && (!control_lines_available || is_hw_handshake)) - || ("CAT" == ptt_port && !CAT_indirect_serial_PTT))); } bool Configuration::impl::validate () @@ -1522,9 +1535,10 @@ TransceiverFactory::ParameterPack Configuration::impl::gather_rig_data () result.data_bits = static_cast (ui_->CAT_data_bits_button_group->checkedId ()); result.stop_bits = static_cast (ui_->CAT_stop_bits_button_group->checkedId ()); result.handshake = static_cast (ui_->CAT_handshake_button_group->checkedId ()); - result.force_line_control = ui_->CAT_control_lines_group_box->isChecked (); - result.dtr_high = ui_->CAT_DTR_check_box->isChecked (); - result.rts_high = ui_->CAT_RTS_check_box->isChecked (); + result.force_dtr = ui_->force_DTR_combo_box->isEnabled () && ui_->force_DTR_combo_box->currentIndex () > 0; + result.dtr_high = 1 == ui_->force_DTR_combo_box->currentIndex (); + result.force_rts = ui_->force_RTS_combo_box->isEnabled () && ui_->force_RTS_combo_box->currentIndex () > 0; + result.rts_high = 1 == ui_->force_RTS_combo_box->currentIndex (); result.poll_interval = ui_->CAT_poll_interval_spin_box->value (); result.ptt_type = static_cast (ui_->PTT_method_button_group->checkedId ()); result.ptt_port = ui_->PTT_port_combo_box->currentText (); @@ -1911,17 +1925,12 @@ void Configuration::impl::on_test_PTT_push_button_clicked (bool checked) } } -void Configuration::impl::on_CAT_control_lines_group_box_toggled (bool /* checked */) +void Configuration::impl::on_force_DTR_combo_box_currentIndexChanged (int /* index */) { set_rig_invariants (); } -void Configuration::impl::on_CAT_DTR_check_box_toggled (bool /* checked */) -{ - set_rig_invariants (); -} - -void Configuration::impl::on_CAT_RTS_check_box_toggled (bool /* checked */) +void Configuration::impl::on_force_RTS_combo_box_currentIndexChanged (int /* index */) { set_rig_invariants (); } diff --git a/Configuration.ui b/Configuration.ui index 6e88f0f8b..3d067d634 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -669,32 +669,75 @@ a few, particularly some Kenwood rigs, require it). Force Control Lines - - true - false - - - <html><head/><body><p>Force the DTR control linelow or high on the CAT serial port.</p><p>This is required for a few CAT interfaces that are powered</p><p>from the DTR control line.</p><p>Normally you should leave this unchecked.</p></body></html> - - - DTR - - + + + + + DTR: + + + force_DTR_combo_box + + + + + + + + + + + + + High + + + + + Low + + + + + - - - <html><head/><body><p>Force the RTS control line low or high on the CAT serial port.</p><p>This is required for a few CAT interfaces that are powered</p><p>from the RTS control line.</p><p>Normally you should leave this unchecked.</p><p>This option is only available if Hardware handshaking is not</p><p>selected above.</p></body></html> - - - RTS - - + + + + + RTS: + + + force_RTS_combo_box + + + + + + + + + + + + + High + + + + + Low + + + + + @@ -2278,12 +2321,11 @@ soundcard changes CAT_handshake_none_radio_button CAT_handshake_xon_radio_button CAT_handshake_hardware_radio_button - CAT_control_lines_group_box - CAT_DTR_check_box - CAT_RTS_check_box + force_DTR_combo_box + force_RTS_combo_box PTT_VOX_radio_button - PTT_CAT_radio_button PTT_DTR_radio_button + PTT_CAT_radio_button PTT_RTS_radio_button PTT_port_combo_box TX_source_data_radio_button @@ -2301,6 +2343,7 @@ soundcard changes sound_output_combo_box sound_output_channel_combo_box save_path_select_push_button + azel_path_select_push_button jt9w_bandwidth_mult_combo_box jt9w_min_dt_double_spin_box jt9w_max_dt_double_spin_box @@ -2397,12 +2440,12 @@ soundcard changes - - - - + + + + diff --git a/HamlibTransceiver.cpp b/HamlibTransceiver.cpp index ce2ee6ec6..af4685aeb 100644 --- a/HamlibTransceiver.cpp +++ b/HamlibTransceiver.cpp @@ -258,9 +258,12 @@ HamlibTransceiver::HamlibTransceiver (int model_number, TransceiverFactory::Para case TransceiverFactory::handshake_hardware: set_conf ("serial_handshake", "Hardware"); break; } - if (params.force_line_control) + 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"); diff --git a/TransceiverFactory.hpp b/TransceiverFactory.hpp index 7d0ad18a2..09fc8008d 100644 --- a/TransceiverFactory.hpp +++ b/TransceiverFactory.hpp @@ -96,8 +96,9 @@ public: DataBits data_bits; StopBits stop_bits; Handshake handshake; - bool force_line_control; + bool force_dtr; bool dtr_high; // to power interface + bool force_rts; bool rts_high; // to power interface PTTMethod ptt_type; // "CAT" | "DTR" | "RTS" | "VOX" TXAudioSource audio_source; // some rigs allow audio routing @@ -117,8 +118,9 @@ public: && rhs.data_bits == data_bits && rhs.stop_bits == stop_bits && rhs.handshake == handshake - && rhs.force_line_control == force_line_control + && rhs.force_dtr == force_dtr && rhs.dtr_high == dtr_high + && rhs.force_rts == force_rts && rhs.rts_high == rts_high && rhs.ptt_type == ptt_type && rhs.audio_source == audio_source