From 49aa7d00a7648288c5c9fa5cf615b8a6eda5500a Mon Sep 17 00:00:00 2001 From: Michael Black Date: Wed, 12 Feb 2020 07:20:34 -0600 Subject: [PATCH] Fix get_ant RIG_ANT_CURR logic --- doc/man1/rigctl.1 | 6 +++++- include/hamlib/rig.h | 2 +- rigs/icom/icom.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index 11653b06d..a1964b1c0 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -668,7 +668,11 @@ Option depends on rig..for Icom it probably sets the RX only flag. See your manu Get .RI \(aq Antenna \(aq .IP -Number is 1-based antenna# (\(oq1\(cq, \(oq2\(cq, \(oq3\(cq, ...). +A value of 0 for Antenna will return the current TX antenna +.IP +> 0 is 1-based antenna# (\(oq1\(cq, \(oq2\(cq, \(oq3\(cq, ...). + + .IP Option returned depends on rig..for Icom is likely the RX only flag. . diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 2497f7b75..aebc32941 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1038,7 +1038,7 @@ typedef struct freq_range_list { int low_power; /*!< Lower RF power in mW, -1 for no power (ie. rx list) */ int high_power; /*!< Higher RF power in mW, -1 for no power (ie. rx list) */ vfo_t vfo; /*!< VFO list equipped with this range */ - ant_t ant; /*!< Antenna list equipped with this range, 0 means all */ + ant_t ant; /*!< Antenna list equipped with this range, 0 means all, RIG_ANT_CURR means dedicated to certain bands and automatically switches */ } freq_range_t; #define RIG_FRNG_END {Hz(0),Hz(0),RIG_MODE_NONE,0,0,RIG_VFO_NONE} diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7c8a8e072..fc01217d0 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -5453,8 +5453,16 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, ant_t *ant_curr, value_t *optio rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant); - ant = rig_setting2idx(ant); - if (ant >= priv_caps->ant_count) return -RIG_EINVAL; + if (ant != RIG_ANT_CURR) + { + ant = rig_setting2idx(ant); + if (ant >= priv_caps->ant_count) + { + rig_debug(RIG_DEBUG_ERR, "%s: ant index=%d > ant_count=%d\n", __func__, ant, priv_caps->ant_count); + return -RIG_EINVAL; + } + } + // Should be able to use just C_CTL_ANT for 1 or 2 antennas hopefully if (ant == RIG_ANT_CURR || priv_caps->ant_count <= 2) { retval = icom_transaction(rig, C_CTL_ANT, -1, NULL, 0, ackbuf, &ack_len); }