From ce99f4c75de83b0a6cac834ada2b28bd2cbc62f7 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 7 Jun 2022 08:33:18 -0500 Subject: [PATCH] Allow rig_set_split_mode to skip setting if mode already set https://github.com/Hamlib/Hamlib/issues/1056 --- rigs/yaesu/ft991.c | 14 +++++++++++++- src/rig.c | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/rigs/yaesu/ft991.c b/rigs/yaesu/ft991.c index c83675b6d..9e2ca3165 100644 --- a/rigs/yaesu/ft991.c +++ b/rigs/yaesu/ft991.c @@ -141,7 +141,7 @@ const struct rig_caps ft991_caps = RIG_MODEL(RIG_MODEL_FT991), .model_name = "FT-991", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".11", + .version = NEWCAT_VER ".12", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -412,6 +412,12 @@ ft991_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) return (rval); } + if (rig->state.cache.freqMainB == tx_freq) + { + rig_debug(RIG_DEBUG_TRACE, "%s: freq %.0f already set on VFOB\n", __func__, tx_freq); + return RIG_OK; + } + if (is_split == RIG_SPLIT_OFF) { rval = newcat_set_tx_vfo(rig, RIG_VFO_B); @@ -582,6 +588,12 @@ static int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, return -RIG_EINVAL; } + if (rig->state.cache.modeMainB == tx_mode) + { + rig_debug(RIG_DEBUG_TRACE, "%s: mode %s already set on VFOB\n", __func__, rig_strrmode(tx_mode)); + return RIG_OK; + } + err = ft991_get_tx_split(rig, &is_split); if (err != RIG_OK) diff --git a/src/rig.c b/src/rig.c index 48605b8fd..d643af971 100644 --- a/src/rig.c +++ b/src/rig.c @@ -4149,6 +4149,14 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, RETURNFUNC(-RIG_EINVAL); } + // we check both VFOs are in the same tx mode -- the we can ignore + // this could be make more intelligent but this should cover all cases where we can skip this + if (tx_mode == rig->state.cache.modeMainA && tx_mode == rig->state.cache.modeMainB) + { + rig_debug(RIG_DEBUG_TRACE, "%s: mode already %s so no change required\n", __func__, rig_strrmode(tx_mode)); + return RIG_OK; + } + // do not mess with mode while PTT is on if (rig->state.cache.ptt) {