Skip to content

Commit

Permalink
Use pointers for all cache references in rigs/*
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoBaltz committed Mar 9, 2024
1 parent 6090657 commit aa0d83d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 71 deletions.
4 changes: 2 additions & 2 deletions rigs/kenwood/ts2000.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions rigs/kenwood/ts480.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions rigs/kenwood/ts590.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions rigs/yaesu/ft100.c
Expand Up @@ -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__);

Expand Down Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions rigs/yaesu/ft1000d.c
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
12 changes: 6 additions & 6 deletions rigs/yaesu/ft1000mp.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion rigs/yaesu/ft736.c
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions rigs/yaesu/ft747.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions rigs/yaesu/ft817.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions rigs/yaesu/ft857.c
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion rigs/yaesu/ft990v12.c
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions rigs/yaesu/ft991.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit aa0d83d

Please sign in to comment.