For FT990UNI permanently cache the update_data block

https://github.com/Hamlib/Hamlib/issues/1050
pull/1068/head
Mike Black W9MDB 2022-06-12 16:49:53 -05:00
rodzic 82fac3e0a6
commit c964ec6bfb
1 zmienionych plików z 10 dodań i 19 usunięć

Wyświetl plik

@ -222,6 +222,7 @@ struct ft990_priv_data
ft990_update_data_t update_data; /* returned data */ ft990_update_data_t update_data; /* returned data */
unsigned char last_vfo_response[FT990_ALL_DATA_LENGTH]; unsigned char last_vfo_response[FT990_ALL_DATA_LENGTH];
struct timespec cache_start; struct timespec cache_start;
int update_count;
}; };
/* /*
@ -380,7 +381,7 @@ const struct rig_caps ft990uni_caps =
RIG_MODEL(RIG_MODEL_FT990UNI), RIG_MODEL(RIG_MODEL_FT990UNI),
.model_name = "FT-990 Old Rom", .model_name = "FT-990 Old Rom",
.mfg_name = "Yaesu", .mfg_name = "Yaesu",
.version = "20220612.0", .version = "20220612.1",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_STABLE, .status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER, .rig_type = RIG_TYPE_TRANSCEIVER,
@ -3412,28 +3413,18 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch)
priv = (struct ft990_priv_data *)rig->state.priv; priv = (struct ft990_priv_data *)rig->state.priv;
if (rig->caps->rig_model == RIG_MODEL_FT990UNI) if (rig->caps->rig_model == RIG_MODEL_FT990UNI && priv->update_count == 0)
{ {
// all we can get is the 1492 byte answer so we'll cache it for repeat calls priv->update_count = 1;
// all we can get is the 1492 byte answer so we'll cache it forever
p = (unsigned char *) &priv->update_data.vfoa; p = (unsigned char *) &priv->update_data.vfoa;
rl = FT990_VFO_DATA_LENGTH; // we'll use the 1508 byte size as it fits the smaller size too rl = FT990_VFO_DATA_LENGTH; // we'll use the 1508 byte size as it fits the smaller size too
// try to cache rapid repeats of the UPDATE_VFO command // cache repeats of the UPDATE_VFO command
if (priv->cache_start.tv_sec != 0) rig_debug(RIG_DEBUG_TRACE, "%s: cache hit\n", __func__);
{ memcpy(p, priv->last_vfo_response, rl);
int cache_age_ms; return RIG_OK;
cache_age_ms = elapsed_ms(&priv->cache_start, 0);
if (cache_age_ms < 500) // 1000ms cache time
{
rig_debug(RIG_DEBUG_TRACE, "%s: cache hit, age=%dms\n", __func__, cache_age_ms);
memcpy(p, priv->last_vfo_response, rl);
return RIG_OK;
}
// else we drop through and do the real IF command
}
} }
// else we drop through and do the real IF command
rig_flush(&rig->state.rigport); rig_flush(&rig->state.rigport);