From 181bc8cc7cc9e333b1e39497cf437b9567046ee7 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 16 Mar 2018 22:00:33 +0000 Subject: [PATCH] Add default options for Hamlib CAT serial data bits, stop bits, and handshaking Hamlib has deafult values for these options that are nearly always correct so we can offer a default option in WSJT-X which in turn is the defaulty option. Thanks to Mike, W9MDB, for the builk of this contribution. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8568 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 9 +++-- Configuration.ui | 84 +++++++++++++++++++++++++++++++----------- HamlibTransceiver.cpp | 11 +++++- TransceiverFactory.hpp | 6 +-- 4 files changed, 81 insertions(+), 29 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index b1cab5b65..0524da1f6 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -955,12 +955,15 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory, // // assign ids to radio buttons // + ui_->CAT_data_bits_button_group->setId (ui_->CAT_default_bit_radio_button, TransceiverFactory::default_data_bits); ui_->CAT_data_bits_button_group->setId (ui_->CAT_7_bit_radio_button, TransceiverFactory::seven_data_bits); ui_->CAT_data_bits_button_group->setId (ui_->CAT_8_bit_radio_button, TransceiverFactory::eight_data_bits); + ui_->CAT_stop_bits_button_group->setId (ui_->CAT_default_stop_bit_radio_button, TransceiverFactory::default_stop_bits); ui_->CAT_stop_bits_button_group->setId (ui_->CAT_one_stop_bit_radio_button, TransceiverFactory::one_stop_bit); ui_->CAT_stop_bits_button_group->setId (ui_->CAT_two_stop_bit_radio_button, TransceiverFactory::two_stop_bits); + ui_->CAT_handshake_button_group->setId (ui_->CAT_handshake_default_radio_button, TransceiverFactory::handshake_default); ui_->CAT_handshake_button_group->setId (ui_->CAT_handshake_none_radio_button, TransceiverFactory::handshake_none); ui_->CAT_handshake_button_group->setId (ui_->CAT_handshake_xon_radio_button, TransceiverFactory::handshake_XonXoff); ui_->CAT_handshake_button_group->setId (ui_->CAT_handshake_hardware_radio_button, TransceiverFactory::handshake_hardware); @@ -1367,9 +1370,9 @@ void Configuration::impl::read_settings () 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 (); - 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_.data_bits = settings_->value ("CATDataBits", QVariant::fromValue (TransceiverFactory::default_data_bits)).value (); + rig_params_.stop_bits = settings_->value ("CATStopBits", QVariant::fromValue (TransceiverFactory::default_stop_bits)).value (); + rig_params_.handshake = settings_->value ("CATHandshake", QVariant::fromValue (TransceiverFactory::handshake_default)).value (); 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 (); diff --git a/Configuration.ui b/Configuration.ui index 64bcef6e8..d1a7eb113 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -6,8 +6,8 @@ 0 0 - 534 - 530 + 530 + 550 @@ -644,11 +644,27 @@ text message. Data Bits + + + + D&efault + + + true + + + CAT_data_bits_button_group + + + Se&ven + + true + CAT_data_bits_button_group @@ -660,7 +676,7 @@ text message. E&ight - true + false CAT_data_bits_button_group @@ -679,6 +695,19 @@ text message. Stop Bits + + + + Default + + + true + + + CAT_stop_bits_button_group + + + @@ -695,7 +724,7 @@ text message. T&wo - true + false CAT_stop_bits_button_group @@ -715,9 +744,9 @@ text message. - + - &None + Default true @@ -728,6 +757,19 @@ text message. + + + &None + + + false + + + CAT_handshake_button_group + + + + Software flow control (very rare on CAT interfaces). @@ -740,7 +782,7 @@ text message. - + Flow control using the RTS and CTS RS-232 control lines @@ -772,16 +814,6 @@ a few, particularly some Kenwood rigs, require it). - - - - DTR: - - - force_DTR_combo_box - - - @@ -801,6 +833,16 @@ a few, particularly some Kenwood rigs, require it). + + + + DTR: + + + force_DTR_combo_box + + + @@ -2780,12 +2822,12 @@ soundcard changes + + + + - - - - diff --git a/HamlibTransceiver.cpp b/HamlibTransceiver.cpp index 473f761d3..186d866d0 100644 --- a/HamlibTransceiver.cpp +++ b/HamlibTransceiver.cpp @@ -316,14 +316,21 @@ 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"); + if (params.data_bits != TransceiverFactory::default_data_bits) + { + set_conf ("data_bits", TransceiverFactory::seven_data_bits == params.data_bits ? "7" : "8"); + } + if (params.stop_bits != TransceiverFactory::default_stop_bits) + { + 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; + default: break; } if (params.force_dtr) diff --git a/TransceiverFactory.hpp b/TransceiverFactory.hpp index f7b5167cb..4c0cd1932 100644 --- a/TransceiverFactory.hpp +++ b/TransceiverFactory.hpp @@ -64,11 +64,11 @@ public: // // various Transceiver parameters // - enum DataBits {seven_data_bits = 7, eight_data_bits}; + enum DataBits {seven_data_bits = 7, eight_data_bits, default_data_bits}; Q_ENUM (DataBits) - enum StopBits {one_stop_bit = 1, two_stop_bits}; + enum StopBits {one_stop_bit = 1, two_stop_bits, default_stop_bits}; Q_ENUM (StopBits) - enum Handshake {handshake_none, handshake_XonXoff, handshake_hardware}; + enum Handshake {handshake_default, handshake_none, handshake_XonXoff, handshake_hardware}; Q_ENUM (Handshake) enum PTTMethod {PTT_method_VOX, PTT_method_CAT, PTT_method_DTR, PTT_method_RTS}; Q_ENUM (PTTMethod)