Update some of rigs/* to use pointer to cache

Issue #536
pull/1523/head
George Baltz N3GB 2024-03-08 10:28:03 -05:00
rodzic 5ab1122139
commit 609065775c
7 zmienionych plików z 107 dodań i 100 usunięć

Wyświetl plik

@ -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 = 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 needed for testing enable this to emulate a rig with 100hz resolution
#if 0 #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; struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv;
channel_t *curr = priv->curr; channel_t *curr = priv->curr;
struct rig_cache *cachep = CACHE(rig);
char buf[16]; char buf[16];
ENTERFUNC; 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_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s %s\n", __func__,
rig_strvfo(vfo), rig_strrmode(mode), buf); 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; } 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); 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); } 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_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->split = split;
priv->tx_vfo = tx_vfo; priv->tx_vfo = tx_vfo;

Wyświetl plik

@ -2218,12 +2218,13 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo)
int ack_len = sizeof(ackbuf); int ack_len = sizeof(ackbuf);
int retval; int retval;
int vfo_is_main_or_sub = (vfo == RIG_VFO_MAIN) || (vfo == RIG_VFO_SUB); int vfo_is_main_or_sub = (vfo == RIG_VFO_MAIN) || (vfo == RIG_VFO_SUB);
struct rig_cache *cachep = CACHE(rig);
ENTERFUNC; ENTERFUNC;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); 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 // Translate VFO A/B to Main/Sub in satellite mode
if (vfo == RIG_VFO_A) if (vfo == RIG_VFO_A)
@ -2247,7 +2248,7 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo)
} }
else if (vfo == RIG_VFO_B) 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", rig_debug(RIG_DEBUG_WARN, "%s: cannot switch to VFOB when in satmode\n",
__func__); __func__);
@ -2267,7 +2268,7 @@ int ic9700_set_vfo(RIG *rig, vfo_t vfo)
return retval; 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__); 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 // 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; 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__); 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 // we return RIG_OK anyways as this should just be a bad request

Wyświetl plik

@ -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) 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 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", 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; 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 // the IC821 seems to be backwards in satmode -- setting Main select Sub and vice versa
retval = rig_set_vfo(rig, RIG_VFO_SUB); retval = rig_set_vfo(rig, RIG_VFO_SUB);

Wyświetl plik

@ -934,7 +934,8 @@ static vfo_t icom_current_vfo(RIG *rig)
freq_t freq_current, freq_other, freq_current_2; freq_t freq_current, freq_other, freq_current_2;
vfo_t vfo_current = RIG_VFO_NONE; vfo_t vfo_current = RIG_VFO_NONE;
vfo_t vfo_check = RIG_VFO_A; 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; struct icom_priv_data *priv = rs->priv;
#if 0 #if 0
@ -944,7 +945,7 @@ static vfo_t icom_current_vfo(RIG *rig)
// these newer rigs get special treatment // these newer rigs get special treatment
retval = icom_current_vfo_x25(rig, &vfo_current); 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; 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 #endif
if (rs->cache.ptt) if (cachep->ptt)
{ {
// don't do this if transmitting -- XCHG would mess it up // don't do this if transmitting -- XCHG would mess it up
return rs->current_vfo; 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); 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; 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 retval, retval_echo, value;
int satmode = 0; int satmode = 0;
struct rig_state *rs = &rig->state; struct rig_state *rs = STATE(rig);
hamlib_port_t *rp = RIGPORT(rig); hamlib_port_t *rp = RIGPORT(rig);
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
int retry_flag = 1; int retry_flag = 1;
@ -1560,7 +1561,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
#if 0 #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)) || ICOM_IS_ID51))
{ {
rig_debug(RIG_DEBUG_TRACE, "%s(%d): ID55100 0x00\n", __func__, __LINE__); 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 // 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; vfo = rs->tx_vfo;
} }
@ -2895,7 +2896,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
{ {
unsigned char ackbuf[MAXFRAMELEN]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), icvfo, retval; 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; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
const struct icom_priv_caps *priv_caps = rig->caps->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) && else if ((vfo == RIG_VFO_SUB) &&
(VFO_HAS_A_B_ONLY || (VFO_HAS_MAIN_SUB_A_B_ONLY (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 // if rig doesn't have Main/Sub
// or if rig has both Main/Sub and A/B -- e.g. 9700 // 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)); rig_strvfo(vfo));
vfo = RIG_VFO_A; 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_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) 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__, 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 // If we're being asked for A/Main but we are a MainA/MainB rig change it
vfo = RIG_VFO_MAIN; 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 // 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) 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; vfo = RIG_VFO_SUB;
// If we're in satmode for rigs like IC9700 we want the 2nd VFO // 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; 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 // 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 else if ((vfo == RIG_VFO_A || vfo == RIG_VFO_B) && !VFO_HAS_A_B
&& VFO_HAS_MAIN_SUB) && 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_debug(RIG_DEBUG_TRACE, "%s: VFO changing from %s to %s\n", __func__,
rig_strvfo(rig->state.current_vfo), rig_strvfo(vfo)); rig_strvfo(rig->state.current_vfo), rig_strvfo(vfo));
rig->state.cache.freqCurr = cachep->freqCurr = 0; // reset current frequency so set_freq works 1st time
0; // reset current frequency so set_freq works 1st time
} }
rig_debug(RIG_DEBUG_TRACE, "%s: line#%d\n", __func__, __LINE__); 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; icvfo = S_MAIN;
// If not split or satmode then we must want VFOA // 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 if (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->split == RIG_SPLIT_OFF
&& !rig->state.cache.satmode) { icvfo = S_VFOA; } && !cachep->satmode) { icvfo = S_VFOA; }
rig_debug(RIG_DEBUG_TRACE, "%s: Main asked for, ended up with vfo=%s\n", rig_debug(RIG_DEBUG_TRACE, "%s: Main asked for, ended up with vfo=%s\n",
__func__, icvfo == S_MAIN ? "Main" : "VFOA"); __func__, icvfo == S_MAIN ? "Main" : "VFOA");
@ -3023,11 +3024,11 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
icvfo = S_SUB; icvfo = S_SUB;
// If split is on these rigs can only split on Main/VFOB // 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 not split or satmode then we must want VFOB
if (VFO_HAS_MAIN_SUB_A_B_ONLY && rig->state.cache.split == RIG_SPLIT_OFF if (VFO_HAS_MAIN_SUB_A_B_ONLY && cachep->split == RIG_SPLIT_OFF
&& !rig->state.cache.satmode) { icvfo = S_VFOB; } && !cachep->satmode) { icvfo = S_VFOB; }
rig_debug(RIG_DEBUG_TRACE, "%s: Sub asked for, ended up with vfo=%s\n", rig_debug(RIG_DEBUG_TRACE, "%s: Sub asked for, ended up with vfo=%s\n",
__func__, icvfo == S_SUB ? "Sub" : "VFOB"); __func__, icvfo == S_SUB ? "Sub" : "VFOB");
@ -3035,8 +3036,8 @@ int icom_set_vfo(RIG *rig, vfo_t vfo)
break; break;
case RIG_VFO_TX: case RIG_VFO_TX:
icvfo = (rig->state.cache.split != RIG_SPLIT_OFF) ? S_VFOB : S_VFOA; icvfo = (cachep->split != RIG_SPLIT_OFF) ? S_VFOB : S_VFOA;
vfo = (rig->state.cache.split != RIG_SPLIT_OFF) ? RIG_VFO_B : RIG_VFO_A; 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_debug(RIG_DEBUG_TRACE, "%s: RIG_VFO_TX changing vfo to %s\n", __func__,
rig_strvfo(vfo)); rig_strvfo(vfo));
break; 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) 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; ENTERFUNC;
rs = (struct rig_state *) &rig->state;
// Initialize TX VFO if not done yet // Initialize TX VFO if not done yet
if (rs->tx_vfo == RIG_VFO_NONE || rs->tx_vfo == RIG_VFO_CURR if (rs->tx_vfo == RIG_VFO_NONE || rs->tx_vfo == RIG_VFO_CURR
|| rs->tx_vfo == RIG_VFO_TX) || 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; rs->tx_vfo = rs->current_vfo;
} }
else 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 (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; *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", 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) 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; *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, rig_debug(RIG_DEBUG_TRACE,
"%s: VFO_HAS_MAIN_SUB_ONLY, split=%d, rx=%s, tx=%s\n", "%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) 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; *rx_vfo = RIG_VFO_MAIN;
*tx_vfo = RIG_VFO_SUB; *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; *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, rig_debug(RIG_DEBUG_TRACE,
"%s: VFO_HAS_MAIN_SUB_A_B_ONLY, split=%d, rx=%s, tx=%s\n", "%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 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) 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); hamlib_port_t *rp = RIGPORT(rig);
struct icom_priv_data *priv = rs->priv; struct icom_priv_data *priv = rs->priv;
const struct icom_priv_caps *priv_caps = rig->caps->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_strvfo(rs->current_vfo));
rig_debug(RIG_DEBUG_VERBOSE, "%s: satmode=%d, tx_vfo=%s\n", __func__, 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 (vfo == RIG_VFO_TX)
{ {
if (rs->cache.satmode) { vfo = RIG_VFO_SUB; } if (cachep->satmode) { vfo = RIG_VFO_SUB; }
else { vfo = rs->tx_vfo; } 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 :( */ /* 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ 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 // 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", 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; HAMLIB_TRACE;
@ -5710,7 +5711,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
RETURNFUNC2(retval); 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 */ /* Re-enable split */
retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, 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) 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); hamlib_port_t *rp = RIGPORT(rig);
struct icom_priv_data *priv = rs->priv; struct icom_priv_data *priv = rs->priv;
const struct icom_priv_caps *priv_caps = rig->caps->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 :( */ /* 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ split for certainty */
@ -5888,7 +5890,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
RETURNFUNC2(retval); 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 */ /* Re-enable split */
retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, 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, int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
pbwidth_t tx_width) 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; struct icom_priv_data *priv = rs->priv;
unsigned char ackbuf[MAXFRAMELEN]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf); 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 :( */ /* 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ split for certainty */
@ -5994,7 +5997,7 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
RETURNFUNC(retval); 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 */ /* Re-enable split */
retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, 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 :( */ /* 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ split for certainty */
@ -6099,7 +6102,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
RETURNFUNC(retval); 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 */ /* Re-enable split */
retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, 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, int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
rmode_t tx_mode, pbwidth_t tx_width) 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; struct icom_priv_data *priv = rs->priv;
unsigned char ackbuf[MAXFRAMELEN]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf); 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 :( */ /* 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ 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)); 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 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; tx_vfo = vfo;
rig_debug(RIG_DEBUG_TRACE, "%s: split not on so using requested vfo=%s\n", 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); 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 */ /* Re-enable split */
retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, 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, int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq,
rmode_t *tx_mode, pbwidth_t *tx_width) 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; struct icom_priv_data *priv = rs->priv;
unsigned char ackbuf[MAXFRAMELEN]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf); 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 :( */ /* 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ split for certainty */
@ -6397,7 +6400,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq,
RETURNFUNC(retval); 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 */ /* Re-enable split */
retval = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, 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) 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; const struct icom_priv_caps *priv_caps = rig->caps->priv;
unsigned char ackbuf[MAXFRAMELEN]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), retval; 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); rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode);
if ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB) if ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB)
&& !rig->state.cache.satmode) && !cachep->satmode)
{ {
rig_debug(RIG_DEBUG_VERBOSE, rig_debug(RIG_DEBUG_VERBOSE,
"%s: requesting split for Main/Sub VFO and satmode is OFF so turning satmode ON\n", "%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); RETURNFUNC2(retval);
} }
else if ((tx_vfo == RIG_VFO_A || tx_vfo == RIG_VFO_B) else if ((tx_vfo == RIG_VFO_A || tx_vfo == RIG_VFO_B)
&& rig->state.cache.satmode) && cachep->satmode)
{ {
rig_debug(RIG_DEBUG_VERBOSE, rig_debug(RIG_DEBUG_VERBOSE,
"%s: requesting split for VFO A/B and satmode is ON so turning satmode OFF\n", "%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); rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, 0);
} }
else if ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB) 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, rig_debug(RIG_DEBUG_VERBOSE,
"%s: requesting split for Main/Sub VFO and rig is already in satmode so setting split on " "%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]; unsigned char splitbuf[MAXFRAMELEN];
int split_len, retval, satmode = 0; int split_len, retval, satmode = 0;
struct rig_state *rs = &rig->state; struct rig_state *rs = STATE(rig);
ENTERFUNC; ENTERFUNC;
retval = icom_transaction(rig, C_CTL_SPLT, -1, NULL, 0, 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() // 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); 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 || if (rig->state.current_vfo != RIG_VFO_MEM ||
!rig_has_vfo_op(rig, RIG_OP_XCHG)) !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); 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; 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", rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): changed satmode=%d\n",
__func__, __LINE__, satmode); __func__, __LINE__, satmode);
@ -7037,7 +7041,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
__func__, __LINE__, satmode); __func__, __LINE__, satmode);
} }
rig->state.cache.satmode = satmode; CACHE(rig)->satmode = satmode;
icom_satmode_fix(rig, satmode); icom_satmode_fix(rig, satmode);
// Turning satmode ON/OFF can change the TX/RX VFOs // 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) 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; struct icom_priv_data *priv = rs->priv;
int satmode = ackbuf[2 + fct_len]; int satmode = ackbuf[2 + fct_len];
*status = satmode; *status = satmode;
if (satmode != rig->state.cache.satmode) if (satmode != CACHE(rig)->satmode)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): changed satmode=%d\n", rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): changed satmode=%d\n",
__func__, __LINE__, satmode); __func__, __LINE__, satmode);
@ -7303,7 +7307,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
__func__, __LINE__, satmode); __func__, __LINE__, satmode);
} }
rig->state.cache.satmode = satmode; CACHE(rig)->satmode = satmode;
icom_satmode_fix(rig, satmode); icom_satmode_fix(rig, satmode);
} }
else 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 // only need to set vfo if it's changed
else if (rs->current_vfo != vfo) else if (rs->current_vfo != vfo)
{ {
if (!(VFO_HAS_MAIN_SUB_A_B_ONLY && rs->cache.split == RIG_SPLIT_OFF if (!(VFO_HAS_MAIN_SUB_A_B_ONLY && CACHE(rig)->split == RIG_SPLIT_OFF
&& !rs->cache.satmode && !CACHE(rig)->satmode
&& vfo == RIG_VFO_SUB && rs->current_vfo == RIG_VFO_B)) && vfo == RIG_VFO_SUB && rs->current_vfo == RIG_VFO_B))
{ {
rig_debug(RIG_DEBUG_TRACE, "%s: setting new vfo=%s\n", __func__, 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) static int icom_get_vfo_number_x25x26(RIG *rig, vfo_t vfo)
{ {
int vfo_number = 0x00; int vfo_number = 0x00;
struct rig_cache *cachep = CACHE(rig);
// Rigs with *only* Main/Sub VFOs can directly address VFOs: 0 = Main, 1 = Sub // 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) 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) 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 // The split VFO is active when transmitting in split mode
vfo_number = (rig->state.cache.split vfo_number = (cachep->split && cachep->ptt) ? !vfo_number : vfo_number;
&& rig->state.cache.ptt) ? !vfo_number : vfo_number;
} }
} }

Wyświetl plik

@ -284,9 +284,9 @@ int id5100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
else if ((vfo == RIG_VFOvfo == RIG_VFO_SUB else if ((vfo == RIG_VFOvfo == RIG_VFO_SUB
&& rs->dual_watch_main_sub == MAIN_ON_RIGHT) && rs->dual_watch_main_sub == MAIN_ON_RIGHT)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Sub/A vfo=%s\n", __func__, __LINE__, rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Sub/A vfo=%s\n", __func__, __LINE__,
rig_strvfo(vfo)); rig_strvfo(vfo));
*freq = rig->state.cache.freqSubA; *freq = CACHE(rig)->freqSubA;
int cache_ms_freq, cache_ms_mode, cache_ms_width; int cache_ms_freq, cache_ms_mode, cache_ms_width;
pbwidth_t width; pbwidth_t width;
freq_t tfreq; freq_t tfreq;

Wyświetl plik

@ -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]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), rc; int ack_len = sizeof(ackbuf), rc;
int split_sc; int split_sc;
struct rig_cache *cachep = CACHE(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); 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: case RIG_SPLIT_ON:
split_sc = S_SPLT_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 */ /* 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)) 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; return -RIG_ERJCTED;
} }
rig->state.cache.split = split; cachep->split = split;
return RIG_OK; return RIG_OK;
} }
@ -988,12 +989,12 @@ static int x108g_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
int rc; int rc;
vfo_t rx_vfo, tx_vfo; vfo_t rx_vfo, tx_vfo;
struct icom_priv_data *priv; 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]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf); int ack_len = sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data *)rs->priv; priv = (struct icom_priv_data *)rs->priv;
/* This method works also in memory mode(RIG_VFO_MEM) */ /* 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 */ queries */
/* broken if user changes split on rig :( */ /* broken if user changes split on rig :( */
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B) 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ 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_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) 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 */ /* Re-enable split */
rc = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len); 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; int rc;
vfo_t rx_vfo, tx_vfo; vfo_t rx_vfo, tx_vfo;
struct icom_priv_data *priv; 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]; unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf); int ack_len = sizeof(ackbuf);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rs = &rig->state;
priv = (struct icom_priv_data *)rs->priv; priv = (struct icom_priv_data *)rs->priv;
/* This method works also in memory mode(RIG_VFO_MEM) */ /* 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 */ queries */
/* broken if user changes split on rig :( */ /* broken if user changes split on rig :( */
if ((rig->state.vfo_list & (RIG_VFO_A | RIG_VFO_B)) == (RIG_VFO_A | RIG_VFO_B) 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 /* VFO A/B style rigs swap VFO on split Tx so we need to disable
split for certainty */ 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_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) 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 */ /* Re-enable split */
rc = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len); rc = icom_transaction(rig, C_CTL_SPLT, S_SPLT_ON, NULL, 0, ackbuf, &ack_len);

Wyświetl plik

@ -339,7 +339,7 @@ static int jst145_get_vfo(RIG *rig, vfo_t *vfo)
jst145_get_ptt(rig, RIG_VFO_A, jst145_get_ptt(rig, RIG_VFO_A,
&ptt); // set priv->ptt to current transmit status &ptt); // set priv->ptt to current transmit status
rig->state.cache.ptt = ptt; CACHE(rig)->ptt = ptt;
ptt_retry: 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; } if (pttstatus[1] == '1') { *ptt = RIG_PTT_ON; }
else { *ptt = RIG_PTT_OFF; } else { *ptt = RIG_PTT_OFF; }
priv->ptt = rig->state.cache.ptt = *ptt; priv->ptt = CACHE(rig)->ptt = *ptt;
return RIG_OK; return RIG_OK;
} }