diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index bef7936ce..b68447b45 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -471,7 +471,20 @@ typedef unsigned int vfo_t; #define RIG_TARGETABLE_FUNC (1<<4) #define RIG_TARGETABLE_ALL 0x7fffffff //! @endcond - +// +// +// Newer Icoms like the 9700 and 910 have VFOA/B on both Main & Sub +// Compared to older rigs which have one or the other +// So we need to distinguish between them +//! @cond Doxygen_Suppress +#define VFO_HAS_A_B ((rig->state.vfo_list & (RIG_VFO_A|RIG_VFO_B)) == (RIG_VFO_A|RIG_VFO_B)) +#define VFO_HAS_MAIN_SUB ((rig->state.vfo_list & (RIG_VFO_MAIN|RIG_VFO_SUB)) == (RIG_VFO_MAIN|RIG_VFO_SUB)) +#define VFO_HAS_MAIN_SUB_ONLY ((!VFO_HAS_A_B) & VFO_HAS_MAIN_SUB) +#define VFO_HAS_MAIN_SUB_A_B_ONLY (VFO_HAS_A_B & VFO_HAS_MAIN_SUB) +#define VFO_HAS_A_B_ONLY (VFO_HAS_A_B & (!VFO_HAS_MAIN_SUB)) +#define VFO_DUAL (RIG_VFO_MAIN_A|RIG_VFO_MAIN_B|RIG_VFO_SUB_A|RIG_VFO_SUB_B) +#define VFO_HAS_DUAL ((rig->state.vfo_list & VFO_DUAL == VFO_DUAL) +//! @endcond /** * \brief Macro for bandpass to be set to normal @@ -2630,7 +2643,7 @@ rig_need_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level)); #ifndef __cplusplus #ifdef __GNUC__ // doing the debug macro with a dummy sprintf allows gcc to check the format string -#define rig_debug(debug_level,fmt,...) { char xxxbuf[16384]="";snprintf(xxxbuf,sizeof(xxxbuf),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); } +#define rig_debug(debug_level,fmt,...) { char xxxbuf[756]="";snprintf(xxxbuf,sizeof(xxxbuf),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); } #endif #endif extern HAMLIB_EXPORT(void) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 70583df08..8692bee5c 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -44,17 +44,6 @@ #include "icom_defs.h" #include "frame.h" -// Newer Icoms like the 9700 and 910 have VFOA/B on both Main & Sub -// Compared to older rigs which have one or the other -// So we need to distinguish between them -#define VFO_HAS_A_B ((rig->state.vfo_list & (RIG_VFO_A|RIG_VFO_B)) == (RIG_VFO_A|RIG_VFO_B)) -#define VFO_HAS_MAIN_SUB ((rig->state.vfo_list & (RIG_VFO_MAIN|RIG_VFO_SUB)) == (RIG_VFO_MAIN|RIG_VFO_SUB)) -#define VFO_HAS_MAIN_SUB_ONLY ((!VFO_HAS_A_B) & VFO_HAS_MAIN_SUB) -#define VFO_HAS_MAIN_SUB_A_B_ONLY (VFO_HAS_A_B & VFO_HAS_MAIN_SUB) -#define VFO_HAS_A_B_ONLY (VFO_HAS_A_B & (!VFO_HAS_MAIN_SUB)) -#define VFO_DUAL (RIG_VFO_MAIN_A|RIG_VFO_MAIN_B|RIG_VFO_SUB_A|RIG_VFO_SUB_B) -#define VFO_HAS_DUAL ((rig->state.vfo_list & VFO_DUAL == VFO_DUAL) - static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo); const cal_table_float_t icom_default_swr_cal = @@ -1999,7 +1988,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) __func__); return -RIG_EINVAL; } - +rig_debug(RIG_DEBUG_TRACE,"%s: debug#1\n", __func__); if (vfo != priv->curr_vfo) { rig_debug(RIG_DEBUG_TRACE, "%s: VFO changing from %s to %s\n", __func__, @@ -2007,6 +1996,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) priv->curr_freq = 0; // reset curr_freq so set_freq works 1st time } +rig_debug(RIG_DEBUG_TRACE,"%s: debug#2\n", __func__); switch (vfo) { case RIG_VFO_A: @@ -2130,8 +2120,10 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) return -RIG_EINVAL; } +rig_debug(RIG_DEBUG_TRACE,"%s: debug#3\n", __func__); retval = icom_transaction(rig, C_SET_VFO, icvfo, NULL, 0, ackbuf, &ack_len); +rig_debug(RIG_DEBUG_TRACE,"%s: debug#4\n", __func__); if (retval != RIG_OK) { @@ -2147,6 +2139,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) priv->curr_vfo = vfo; rig->state.current_vfo = vfo; +rig_debug(RIG_DEBUG_TRACE,"%s: debug#5\n", __func__); return RIG_OK; } diff --git a/src/rig.c b/src/rig.c index 60e938260..b18ba5040 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1801,6 +1801,17 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) return -RIG_EINVAL; } + // make sure we are asking for a VFO that the rig actually has + if ((vfo == RIG_VFO_A || vfo == RIG_VFO_B) && !VFO_HAS_A_B) { + rig_debug(RIG_DEBUG_ERR, "%s: rig does not have %s\n", __func__, rig_strvfo(vfo)); + return -RIG_EINVAL; + } + if ((vfo == RIG_VFO_MAIN || vfo == RIG_VFO_SUB) && !VFO_HAS_MAIN_SUB) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig does not have %s\n", __func__, rig_strvfo(vfo)); + return -RIG_EINVAL; + } + caps = rig->caps; if (caps->set_vfo == NULL)