Use pointers for all cache references in rigs/*

pull/1523/head
George Baltz N3GB 2024-03-09 14:25:59 -05:00
rodzic 609065775c
commit aa0d83df95
13 zmienionych plików z 78 dodań i 71 usunięć

Wyświetl plik

@ -692,7 +692,7 @@ static int ts2000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return RIG_OK;
case RIG_LEVEL_STRENGTH:
if (rig->state.cache.ptt != RIG_PTT_OFF)
if (CACHE(rig)->ptt != RIG_PTT_OFF)
{
val->i = -9 * 6;
break;
@ -879,7 +879,7 @@ static int ts2000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int raw_value;
char read_vfo_num;
if (rig->state.cache.ptt == RIG_PTT_OFF)
if (CACHE(rig)->ptt == RIG_PTT_OFF)
{
val->f = 0;
break;

Wyświetl plik

@ -581,7 +581,7 @@ kenwood_ts480_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return RIG_OK;
case RIG_LEVEL_STRENGTH:
if (rig->state.cache.ptt != RIG_PTT_OFF)
if (CACHE(rig)->ptt != RIG_PTT_OFF)
{
val->i = -9 * 6;
break;
@ -708,7 +708,7 @@ kenwood_ts480_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
int raw_value;
if (rig->state.cache.ptt == RIG_PTT_OFF)
if (CACHE(rig)->ptt == RIG_PTT_OFF)
{
val->f = 0;
break;
@ -2198,15 +2198,16 @@ int malachite_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int malachite_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
struct rig_cache *cachep = CACHE(rig);
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "%s: freqMainA=%g, freq=%g\n", __func__,
rig->state.cache.freqMainA, freq);
cachep->freqMainA, freq);
if ((rig->state.cache.freqMainA < 400000000 && freq >= 400000000)
|| (rig->state.cache.freqMainA >= 400000000 && freq < 400000000)
|| rig->state.cache.freqMainA == 0)
if ((cachep->freqMainA < 400000000 && freq >= 400000000)
|| (cachep->freqMainA >= 400000000 && freq < 400000000)
|| cachep->freqMainA == 0)
{
// Malachite has a bug where it takes two freq set to make it work
// under band changes -- so we just do this all the time

Wyświetl plik

@ -240,7 +240,7 @@ static int ts590_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (!sf_fails)
{
SNPRINTF(cmd, sizeof(cmd), "SF%d%011.0f%c", vfo == RIG_VFO_A ? 0 : 1,
vfo == RIG_VFO_A ? rig->state.cache.freqMainA : rig->state.cache.freqMainB,
vfo == RIG_VFO_A ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB,
c);
retval = kenwood_transaction(rig, cmd, NULL, 0);
}
@ -328,7 +328,7 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); }
if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, CACHE(rig)->split); }
retval = RIG_OK;
@ -875,7 +875,7 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return RIG_OK;
case RIG_LEVEL_STRENGTH:
if (rig->state.cache.ptt != RIG_PTT_OFF)
if (CACHE(rig)->ptt != RIG_PTT_OFF)
{
val->i = -9 * 6;
break;
@ -1022,7 +1022,7 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int raw_value;
if (rig->state.cache.ptt == RIG_PTT_OFF)
if (CACHE(rig)->ptt == RIG_PTT_OFF)
{
val->f = 0;
break;

Wyświetl plik

@ -914,7 +914,7 @@ int ft100_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
unsigned char cmd_index;
int split = rig->state.cache.split;
int split = CACHE(rig)->split;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -971,8 +971,8 @@ int ft100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
int ret;
int split = rig->state.cache.split;
int ptt = rig->state.cache.ptt;
int split = CACHE(rig)->split;
int ptt = CACHE(rig)->ptt;
FT100_METER_INFO ft100_meter;

Wyświetl plik

@ -4121,11 +4121,11 @@ static int ft1000_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (vfo == RIG_VFO_A)
{
*freq = rig->state.cache.freqMainA;
*freq = CACHE(rig)->freqMainA;
}
else
{
*freq = rig->state.cache.freqMainB;
*freq = CACHE(rig)->freqMainB;
}
return RIG_OK;
@ -4135,11 +4135,11 @@ static int ft1000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
if (vfo == RIG_VFO_A)
{
*mode = rig->state.cache.modeMainA;
*mode = CACHE(rig)->modeMainA;
}
else
{
*mode = rig->state.cache.modeMainB;
*mode = CACHE(rig)->modeMainB;
}
return RIG_OK;
@ -4153,7 +4153,7 @@ static int ft1000_get_vfo(RIG *rig, vfo_t *vfo)
static int ft1000_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
*ptt = rig->state.cache.ptt;
*ptt = CACHE(rig)->ptt;
return RIG_OK;
}

Wyświetl plik

@ -932,11 +932,11 @@ static int ft1000mp_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (vfo == RIG_VFO_A)
{
*freq = rig->state.cache.freqMainA;
*freq = CACHE(rig)->freqMainA;
}
else
{
*freq = rig->state.cache.freqMainB;
*freq = CACHE(rig)->freqMainB;
}
return RIG_OK;
@ -1818,8 +1818,8 @@ static int ft1000mp_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
if (retval == RIG_OK)
{
rig->state.cache.freqMainB = freq;
rig->state.cache.modeMainB = mode;
CACHE(rig)->freqMainB = freq;
CACHE(rig)->modeMainB = mode;
}
RETURNFUNC(retval);
@ -1842,8 +1842,8 @@ static int ft1000mp_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq,
if (retval == RIG_OK)
{
rig->state.cache.freqMainB = *freq;
rig->state.cache.modeMainB = *mode;
CACHE(rig)->freqMainB = *freq;
CACHE(rig)->modeMainB = *mode;
}
RETURNFUNC(retval);

Wyświetl plik

@ -298,7 +298,7 @@ int ft736_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) { *freq = rig->state.cache.freqMainA; }
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) { *freq = CACHE(rig)->freqMainA; }
else { rig_get_cache_freq(rig, vfo, freq, NULL); }
return RIG_OK;

Wyświetl plik

@ -579,18 +579,19 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int ft747_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct ft747_priv_data *p;
struct rig_cache *cachep = CACHE(rig);
freq_t f;
int ret;
rig_debug(RIG_DEBUG_VERBOSE,
"%s: called vfo=%s, freqMainA=%.0f, freqMainB=%.0f\n", __func__,
rig_strvfo(vfo), rig->state.cache.freqMainA, rig->state.cache.freqMainB);
rig_strvfo(vfo), cachep->freqMainA, cachep->freqMainB);
if (vfo == RIG_VFO_CURR) { vfo = rig->state.cache.vfo; }
if (vfo == RIG_VFO_CURR) { vfo = cachep->vfo; }
if (rig->state.cache.ptt == RIG_PTT_ON)
if (cachep->ptt == RIG_PTT_ON)
{
*freq = RIG_VFO_B ? rig->state.cache.freqMainB : rig->state.cache.freqMainA;
*freq = RIG_VFO_B ? cachep->freqMainB : cachep->freqMainA;
return RIG_OK;
}
@ -1005,7 +1006,7 @@ static int ft747_get_update_data(RIG *rig)
p = (struct ft747_priv_data *)rig->state.priv;
rigport = RIGPORT(rig);
if (rig->state.cache.ptt == RIG_PTT_ON
if (CACHE(rig)->ptt == RIG_PTT_ON
|| !rig_check_cache_timeout(&p->status_tv, FT747_CACHE_TIMEOUT))
{
return RIG_OK;

Wyświetl plik

@ -988,16 +988,17 @@ static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
freq_t f1 = 0, f2 = 0;
struct rig_cache *cachep = CACHE(rig);
int retries = RIGPORT(rig)->retry +
1; // +1 because, because 2 steps are needed even in best scenario
rig_debug(RIG_DEBUG_VERBOSE, "%s: called, vfo=%s, ptt=%d, split=%d\n", __func__,
rig_strvfo(vfo), rig->state.cache.ptt, rig->state.cache.split);
rig_strvfo(vfo), cachep->ptt, cachep->split);
// we can't query VFOB while in transmit and split mode
if (rig->state.cache.ptt && vfo == RIG_VFO_B && rig->state.cache.split)
if (cachep->ptt && vfo == RIG_VFO_B && cachep->split)
{
*freq = rig->state.cache.freqMainB;
*freq = cachep->freqMainB;
return RIG_OK;
}
@ -2127,7 +2128,7 @@ static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
return n;
}
rig->state.cache.split = split;
CACHE(rig)->split = split;
return RIG_OK;

Wyświetl plik

@ -615,14 +615,14 @@ int ft857_get_vfo(RIG *rig, vfo_t *vfo)
// Some 857's cannot read so we'll just return the cached value if we've seen an error
if (ignore)
{
*vfo = rig->state.cache.vfo;
*vfo = CACHE(rig)->vfo;
return RIG_OK;
}
if (ft857_read_eeprom(rig, 0x0068, &c) < 0) /* get vfo status */
{
ignore = 1;
*vfo = rig->state.cache.vfo;
*vfo = CACHE(rig)->vfo;
return RIG_OK;
}

