diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index b61f24f8e..239a8a3d6 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -446,7 +446,7 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if (vfo == RIG_VFO_CURR) { vfo = priv->curr_vfo; } - if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); } + if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX) { vfo = vfo_fixup(rig, vfo, CACHE(rig)->split); } // if needed for testing enable this to emulate a rig with 100hz resolution #if 0 @@ -534,6 +534,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; channel_t *curr = priv->curr; + struct rig_cache *cachep = CACHE(rig); char buf[16]; ENTERFUNC; @@ -542,7 +543,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s %s\n", __func__, rig_strvfo(vfo), rig_strrmode(mode), buf); - vfo = vfo_fixup(rig, vfo, rig->state.cache.split); + vfo = vfo_fixup(rig, vfo, cachep->split); if (vfo == RIG_VFO_CURR) { vfo = priv->curr_vfo; } @@ -587,7 +588,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) RETURNFUNC(-RIG_EINVAL); } - vfo = vfo_fixup(rig, vfo, rig->state.cache.split); + vfo = vfo_fixup(rig, vfo, cachep->split); if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); } @@ -1085,7 +1086,7 @@ static int dummy_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) if (tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) { tx_vfo = priv->curr_vfo; } - if (tx_vfo == RIG_VFO_CURR || tx_vfo == RIG_VFO_TX) { tx_vfo = vfo_fixup(rig, vfo, rig->state.cache.split); } + if (tx_vfo == RIG_VFO_CURR || tx_vfo == RIG_VFO_TX) { tx_vfo = vfo_fixup(rig, vfo, CACHE(rig)->split); } priv->split = split; priv->tx_vfo = tx_vfo; diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index 9536beb35..98d010e60 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -2218,12 +2218,13 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo) int ack_len = sizeof(ackbuf); int retval; int vfo_is_main_or_sub = (vfo == RIG_VFO_MAIN) || (vfo == RIG_VFO_SUB); + struct rig_cache *cachep = CACHE(rig); ENTERFUNC; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); - if (rig->state.cache.satmode && !vfo_is_main_or_sub) + if (cachep->satmode && !vfo_is_main_or_sub) { // Translate VFO A/B to Main/Sub in satellite mode if (vfo == RIG_VFO_A) @@ -2247,7 +2248,7 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo) } else if (vfo == RIG_VFO_B) { - if (rig->state.cache.satmode) + if (cachep->satmode) { rig_debug(RIG_DEBUG_WARN, "%s: cannot switch to VFOB when in satmode\n", __func__); @@ -2267,7 +2268,7 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo) return retval; } - if (rig->state.cache.satmode && vfo == RIG_VFO_MAIN_B) + if (cachep->satmode && vfo == RIG_VFO_MAIN_B) { rig_debug(RIG_DEBUG_WARN, "%s: cannot switch to VFOB when in satmode\n", __func__); // we return RIG_OK anyways as this should just be a bad request @@ -2290,7 +2291,7 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo) return retval; } - if (rig->state.cache.satmode && vfo == RIG_VFO_SUB_B) + if (cachep->satmode && vfo == RIG_VFO_SUB_B) { rig_debug(RIG_DEBUG_WARN, "%s: cannot switch to VFOB when in satmode\n", __func__); // we return RIG_OK anyways as this should just be a bad request diff --git a/rigs/icom/ic821h.c b/rigs/icom/ic821h.c index e8f4d33ea..3b6000f7a 100644 --- a/rigs/icom/ic821h.c +++ b/rigs/icom/ic821h.c @@ -64,10 +64,10 @@ int ic821h_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) if (tx_vfo == RIG_VFO_MAIN) { - rig->state.cache.satmode = + CACHE(rig)->satmode = split; // we emulate satmode of other rigs since we apparently can't query rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo==MAIN so assuming sat mode=%d\n", - __func__, rig->state.cache.satmode); + __func__, CACHE(rig)->satmode); rig->state.tx_vfo = split == RIG_SPLIT_ON ? RIG_VFO_SUB : RIG_VFO_MAIN; // the IC821 seems to be backwards in satmode -- setting Main select Sub and vice versa retval = rig_set_vfo(rig, RIG_VFO_SUB); diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index a5894f681..921259642 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -934,7 +934,8 @@ static vfo_t icom_current_vfo(RIG *rig) freq_t freq_current, freq_other, freq_current_2; vfo_t vfo_current = RIG_VFO_NONE; vfo_t vfo_check = RIG_VFO_A; - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); struct icom_priv_data *priv = rs->priv; #if 0 @@ -944,7 +945,7 @@ static vfo_t icom_current_vfo(RIG *rig) // these newer rigs get special treatment retval = icom_current_vfo_x25(rig, &vfo_current); - if (VFO_HAS_MAIN_SUB_ONLY || (VFO_HAS_MAIN_SUB_A_B_ONLY && rs->cache.satmode)) + if (VFO_HAS_MAIN_SUB_ONLY || (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->satmode)) { vfo_current = (vfo_current == RIG_VFO_A) ? RIG_VFO_MAIN : RIG_VFO_SUB; } @@ -956,7 +957,7 @@ static vfo_t icom_current_vfo(RIG *rig) } #endif - if (rs->cache.ptt) + if (cachep->ptt) { // don't do this if transmitting -- XCHG would mess it up return rs->current_vfo; @@ -1040,7 +1041,7 @@ static vfo_t icom_current_vfo(RIG *rig) rig_set_freq(rig, RIG_VFO_CURR, freq_current); } - if (VFO_HAS_MAIN_SUB_ONLY || (VFO_HAS_MAIN_SUB_A_B_ONLY && rs->cache.satmode)) + if (VFO_HAS_MAIN_SUB_ONLY || (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->satmode)) { vfo_current = (vfo_current == RIG_VFO_A) ? RIG_VFO_MAIN : RIG_VFO_SUB; } @@ -1089,7 +1090,7 @@ int icom_rig_open(RIG *rig) { int retval, retval_echo, value; int satmode = 0; - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); hamlib_port_t *rp = RIGPORT(rig); struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; int retry_flag = 1; @@ -1560,7 +1561,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) #if 0 - if (rig->state.cache.ptt && (ICOM_IS_ID5100 || ICOM_IS_ID4100 || ICOM_IS_ID31 + if (CACHE(rig)->ptt && (ICOM_IS_ID5100 || ICOM_IS_ID4100 || ICOM_IS_ID31 || ICOM_IS_ID51)) { rig_debug(RIG_DEBUG_TRACE, "%s(%d): ID55100 0x00\n", __func__, __LINE__); @@ -1720,7 +1721,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } // Fix VFO if the TX freq command is not available - if (rig->state.cache.split != RIG_SPLIT_OFF) + if (CACHE(rig)->split != RIG_SPLIT_OFF) { vfo = rs->tx_vfo; } @@ -2895,7 +2896,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) { unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf), icvfo, retval; - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; const struct icom_priv_caps *priv_caps = rig->caps->priv; @@ -2917,7 +2919,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) } else if ((vfo == RIG_VFO_SUB) && (VFO_HAS_A_B_ONLY || (VFO_HAS_MAIN_SUB_A_B_ONLY - && rig->state.cache.split == RIG_SPLIT_OFF && !rig->state.cache.satmode))) + && cachep->split == RIG_SPLIT_OFF && !cachep->satmode))) { // if rig doesn't have Main/Sub // or if rig has both Main/Sub and A/B -- e.g. 9700 @@ -2934,22 +2936,22 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) rig_strvfo(vfo)); vfo = RIG_VFO_A; - if (VFO_HAS_A_B_ONLY && rig->state.cache.satmode) { vfo = RIG_VFO_B; } + if (VFO_HAS_A_B_ONLY && cachep->satmode) { vfo = RIG_VFO_B; } else if (VFO_HAS_MAIN_SUB_ONLY) { vfo = RIG_VFO_SUB; } - else if (VFO_HAS_MAIN_SUB_A_B_ONLY && rig->state.cache.satmode) { vfo = RIG_VFO_SUB; } + else if (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->satmode) { vfo = RIG_VFO_SUB; } } else if ((vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) && VFO_HAS_DUAL) { rig_debug(RIG_DEBUG_TRACE, "%s: vfo line#%d vfo=%s, split=%d\n", __func__, - __LINE__, rig_strvfo(vfo), rig->state.cache.split); + __LINE__, rig_strvfo(vfo), cachep->split); // If we're being asked for A/Main but we are a MainA/MainB rig change it vfo = RIG_VFO_MAIN; - if (rig->state.cache.split == RIG_SPLIT_ON && !rig->state.cache.satmode) { vfo = RIG_VFO_A; } + if (cachep->split == RIG_SPLIT_ON && !cachep->satmode) { vfo = RIG_VFO_A; } // Seems the IC821H reverses Main/Sub when in satmode - if (RIG_IS_IC821H && rig->state.cache.satmode) { vfo = RIG_VFO_SUB; } + if (RIG_IS_IC821H && cachep->satmode) { vfo = RIG_VFO_SUB; } } else if ((vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) && VFO_HAS_DUAL) { @@ -2959,14 +2961,14 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) vfo = RIG_VFO_SUB; // If we're in satmode for rigs like IC9700 we want the 2nd VFO - if (rig->state.cache.satmode) + if (cachep->satmode) { vfo = RIG_VFO_SUB_A; } - else if (rig->state.cache.split == RIG_SPLIT_ON) { vfo = RIG_VFO_B; } + else if (cachep->split == RIG_SPLIT_ON) { vfo = RIG_VFO_B; } // Seems the IC821H reverses Main/Sub when in satmode - if (RIG_IS_IC821H && rig->state.cache.satmode) { vfo = RIG_VFO_MAIN; } + if (RIG_IS_IC821H && cachep->satmode) { vfo = RIG_VFO_MAIN; } } else if ((vfo == RIG_VFO_A || vfo == RIG_VFO_B) && !VFO_HAS_A_B && VFO_HAS_MAIN_SUB) @@ -2991,8 +2993,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) { rig_debug(RIG_DEBUG_TRACE, "%s: VFO changing from %s to %s\n", __func__, rig_strvfo(rig->state.current_vfo), rig_strvfo(vfo)); - rig->state.cache.freqCurr = - 0; // reset current frequency so set_freq works 1st time + cachep->freqCurr = 0; // reset current frequency so set_freq works 1st time } rig_debug(RIG_DEBUG_TRACE, "%s: line#%d\n", __func__, __LINE__); @@ -3011,8 +3012,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) icvfo = S_MAIN; // If not split or satmode then we must want VFOA - if (VFO_HAS_MAIN_SUB_A_B_ONLY && rig->state.cache.split == RIG_SPLIT_OFF - && !rig->state.cache.satmode) { icvfo = S_VFOA; } + if (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->split == RIG_SPLIT_OFF + && !cachep->satmode) { icvfo = S_VFOA; } rig_debug(RIG_DEBUG_TRACE, "%s: Main asked for, ended up with vfo=%s\n", __func__, icvfo == S_MAIN ? "Main" : "VFOA"); @@ -3023,11 +3024,11 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) icvfo = S_SUB; // If split is on these rigs can only split on Main/VFOB - if (VFO_HAS_MAIN_SUB_A_B_ONLY && rig->state.cache.split != RIG_SPLIT_OFF) { icvfo = S_VFOB; } + if (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { icvfo = S_VFOB; } // If not split or satmode then we must want VFOB - if (VFO_HAS_MAIN_SUB_A_B_ONLY && rig->state.cache.split == RIG_SPLIT_OFF - && !rig->state.cache.satmode) { icvfo = S_VFOB; } + if (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->split == RIG_SPLIT_OFF + && !cachep->satmode) { icvfo = S_VFOB; } rig_debug(RIG_DEBUG_TRACE, "%s: Sub asked for, ended up with vfo=%s\n", __func__, icvfo == S_SUB ? "Sub" : "VFOB"); @@ -3035,8 +3036,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) break; case RIG_VFO_TX: - icvfo = (rig->state.cache.split != RIG_SPLIT_OFF) ? S_VFOB : S_VFOA; - vfo = (rig->state.cache.split != RIG_SPLIT_OFF) ? RIG_VFO_B : RIG_VFO_A; + icvfo = (cachep->split != RIG_SPLIT_OFF) ? S_VFOB : S_VFOA; + vfo = (cachep->split != RIG_SPLIT_OFF) ? RIG_VFO_B : RIG_VFO_A; rig_debug(RIG_DEBUG_TRACE, "%s: RIG_VFO_TX changing vfo to %s\n", __func__, rig_strvfo(vfo)); break; @@ -5437,29 +5438,28 @@ int icom_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs) */ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) { - struct rig_state *rs; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); ENTERFUNC; - rs = (struct rig_state *) &rig->state; - // Initialize TX VFO if not done yet if (rs->tx_vfo == RIG_VFO_NONE || rs->tx_vfo == RIG_VFO_CURR || rs->tx_vfo == RIG_VFO_TX) { - if (rs->cache.split == RIG_SPLIT_OFF) + if (cachep->split == RIG_SPLIT_OFF) { rs->tx_vfo = rs->current_vfo; } else { - rs->tx_vfo = vfo_fixup(rig, RIG_VFO_OTHER, rs->cache.split); + rs->tx_vfo = vfo_fixup(rig, RIG_VFO_OTHER, cachep->split); } } if (VFO_HAS_A_B_ONLY) { - if (rs->cache.split == RIG_SPLIT_OFF) + if (cachep->split == RIG_SPLIT_OFF) { *rx_vfo = *tx_vfo = rs->current_vfo; } @@ -5470,11 +5470,11 @@ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) } rig_debug(RIG_DEBUG_TRACE, "%s: VFO_HAS_A_B_ONLY, split=%d, rx=%s, tx=%s\n", - __func__, rs->cache.split, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); + __func__, cachep->split, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); } else if (VFO_HAS_MAIN_SUB_ONLY) { - if (rs->cache.split == RIG_SPLIT_OFF) + if (cachep->split == RIG_SPLIT_OFF) { *rx_vfo = *tx_vfo = rs->current_vfo; } @@ -5486,7 +5486,7 @@ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) rig_debug(RIG_DEBUG_TRACE, "%s: VFO_HAS_MAIN_SUB_ONLY, split=%d, rx=%s, tx=%s\n", - __func__, rs->cache.split, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); + __func__, cachep->split, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); } else if (VFO_HAS_MAIN_SUB_A_B_ONLY) { @@ -5505,7 +5505,7 @@ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) *rx_vfo = RIG_VFO_MAIN; *tx_vfo = RIG_VFO_SUB; } - else if (rs->cache.split == RIG_SPLIT_OFF) + else if (cachep->split == RIG_SPLIT_OFF) { *rx_vfo = *tx_vfo = rs->current_vfo; } @@ -5517,7 +5517,7 @@ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) rig_debug(RIG_DEBUG_TRACE, "%s: VFO_HAS_MAIN_SUB_A_B_ONLY, split=%d, rx=%s, tx=%s\n", - __func__, rs->cache.split, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); + __func__, cachep->split, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); } else { @@ -5537,7 +5537,8 @@ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) */ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); hamlib_port_t *rp = RIGPORT(rig); struct icom_priv_data *priv = rs->priv; const struct icom_priv_caps *priv_caps = rig->caps->priv; @@ -5551,11 +5552,11 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) rig_strvfo(rs->current_vfo)); rig_debug(RIG_DEBUG_VERBOSE, "%s: satmode=%d, tx_vfo=%s\n", __func__, - rs->cache.satmode, rig_strvfo(rs->tx_vfo)); + cachep->satmode, rig_strvfo(rs->tx_vfo)); if (vfo == RIG_VFO_TX) { - if (rs->cache.satmode) { vfo = RIG_VFO_SUB; } + if (cachep->satmode) { vfo = RIG_VFO_SUB; } else { vfo = rs->tx_vfo; } } @@ -5637,7 +5638,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) } /* broken if user changes split on rig :( */ - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -5690,7 +5691,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { // Then we return the VFO to the rx_vfo rig_debug(RIG_DEBUG_TRACE, "%s: SATMODE split_on=%d rig so setting vfo to %s\n", - __func__, rs->cache.split, rig_strvfo(rx_vfo)); + __func__, cachep->split, rig_strvfo(rx_vfo)); HAMLIB_TRACE; @@ -5710,7 +5711,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) RETURNFUNC2(retval); } - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { /* Re-enable split */ retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, @@ -5737,7 +5738,8 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) */ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); hamlib_port_t *rp = RIGPORT(rig); struct icom_priv_data *priv = rs->priv; const struct icom_priv_caps *priv_caps = rig->caps->priv; @@ -5845,7 +5847,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) } /* broken if user changes split on rig :( */ - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -5888,7 +5890,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) RETURNFUNC2(retval); } - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { /* Re-enable split */ retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, @@ -5911,7 +5913,8 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); struct icom_priv_data *priv = rs->priv; unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf); @@ -5949,7 +5952,7 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, } /* broken if user changes split on rig :( */ - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -5994,7 +5997,7 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, RETURNFUNC(retval); } - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && cachep->split != RIG_SPLIT_OFF) { /* Re-enable split */ retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, @@ -6056,7 +6059,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, } /* broken if user changes split on rig :( */ - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && CACHE(rig)->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -6099,7 +6102,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, RETURNFUNC(retval); } - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && CACHE(rig)->split != RIG_SPLIT_OFF) { /* Re-enable split */ retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, @@ -6122,7 +6125,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t tx_mode, pbwidth_t tx_width) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); struct icom_priv_data *priv = rs->priv; unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf); @@ -6188,7 +6191,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, } /* broken if user changes split on rig :( */ - if (VFO_HAS_A_B && (split_assumed || rs->cache.split != RIG_SPLIT_OFF)) + if (VFO_HAS_A_B && (split_assumed || CACHE(rig)->split != RIG_SPLIT_OFF)) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -6230,7 +6233,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, rig_strvfo(rs->rx_vfo), rig_strvfo(rs->tx_vfo)); // if not asking for RIG_VFO_CURR we'll use the requested VFO in the function call as tx_vfo - if (rs->cache.split == RIG_SPLIT_OFF && vfo != RIG_VFO_CURR) + if (CACHE(rig)->split == RIG_SPLIT_OFF && vfo != RIG_VFO_CURR) { tx_vfo = vfo; rig_debug(RIG_DEBUG_TRACE, "%s: split not on so using requested vfo=%s\n", @@ -6272,7 +6275,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, RETURNFUNC2(retval); } - if (VFO_HAS_A_B && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B && CACHE(rig)->split != RIG_SPLIT_OFF) { /* Re-enable split */ retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, @@ -6296,7 +6299,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, rmode_t *tx_mode, pbwidth_t *tx_width) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); struct icom_priv_data *priv = rs->priv; unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf); @@ -6349,7 +6352,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, } /* broken if user changes split on rig :( */ - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && CACHE(rig)->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -6397,7 +6400,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, RETURNFUNC(retval); } - if (VFO_HAS_A_B_ONLY && rs->cache.split != RIG_SPLIT_OFF) + if (VFO_HAS_A_B_ONLY && CACHE(rig)->split != RIG_SPLIT_OFF) { /* Re-enable split */ retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, @@ -6418,7 +6421,8 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, */ int icom_set_split_vfo(RIG *rig, vfo_t rx_vfo, split_t split, vfo_t tx_vfo) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); const struct icom_priv_caps *priv_caps = rig->caps->priv; unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf), retval; @@ -6443,7 +6447,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t rx_vfo, split_t split, vfo_t tx_vfo) rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); if ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB) - && !rig->state.cache.satmode) + && !cachep->satmode) { rig_debug(RIG_DEBUG_VERBOSE, "%s: requesting split for Main/Sub VFO and satmode is OFF so turning satmode ON\n", @@ -6453,7 +6457,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t rx_vfo, split_t split, vfo_t tx_vfo) RETURNFUNC2(retval); } else if ((tx_vfo == RIG_VFO_A || tx_vfo == RIG_VFO_B) - && rig->state.cache.satmode) + && cachep->satmode) { rig_debug(RIG_DEBUG_VERBOSE, "%s: requesting split for VFO A/B and satmode is ON so turning satmode OFF\n", @@ -6461,7 +6465,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t rx_vfo, split_t split, vfo_t tx_vfo) rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, 0); } else if ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB) - && rig->state.cache.satmode && split == RIG_SPLIT_ON) + && cachep->satmode && split == RIG_SPLIT_ON) { rig_debug(RIG_DEBUG_VERBOSE, "%s: requesting split for Main/Sub VFO and rig is already in satmode so setting split on " @@ -6550,7 +6554,7 @@ int icom_get_split_vfo(RIG *rig, vfo_t rx_vfo, split_t *split, vfo_t *tx_vfo) { unsigned char splitbuf[MAXFRAMELEN]; int split_len, retval, satmode = 0; - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); ENTERFUNC; retval = icom_transaction(rig, C_CTL_SPLT, -1, NULL, 0, @@ -6605,7 +6609,7 @@ int icom_get_split_vfo(RIG *rig, vfo_t rx_vfo, split_t *split, vfo_t *tx_vfo) } // Update cache early for icom_get_split_vfos() - rs->cache.split = *split; + CACHE(rig)->split = *split; icom_get_split_vfos(rig, &rs->rx_vfo, &rs->tx_vfo); @@ -6636,7 +6640,7 @@ int icom_mem_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, if (rig->state.current_vfo != RIG_VFO_MEM || !rig_has_vfo_op(rig, RIG_OP_XCHG)) { - *split = rig->state.cache.split; // we set this but still return ENAVAIL + *split = CACHE(rig)->split; // we set this but still return ENAVAIL RETURNFUNC(-RIG_ENAVAIL); } @@ -7021,7 +7025,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) { int satmode = status ? 1 : 0; - if (satmode != rig->state.cache.satmode) + if (satmode != CACHE(rig)->satmode) { rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): changed satmode=%d\n", __func__, __LINE__, satmode); @@ -7037,7 +7041,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) __func__, __LINE__, satmode); } - rig->state.cache.satmode = satmode; + CACHE(rig)->satmode = satmode; icom_satmode_fix(rig, satmode); // Turning satmode ON/OFF can change the TX/RX VFOs @@ -7281,13 +7285,13 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } else if (func == RIG_FUNC_SATMODE) { - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); struct icom_priv_data *priv = rs->priv; int satmode = ackbuf[2 + fct_len]; *status = satmode; - if (satmode != rig->state.cache.satmode) + if (satmode != CACHE(rig)->satmode) { rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): changed satmode=%d\n", __func__, __LINE__, satmode); @@ -7303,7 +7307,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) __func__, __LINE__, satmode); } - rig->state.cache.satmode = satmode; + CACHE(rig)->satmode = satmode; icom_satmode_fix(rig, satmode); } else @@ -9381,8 +9385,8 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo) // only need to set vfo if it's changed else if (rs->current_vfo != vfo) { - if (!(VFO_HAS_MAIN_SUB_A_B_ONLY && rs->cache.split == RIG_SPLIT_OFF - && !rs->cache.satmode + if (!(VFO_HAS_MAIN_SUB_A_B_ONLY && CACHE(rig)->split == RIG_SPLIT_OFF + && !CACHE(rig)->satmode && vfo == RIG_VFO_SUB && rs->current_vfo == RIG_VFO_B)) { rig_debug(RIG_DEBUG_TRACE, "%s: setting new vfo=%s\n", __func__, @@ -9698,11 +9702,12 @@ static void icom_set_x25x26_ability(RIG *rig, int status) static int icom_get_vfo_number_x25x26(RIG *rig, vfo_t vfo) { int vfo_number = 0x00; + struct rig_cache *cachep = CACHE(rig); // Rigs with *only* Main/Sub VFOs can directly address VFOs: 0 = Main, 1 = Sub if (RIG_IS_IC7600 || RIG_IS_IC7610 || RIG_IS_IC7800 || RIG_IS_IC785X) { - vfo_t actual_vfo = vfo_fixup(rig, vfo, rig->state.cache.split); + vfo_t actual_vfo = vfo_fixup(rig, vfo, cachep->split); if (actual_vfo == RIG_VFO_CURR) { @@ -9746,8 +9751,7 @@ static int icom_get_vfo_number_x25x26(RIG *rig, vfo_t vfo) } // The split VFO is active when transmitting in split mode - vfo_number = (rig->state.cache.split - && rig->state.cache.ptt) ? !vfo_number : vfo_number; + vfo_number = (cachep->split && cachep->ptt) ? !vfo_number : vfo_number; } } diff --git a/rigs/icom/id5100.c b/rigs/icom/id5100.c index 9ad6fa4ff..aae0b19d2 100644 --- a/rigs/icom/id5100.c +++ b/rigs/icom/id5100.c @@ -284,9 +284,9 @@ int id5100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) else if ((vfo == RIG_VFOvfo == RIG_VFO_SUB && rs->dual_watch_main_sub == MAIN_ON_RIGHT) { - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Sub/A vfo=%s\n", __func__, __LINE__, - rig_strvfo(vfo)); - *freq = rig->state.cache.freqSubA; + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Sub/A vfo=%s\n", __func__, __LINE__, + rig_strvfo(vfo)); + *freq = CACHE(rig)->freqSubA; int cache_ms_freq, cache_ms_mode, cache_ms_width; pbwidth_t width; freq_t tfreq; diff --git a/rigs/icom/xiegu.c b/rigs/icom/xiegu.c index a4ba8da57..9fa3142dd 100644 --- a/rigs/icom/xiegu.c +++ b/rigs/icom/xiegu.c @@ -934,6 +934,7 @@ static int x108g_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf), rc; int split_sc; + struct rig_cache *cachep = CACHE(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -946,7 +947,7 @@ static int x108g_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) case RIG_SPLIT_ON: split_sc = S_SPLT_ON; - if (rig->state.cache.split == RIG_SPLIT_OFF) + if (cachep->split == RIG_SPLIT_OFF) { /* ensure VFO A is Rx and VFO B is Tx as we assume that elsewhere */ if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B)) @@ -973,7 +974,7 @@ static int x108g_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) return -RIG_ERJCTED; } - rig->state.cache.split = split; + cachep->split = split; return RIG_OK; } @@ -988,12 +989,12 @@ static int x108g_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) int rc; vfo_t rx_vfo, tx_vfo; struct icom_priv_data *priv; - struct rig_state *rs; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rs = &rig->state; priv = (struct icom_priv_data *)rs->priv; /* This method works also in memory mode(RIG_VFO_MEM) */ @@ -1014,7 +1015,7 @@ static int x108g_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) queries */ /* broken if user changes split on rig :( */ if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B) - && rig->state.cache.split != RIG_SPLIT_OFF) + && cachep->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -1041,7 +1042,7 @@ static int x108g_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) { return rc; } if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B) - && rig->state.cache.split != RIG_SPLIT_OFF) + && cachep->split != RIG_SPLIT_OFF) { /* Re-enable split */ rc = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len); @@ -1064,12 +1065,12 @@ static int x108g_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, int rc; vfo_t rx_vfo, tx_vfo; struct icom_priv_data *priv; - struct rig_state *rs; + struct rig_state *rs = STATE(rig); + struct rig_cache *cachep = CACHE(rig); unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rs = &rig->state; priv = (struct icom_priv_data *)rs->priv; /* This method works also in memory mode(RIG_VFO_MEM) */ @@ -1091,7 +1092,7 @@ static int x108g_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, queries */ /* broken if user changes split on rig :( */ if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B) - && rig->state.cache.split != RIG_SPLIT_OFF) + && cachep->split != RIG_SPLIT_OFF) { /* VFO A/B style rigs swap VFO on split Tx so we need to disable split for certainty */ @@ -1119,7 +1120,7 @@ static int x108g_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, if (RIG_OK != (rc = icom_set_vfo(rig, rx_vfo))) { return rc; } if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B) - && rig->state.cache.split != RIG_SPLIT_OFF) + && cachep->split != RIG_SPLIT_OFF) { /* Re-enable split */ rc = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len); diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 44b657afe..fd0045d12 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -339,7 +339,7 @@ static int jst145_get_vfo(RIG *rig, vfo_t *vfo) jst145_get_ptt(rig, RIG_VFO_A, &ptt); // set priv->ptt to current transmit status - rig->state.cache.ptt = ptt; + CACHE(rig)->ptt = ptt; ptt_retry: @@ -609,7 +609,7 @@ static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) if (pttstatus[1] == '1') { *ptt = RIG_PTT_ON; } else { *ptt = RIG_PTT_OFF; } - priv->ptt = rig->state.cache.ptt = *ptt; + priv->ptt = CACHE(rig)->ptt = *ptt; return RIG_OK; }