From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- Transceiver/HamlibTransceiver.cpp | 245 +++++++++++++++++--------------------- 1 file changed, 112 insertions(+), 133 deletions(-) (limited to 'Transceiver/HamlibTransceiver.cpp') diff --git a/Transceiver/HamlibTransceiver.cpp b/Transceiver/HamlibTransceiver.cpp index 99b31f5c..2dde9459 100644 --- a/Transceiver/HamlibTransceiver.cpp +++ b/Transceiver/HamlibTransceiver.cpp @@ -1,4 +1,5 @@ #include "HamlibTransceiver.hpp" +#include "HamlibMode.hpp" #include #include @@ -13,6 +14,13 @@ #include #include #include +#ifndef HAMLIB_PTTPORT +#include +#endif +#ifndef HAMLIB_STATE +#include +#endif +#include "HamlibVfoRoleState.hpp" #include "pimpl_impl.hpp" #include "moc_HamlibTransceiver.cpp" @@ -22,6 +30,32 @@ namespace { + int vfo_list (RIG * rig) + { + return HAMLIB_STATE (rig)->vfo_list; + } + + bool has_vfo (RIG * rig, vfo_t vfo) + { + return vfo_list (rig) & vfo; + } + + vfo_t rx_vfo (RIG * rig) + { + return has_vfo (rig, RIG_VFO_A) ? RIG_VFO_A : RIG_VFO_MAIN; + } + + vfo_t tx_vfo (RIG * rig) + { + return has_vfo (rig, RIG_VFO_B) ? RIG_VFO_B : RIG_VFO_SUB; + } + + bool ptt_port_configured (RIG * rig) + { + auto ptt_port = HAMLIB_PTTPORT (rig); + return ptt_port && RIG_PTT_NONE != ptt_port->type.ptt; + } + // Unfortunately bandwidth is conflated with mode, this is probably // because Icom do the same. So we have to care about bandwidth if // we want to set mode otherwise we will end up setting unwanted @@ -116,13 +150,13 @@ namespace hamlib_tx_vfo_fixup (RIG * rig, vfo_t tx_vfo) : rig_ {rig} { - original_vfo_ = rig_->state.tx_vfo; - rig_->state.tx_vfo = tx_vfo; + original_vfo_ = HAMLIB_STATE (rig_)->tx_vfo; + HAMLIB_STATE (rig_)->tx_vfo = tx_vfo; } ~hamlib_tx_vfo_fixup () { - rig_->state.tx_vfo = original_vfo_; + HAMLIB_STATE (rig_)->tx_vfo = original_vfo_; } private: @@ -142,7 +176,6 @@ public: , back_ptt_port_ {false} , one_VFO_ {false} , is_dummy_ {true} - , reversed_ {false} , freq_query_works_ {true} , mode_query_works_ {true} , split_query_works_ {true} @@ -165,7 +198,6 @@ public: , back_ptt_port_ {TransceiverFactory::TX_audio_source_rear == params.audio_source} , one_VFO_ {false} , is_dummy_ {RIG_MODEL_DUMMY == model_} - , reversed_ {false} , freq_query_works_ {rig_ && rig_get_function_ptr (model_, RIG_FUNCTION_GET_FREQ)} , mode_query_works_ {rig_ && rig_get_function_ptr (model_, RIG_FUNCTION_GET_MODE)} , split_query_works_ {rig_ && rig_get_function_ptr (model_, RIG_FUNCTION_GET_SPLIT_VFO)} @@ -189,7 +221,7 @@ public: QByteArray get_conf (char const * item); Transceiver::MODE map_mode (rmode_t) const; rmode_t map_mode (Transceiver::MODE mode) const; - std::tuple get_vfos (bool for_split) const; + std::tuple get_vfos (bool for_split, bool split_ptt_active) const; HamlibTransceiver::logger_type mutable * logger_; unsigned model_; @@ -206,7 +238,7 @@ public: static freq_t dummy_frequency_; static rmode_t dummy_mode_; - bool mutable reversed_; + HamlibVfoRoleState mutable vfo_roles_; bool freq_query_works_; bool mode_query_works_; @@ -283,7 +315,7 @@ void HamlibTransceiver::impl::error_check (int ret_code, QString const& doing) c } } -std::tuple HamlibTransceiver::impl::get_vfos (bool for_split) const +std::tuple HamlibTransceiver::impl::get_vfos (bool for_split, bool split_ptt_active) const { if (get_vfo_works_ && rig_get_function_ptr (model_, RIG_FUNCTION_GET_VFO)) { @@ -291,7 +323,7 @@ std::tuple HamlibTransceiver::impl::get_vfos (bool for_split) cons error_check (rig_get_vfo (rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib CAT_TRACE ("rig_get_vfo VFO=" << rig_strvfo (v)); - reversed_ = RIG_VFO_B == v; + vfo_roles_.observe_active_vfo (v, split_ptt_active); } else if (!for_split && set_vfo_works_ && rig_get_function_ptr (model_, RIG_FUNCTION_SET_VFO) && rig_get_function_ptr (model_, RIG_FUNCTION_SET_SPLIT_VFO)) { @@ -300,22 +332,22 @@ std::tuple HamlibTransceiver::impl::get_vfos (bool for_split) cons // support this way around 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 (), rx_vfo (rig_.data ())), tr ("setting current VFO")); } // else only toggle available but VFOs should be substitutable - auto rx_vfo = rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN; + auto rx_vfo = ::rx_vfo (rig_.data ()); auto tx_vfo = (WSJT_RIG_NONE_CAN_SPLIT || !is_dummy_) && for_split - ? (rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB) + ? ::tx_vfo (rig_.data ()) : rx_vfo; - if (reversed_) + if (vfo_roles_.reversed ()) { CAT_TRACE ("reversing VFOs"); - std::swap (rx_vfo, tx_vfo); } - CAT_TRACE ("RX VFO=" << rig_strvfo (rx_vfo) << " TX VFO=" << rig_strvfo (tx_vfo)); - return std::make_tuple (rx_vfo, tx_vfo); + auto vfos = vfo_roles_.resolve (rx_vfo, tx_vfo); + CAT_TRACE ("RX VFO=" << rig_strvfo (std::get<0> (vfos)) << " TX VFO=" << rig_strvfo (std::get<1> (vfos))); + return vfos; } void HamlibTransceiver::impl::set_conf (char const * item, char const * value) @@ -333,82 +365,15 @@ QByteArray HamlibTransceiver::impl::get_conf (char const * item) QByteArray value {128, '\0'}; if (RIG_CONF_END != token) // only get if valid for rig model { - error_check (rig_get_conf2 (rig_.data (), token, value.data (),value.length()), tr ("getting a configuration item")); //changed to conf2, added parameter for buffer length +#if HAVE_HAMLIB_GET_CONF2 + error_check (rig_get_conf2 (rig_.data (), token, value.data (), value.length ()), tr ("getting a configuration item")); +#else + error_check (rig_get_conf (rig_.data (), token, value.data ()), tr ("getting a configuration item")); +#endif } return value; } -auto HamlibTransceiver::impl::map_mode (rmode_t m) const -> MODE -{ - switch (m) - { - case RIG_MODE_AM: - case RIG_MODE_SAM: - case RIG_MODE_AMS: - case RIG_MODE_DSB: - return AM; - - case RIG_MODE_CW: - return CW; - - case RIG_MODE_CWR: - return CW_R; - - case RIG_MODE_USB: - case RIG_MODE_ECSSUSB: - case RIG_MODE_SAH: - case RIG_MODE_FAX: - return USB; - - case RIG_MODE_LSB: - case RIG_MODE_ECSSLSB: - case RIG_MODE_SAL: - return LSB; - - case RIG_MODE_RTTY: - return FSK; - - case RIG_MODE_RTTYR: - return FSK_R; - - case RIG_MODE_PKTLSB: - return DIG_L; - - case RIG_MODE_PKTUSB: - return DIG_U; - - case RIG_MODE_FM: - case RIG_MODE_WFM: - return FM; - - case RIG_MODE_PKTFM: - return DIG_FM; - - default: - return UNK; - } -} - -rmode_t HamlibTransceiver::impl::map_mode (MODE mode) const -{ - switch (mode) - { - case AM: return RIG_MODE_AM; - case CW: return RIG_MODE_CW; - case CW_R: return RIG_MODE_CWR; - case USB: return RIG_MODE_USB; - case LSB: return RIG_MODE_LSB; - case FSK: return RIG_MODE_RTTY; - case FSK_R: return RIG_MODE_RTTYR; - case DIG_L: return RIG_MODE_PKTLSB; - case DIG_U: return RIG_MODE_PKTUSB; - case FM: return RIG_MODE_FM; - case DIG_FM: return RIG_MODE_PKTFM; - default: break; - } - return RIG_MODE_USB; // quieten compiler grumble -} - HamlibTransceiver::HamlibTransceiver (logger_type * logger, TransceiverFactory::PTTMethod ptt_type, QString const& ptt_port, QObject * parent) @@ -467,9 +432,6 @@ HamlibTransceiver::HamlibTransceiver (logger_type * logger, { throw error {tr ("Hamlib initialisation error")}; } - - // m_->rig_->state.obj = this; - if (!m_->is_dummy_) { // printf("Hamlib open params: power_on=%d power_off=%d ptt_share=%d\n",(params.poll_interval & rig__power) == rig__power,(params.poll_interval & rig__power_off) == rig__power_off,(params.poll_interval & ptt__share) == ptt__share); @@ -645,7 +607,7 @@ int HamlibTransceiver::do_start () // reset dynamic state m_->one_VFO_ = false; - m_->reversed_ = false; + m_->vfo_roles_.reset (); m_->freq_query_works_ = rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_FREQ); m_->mode_query_works_ = rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_MODE); m_->split_query_works_ = rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_SPLIT_VFO); @@ -665,7 +627,7 @@ int HamlibTransceiver::do_start () m_->get_vfo_works_ = false; // determine if the rig uses single VFO addressing i.e. A/B and // no get_vfo function - if (m_->rig_->state.vfo_list & RIG_VFO_B) + if (has_vfo (m_->rig_.data (), RIG_VFO_B)) { m_->one_VFO_ = true; } @@ -706,7 +668,7 @@ int HamlibTransceiver::do_start () else { CAT_TRACE ("rig_set_vfo to other VFO"); - rc = rig_set_vfo (m_->rig_.data (), m_->rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB); + rc = rig_set_vfo (m_->rig_.data (), tx_vfo (m_->rig_.data ())); if (-RIG_ENAVAIL == rc || -RIG_ENIMPL == rc) { // if we are talking to netrigctl then toggle VFO op @@ -749,7 +711,7 @@ int HamlibTransceiver::do_start () else { CAT_TRACE ("rig_set_vfo A/MAIN"); - m_->error_check (rig_set_vfo (m_->rig_.data (), m_->rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN), tr ("setting current VFO")); + m_->error_check (rig_set_vfo (m_->rig_.data (), rx_vfo (m_->rig_.data ())), tr ("setting current VFO")); } if (f1 != f2 || m != mb || w != wb) // we must have started with MAIN/A @@ -783,7 +745,7 @@ int HamlibTransceiver::do_start () CAT_TRACE ("rig_get_vfo current VFO=" << rig_strvfo (v)); } - m_->reversed_ = RIG_VFO_B == v; + m_->vfo_roles_.observe_active_vfo (v, false); if (m_->mode_query_works_ && !(rig_get_caps_int (m_->model_, RIG_CAPS_TARGETABLE_VFO) & RIG_TARGETABLE_MODE)) { @@ -801,7 +763,7 @@ int HamlibTransceiver::do_start () } } } - update_mode (m_->map_mode (m)); + update_mode (HamlibMode::from_hamlib (m)); } m_->tickle_hamlib_ = true; @@ -815,7 +777,7 @@ int HamlibTransceiver::do_start () if (RIG_MODE_NONE != impl::dummy_mode_) { rig_set_mode (m_->rig_.data (), RIG_VFO_CURR, impl::dummy_mode_, RIG_PASSBAND_NOCHANGE); - update_mode (m_->map_mode (impl::dummy_mode_)); + update_mode (HamlibMode::from_hamlib (impl::dummy_mode_)); } } @@ -873,7 +835,7 @@ int HamlibTransceiver::do_start () do_poll (); - CAT_TRACE ("finished start " << state () << " reversed=" << m_->reversed_ << " resolution=" << resolution); + CAT_TRACE ("finished start " << state () << " reversed=" << m_->vfo_roles_.reversed () << " resolution=" << resolution); return resolution; } @@ -894,12 +856,12 @@ void HamlibTransceiver::do_stop () rig_close (m_->rig_.data ()); } - CAT_TRACE ("state: " << state () << " reversed=" << m_->reversed_); + CAT_TRACE ("state: " << state () << " reversed=" << m_->vfo_roles_.reversed ()); } void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) { - CAT_TRACE ("f: " << f << " mode: " << m << " reversed: " << m_->reversed_); + CAT_TRACE ("f: " << f << " mode: " << m << " reversed: " << m_->vfo_roles_.reversed ()); // only change when receiving or simplex or direct VFO addressing // unavailable or forced @@ -908,7 +870,7 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) // for the 1st time as a band change may cause a recalled mode to be // set vfo_t target_vfo = RIG_VFO_CURR; - if (!(m_->rig_->state.vfo_list & RIG_VFO_B)) + if (!has_vfo (m_->rig_.data (), RIG_VFO_B)) { target_vfo = RIG_VFO_MAIN; // no VFO A/B so force to Rx on MAIN } @@ -919,11 +881,11 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) { rmode_t current_mode; pbwidth_t current_width; - auto new_mode = m_->map_mode (m); + auto new_mode = HamlibMode::to_hamlib (m); m_->error_check (rig_get_mode (m_->rig_.data (), target_vfo, ¤t_mode, ¤t_width), tr ("getting current VFO mode")); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); - if (new_mode != current_mode) + if (HamlibMode::change_required (m, current_mode)) { CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode)); m_->error_check (rig_set_mode (m_->rig_.data (), target_vfo, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); @@ -938,7 +900,16 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) m_->error_check (rig_set_mode (m_->rig_.data (), target_vfo, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); } // set mode on VFOB too if we are in split - if (state ().split()) rig_set_mode (m_->rig_.data (), RIG_VFO_B, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting VFOB mode"); + if (state ().split ()) + { + rmode_t tx_mode; + pbwidth_t tx_width; + auto rc = rig_get_mode (m_->rig_.data (), RIG_VFO_B, &tx_mode, &tx_width); + if (RIG_OK != rc || HamlibMode::change_required (m, tx_mode)) + { + rig_set_mode (m_->rig_.data (), RIG_VFO_B, new_mode, RIG_PASSBAND_NOCHANGE); + } + } update_mode (m); } } @@ -946,12 +917,12 @@ void HamlibTransceiver::do_frequency (Frequency f, MODE m, bool no_ignore) void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore) { - CAT_TRACE ("txf: " << tx << " reversed: " << m_->reversed_); + CAT_TRACE ("txf: " << tx << " reversed: " << m_->vfo_roles_.reversed ()); if (WSJT_RIG_NONE_CAN_SPLIT || !m_->is_dummy_) // split is meaningless if you can't see it { auto split = tx ? RIG_SPLIT_ON : RIG_SPLIT_OFF; - auto vfos = m_->get_vfos (tx); + auto vfos = m_->get_vfos (tx, state ().ptt () && state ().split ()); // auto rx_vfo = std::get<0> (vfos); // or use RIG_VFO_CURR auto tx_vfo = std::get<1> (vfos); @@ -999,11 +970,11 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore { rmode_t current_mode; pbwidth_t current_width; - auto new_mode = m_->map_mode (mode); + auto new_mode = HamlibMode::to_hamlib (mode); m_->error_check (rig_get_mode (m_->rig_.data (), RIG_VFO_CURR, ¤t_mode, ¤t_width), tr ("getting current VFO mode")); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); - if (new_mode != current_mode) + if (HamlibMode::change_required (mode, current_mode)) { CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode)); m_->error_check (rig_set_mode (m_->rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); @@ -1016,7 +987,22 @@ void HamlibTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool no_ignore hamlib_tx_vfo_fixup fixup (m_->rig_.data (), tx_vfo); if (UNK != mode) { - auto new_mode = m_->map_mode (mode); + auto new_mode = HamlibMode::to_hamlib (mode); + rmode_t current_mode; + pbwidth_t current_width; + int rc; + if (state ().split ()) + { + rc = rig_get_split_mode (m_->rig_.data (), RIG_VFO_CURR, ¤t_mode, ¤t_width); + } + else + { + rc = rig_get_mode (m_->rig_.data (), tx_vfo, ¤t_mode, ¤t_width); + } + if (RIG_OK == rc && HamlibMode::satisfies_request (new_mode, current_mode)) + { + new_mode = current_mode; + } CAT_TRACE ("rig_set_split_freq_mode freq=" << tx << " mode = " << rig_strrmode (new_mode)); m_->error_check (rig_set_split_freq_mode (m_->rig_.data (), RIG_VFO_CURR, tx, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting split TX frequency and mode")); @@ -1061,16 +1047,16 @@ void HamlibTransceiver::do_mode (MODE mode) { CAT_TRACE (mode); - auto vfos = m_->get_vfos (state ().split ()); + auto vfos = m_->get_vfos (state ().split (), state ().ptt () && state ().split ()); // auto rx_vfo = std::get<0> (vfos); auto tx_vfo = std::get<1> (vfos); rmode_t current_mode; pbwidth_t current_width; - auto new_mode = m_->map_mode (mode); + auto new_mode = HamlibMode::to_hamlib (mode); vfo_t target_vfo = RIG_VFO_CURR; - if (!(m_->rig_->state.vfo_list & RIG_VFO_B)) + if (!has_vfo (m_->rig_.data (), RIG_VFO_B)) { target_vfo = RIG_VFO_MAIN; // no VFO A/B so force to Rx on MAIN } @@ -1081,7 +1067,7 @@ void HamlibTransceiver::do_mode (MODE mode) m_->error_check (rig_get_mode (m_->rig_.data (), target_vfo, ¤t_mode, ¤t_width), tr ("getting current VFO mode")); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); - if (new_mode != current_mode) + if (HamlibMode::change_required (mode, current_mode)) { CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode)); m_->error_check (rig_set_mode (m_->rig_.data (), target_vfo, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); @@ -1094,7 +1080,7 @@ void HamlibTransceiver::do_mode (MODE mode) m_->error_check (rig_get_mode (m_->rig_.data (), RIG_VFO_CURR, ¤t_mode, ¤t_width), tr ("getting current VFO mode")); CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); - if (new_mode != current_mode) + if (HamlibMode::change_required (mode, current_mode)) { CAT_TRACE ("rig_set_mode mode=" << rig_strrmode (new_mode)); m_->error_check (rig_set_mode (m_->rig_.data (), RIG_VFO_CURR, new_mode, RIG_PASSBAND_NOCHANGE), tr ("setting current VFO mode")); @@ -1105,7 +1091,7 @@ void HamlibTransceiver::do_mode (MODE mode) m_->error_check (rig_get_split_mode (m_->rig_.data (), RIG_VFO_CURR, ¤t_mode, ¤t_width), tr ("getting split TX VFO mode")); CAT_TRACE ("rig_get_split_mode mode=" << rig_strrmode (current_mode) << " bw=" << current_width); - if (new_mode != current_mode) + if (HamlibMode::change_required (mode, current_mode)) { CAT_TRACE ("rig_set_split_mode mode=" << rig_strrmode (new_mode)); hamlib_tx_vfo_fixup fixup (m_->rig_.data (), tx_vfo); @@ -1127,7 +1113,7 @@ void HamlibTransceiver::do_poll () vfo_t v; m_->error_check (rig_get_vfo (m_->rig_.data (), &v), tr ("getting current VFO")); // has side effect of establishing current VFO inside hamlib CAT_TRACE ("VFO=" << rig_strvfo (v)); - m_->reversed_ = RIG_VFO_B == v; + m_->vfo_roles_.observe_active_vfo (v, state ().ptt () && state ().split ()); } if ((WSJT_RIG_NONE_CAN_SPLIT || !m_->is_dummy_) @@ -1139,10 +1125,6 @@ void HamlibTransceiver::do_poll () { CAT_TRACE ("rig_get_split_vfo split=" << s << " VFO=" << rig_strvfo (v)); update_split (true); - // if (RIG_VFO_A == v) - // { - // m_->reversed_ = true; // not sure if this helps us here - // } } else if (-RIG_OK == rc) // not split { @@ -1181,11 +1163,8 @@ void HamlibTransceiver::do_poll () // we can only probe current VFO unless rig supports reading // the other one directly because we can't glitch the Rx - m_->error_check (rig_get_freq (m_->rig_.data () - , m_->reversed_ - ? (m_->rig_->state.vfo_list & RIG_VFO_A ? RIG_VFO_A : RIG_VFO_MAIN) - : (m_->rig_->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB) - , &f), tr ("getting other VFO frequency")); + auto vfos = m_->vfo_roles_.resolve (rx_vfo (m_->rig_.data ()), tx_vfo (m_->rig_.data ())); + m_->error_check (rig_get_freq (m_->rig_.data (), std::get<1> (vfos), &f), tr ("getting other VFO frequency")); f = std::round (f); CAT_TRACE ("rig_get_freq other VFO=" << f); update_other_frequency (f); @@ -1206,7 +1185,7 @@ void HamlibTransceiver::do_poll () if (RIG_OK == rc) { CAT_TRACE ("rig_get_mode mode=" << rig_strrmode (m) << " bw=" << w); - update_mode (m_->map_mode (m)); + update_mode (HamlibMode::from_hamlib (m)); } else { @@ -1214,7 +1193,7 @@ void HamlibTransceiver::do_poll () } } - if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt && rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_PTT)) + if (ptt_port_configured (m_->rig_.data ()) && rig_get_function_ptr (m_->model_, RIG_FUNCTION_GET_PTT)) { ptt_t p; auto rc = rig_get_ptt (m_->rig_.data (), RIG_VFO_CURR, &p); @@ -1281,10 +1260,10 @@ void HamlibTransceiver::do_poll () void HamlibTransceiver::do_ptt (bool on) { - CAT_TRACE ("PTT: " << on << " " << state () << " reversed=" << m_->reversed_); + CAT_TRACE ("PTT: " << on << " " << state () << " reversed=" << m_->vfo_roles_.reversed ()); if (on) { - if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt) + if (ptt_port_configured (m_->rig_.data ())) { ptt_on_ = true; CAT_TRACE ("rig_set_ptt PTT=true"); @@ -1296,7 +1275,7 @@ void HamlibTransceiver::do_ptt (bool on) } else { - if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt) + if (ptt_port_configured (m_->rig_.data ())) { ptt_on_ = false; CAT_TRACE ("rig_set_ptt PTT=false"); @@ -1313,7 +1292,7 @@ void HamlibTransceiver::do_tune (bool on) CAT_TRACE ("Tune: " << on << " " << state ()); if (on) { - if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt) + if (ptt_port_configured (m_->rig_.data ())) { update_PTT (true); // we'll change the PTT button while we do this CAT_TRACE ("rig_vfo_opt RIG_VFO_OP_TUNE=" << on); @@ -1325,7 +1304,7 @@ void HamlibTransceiver::do_tune (bool on) #if 0 else // do we need to be able to turn PTT off on anybody? { - if (RIG_PTT_NONE != m_->rig_->state.pttport.type.ptt) + if (ptt_port_configured (m_->rig_.data ())) { ptt_on_ = false; CAT_TRACE ("rig_set_ptt PTT=false"); -- cgit v1.2.3