Wyświetl plik

@ -701,7 +701,7 @@ int ft990v12_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
else
{
// M0EZP: Uni use cache
// *freq = vfo == RIG_VFO_A ? rig->state.cache.freqMainA : rig->state.cache.freqMainB;
// *freq = vfo == RIG_VFO_A ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB;
return (RIG_OK);
}
}

Wyświetl plik

@ -458,7 +458,7 @@ ft991_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
return (rval);
}
if (rig->state.cache.freqMainB == tx_freq)
if (CACHE(rig)->freqMainB == tx_freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: freq %.0f already set on VFOB\n", __func__,
tx_freq);
@ -635,7 +635,7 @@ 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)
if (CACHE(rig)->modeMainB == tx_mode)
{
rig_debug(RIG_DEBUG_TRACE, "%s: mode %s already set on VFOB\n", __func__,
rig_strrmode(tx_mode));

Wyświetl plik

@ -936,17 +936,18 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
char target_vfo;
int err;
struct rig_caps *caps;
struct rig_cache *cachep = CACHE(rig);
struct newcat_priv_data *priv;
int special_60m = 0;
vfo_t vfo_mode;
ENTERFUNC;
if (newcat_60m_exception(rig, freq, rig->state.cache.modeMainA))
if (newcat_60m_exception(rig, freq, cachep->modeMainA))
{
// we don't try to set freq on 60m for some rigs since we must be in memory mode
// and we can't run split mode on 60M memory mode either
if (rig->state.cache.split == RIG_SPLIT_ON)
if (cachep->split == RIG_SPLIT_ON)
{
rig_set_split_vfo(rig, RIG_VFO_A, RIG_VFO_A, RIG_SPLIT_OFF);
}
@ -1029,16 +1030,16 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// some rigs like FTDX101D cannot change non-TX vfo freq
// but they can change the TX vfo
if ((is_ftdx101d || is_ftdx101mp) && rig->state.cache.ptt == RIG_PTT_ON)
if ((is_ftdx101d || is_ftdx101mp) && cachep->ptt == RIG_PTT_ON)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ftdx101 check vfo OK, vfo=%s, tx_vfo=%s\n",
__func__, rig_strvfo(vfo), rig_strvfo(rig->state.tx_vfo));
// when in split we can change VFOB but not VFOA
if (rig->state.cache.split == RIG_SPLIT_ON && target_vfo == '0') { return -RIG_ENTARGET; }
if (cachep->split == RIG_SPLIT_ON && target_vfo == '0') { return -RIG_ENTARGET; }
// when not in split we can't change VFOA at all
if (rig->state.cache.split == RIG_SPLIT_OFF && target_vfo == '0') { return -RIG_ENTARGET; }
if (cachep->split == RIG_SPLIT_OFF && target_vfo == '0') { return -RIG_ENTARGET; }
if (vfo != rig->state.tx_vfo) { return -RIG_ENTARGET; }
}
@ -1077,7 +1078,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
and select the correct VFO before setting the frequency
*/
// Plus we can't do the VFO swap if transmitting
if (target_vfo == '1' && rig->state.cache.ptt == RIG_PTT_ON) { RETURNFUNC(-RIG_ENTARGET); }
if (target_vfo == '1' && cachep->ptt == RIG_PTT_ON) { RETURNFUNC(-RIG_ENTARGET); }
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "VS%c", cat_term);
@ -1147,7 +1148,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (newcat_valid_command(rig, "BS") && changing
&& !rig->state.disable_yaesu_bandselect
// remove the split check here -- hopefully works OK
//&& !rig->state.cache.split
//&& !cachep->split
// seems some rigs are problematic
// && !(is_ftdx3000 || is_ftdx3000dm)
// some rigs can't do BS command on 60M
@ -1331,8 +1332,8 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// just drop through
}
rig_debug(RIG_DEBUG_ERR, "%s: is_ft991=%d, rig->state.cache.split=%d, vfo=%s\n",
__func__, is_ft991, rig->state.cache.split, rig_strvfo(vfo));
rig_debug(RIG_DEBUG_ERR, "%s: is_ft991=%d, CACHE(rig)->split=%d, vfo=%s\n",
__func__, is_ft991, cachep->split, rig_strvfo(vfo));
if (priv->band_index < 0) { priv->band_index = newcat_band_index(freq); }
@ -1340,7 +1341,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// there are multiple bandstacks so we just use the 1st one
if (is_ft991 && vfo == RIG_VFO_A && priv->band_index != newcat_band_index(freq))
{
if (rig->state.cache.split)
if (cachep->split)
{
// FT991/991A bandstack does not work in split mode
// so for a VFOA change we stop split, change bands, change freq, enable split
@ -1493,16 +1494,17 @@ int newcat_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
struct newcat_priv_data *priv;
struct rig_cache *cachep = CACHE(rig);
int err;
rmode_t tmode;
pbwidth_t twidth;
split_t split_save = rig->state.cache.split;
split_t split_save = cachep->split;
priv = (struct newcat_priv_data *)rig->state.priv;
ENTERFUNC;
if (newcat_60m_exception(rig, rig->state.cache.freqMainA, mode)) { RETURNFUNC(RIG_OK); } // we don't set mode in this case
if (newcat_60m_exception(rig, cachep->freqMainA, mode)) { RETURNFUNC(RIG_OK); } // we don't set mode in this case
if (!newcat_valid_command(rig, "MD"))
{
@ -1571,11 +1573,11 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN)
{
rig->state.cache.modeMainA = mode;
cachep->modeMainA = mode;
}
else
{
rig->state.cache.modeMainB = mode;
cachep->modeMainB = mode;
}
if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(err); }
@ -1705,7 +1707,7 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo)
rig_strvfo(vfo));
// we can't change VFO while transmitting
if (rig->state.cache.ptt == RIG_PTT_ON) { RETURNFUNC(RIG_OK); }
if (CACHE(rig)->ptt == RIG_PTT_ON) { RETURNFUNC(RIG_OK); }
if (!newcat_valid_command(rig, command))
{
@ -2712,11 +2714,11 @@ int newcat_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN)
{
rig->state.cache.modeMainA = tx_mode;
CACHE(rig)->modeMainA = tx_mode;
}
else
{
rig->state.cache.modeMainB = tx_mode;
CACHE(rig)->modeMainB = tx_mode;
}
@ -2758,8 +2760,8 @@ int newcat_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
RETURNFUNC(err);
}
if (newcat_60m_exception(rig, rig->state.cache.freqMainA,
rig->state.cache.modeMainA))
if (newcat_60m_exception(rig, CACHE(rig)->freqMainA,
CACHE(rig)->modeMainA))
{
rig_debug(RIG_DEBUG_VERBOSE,
"%s: force set_split off since we're on 60M exception\n", __func__);
@ -4088,7 +4090,8 @@ static int band2rig(hamlib_band_t band)
int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
struct rig_state *state = &rig->state;
struct rig_state *state = STATE(rig);
struct rig_cache *cachep = CACHE(rig);
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int err;
int i;
@ -4300,9 +4303,9 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
rmode_t exclude = RIG_MODE_CW | RIG_MODE_CWR | RIG_MODE_RTTY | RIG_MODE_RTTYR;
if ((rig->state.tx_vfo == RIG_VFO_A && (rig->state.cache.modeMainA & exclude))
|| (rig->state.tx_vfo == RIG_VFO_B && (rig->state.cache.modeMainB & exclude))
|| (rig->state.tx_vfo == RIG_VFO_C && (rig->state.cache.modeMainC & exclude)))
if ((rig->state.tx_vfo == RIG_VFO_A && (cachep->modeMainA & exclude))
|| (rig->state.tx_vfo == RIG_VFO_B && (cachep->modeMainB & exclude))
|| (rig->state.tx_vfo == RIG_VFO_C && (cachep->modeMainC & exclude)))
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: rig cannot set MG in CW/RTTY modes\n",
__func__);
@ -4906,7 +4909,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
if (is_ftdx101d || is_ftdx101mp)
{
rmode_t curmode = rig->state.current_vfo == RIG_VFO_A ?
rig->state.cache.modeMainA : rig->state.cache.modeMainB;
cachep->modeMainA : cachep->modeMainB;
float valf = val.f / level_info->step.f;
switch (curmode)
@ -4960,7 +4963,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
struct rig_state *state = &rig->state;
struct rig_state *state = STATE(rig);
struct rig_cache *cachep = CACHE(rig);
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int err;
int ret_data_len;
@ -5117,9 +5121,9 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rmode_t exclude = RIG_MODE_CW | RIG_MODE_CWR | RIG_MODE_RTTY | RIG_MODE_RTTYR;
if ((rig->state.tx_vfo == RIG_VFO_A && (rig->state.cache.modeMainA & exclude))
|| (rig->state.tx_vfo == RIG_VFO_B && (rig->state.cache.modeMainB & exclude))
|| (rig->state.tx_vfo == RIG_VFO_C && (rig->state.cache.modeMainC & exclude)))
if ((rig->state.tx_vfo == RIG_VFO_A && (cachep->modeMainA & exclude))
|| (rig->state.tx_vfo == RIG_VFO_B && (cachep->modeMainB & exclude))
|| (rig->state.tx_vfo == RIG_VFO_C && (cachep->modeMainC & exclude)))
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: rig cannot read MG in CW/RTTY modes\n",
__func__);
@ -5502,7 +5506,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (is_ftdx101d || is_ftdx101mp)
{
rmode_t curmode = rig->state.current_vfo == RIG_VFO_A ?
rig->state.cache.modeMainA : rig->state.cache.modeMainB;
cachep->modeMainA : cachep->modeMainB;
switch (curmode)
{
@ -5544,7 +5548,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (is_ftdx101d || is_ftdx101mp)
{
rmode_t curmode = rig->state.current_vfo == RIG_VFO_A ?
rig->state.cache.modeMainA : rig->state.cache.modeMainB;
cachep->modeMainA : cachep->modeMainB;
switch (curmode)
{