kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'master' of https://github.com/mdblack98/Hamlib
commit
fef8648634
|
@ -255,6 +255,30 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data,
|
|||
/* Emulators don't need any post_write_delay */
|
||||
if (priv->is_emulation) { rs->rigport.post_write_delay = 0; }
|
||||
|
||||
// if this is an IF cmdstr and not the first time through check cache
|
||||
if (strcmp(cmdstr, "IF") == 0 && priv->cache_start.tv_sec != 0)
|
||||
{
|
||||
int cache_age_ms;
|
||||
|
||||
cache_age_ms = elapsed_ms(&priv->cache_start, 0);
|
||||
|
||||
if (cache_age_ms < 500) // 500ms cache time
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cache hit, age=%dms\n", __func__, cache_age_ms);
|
||||
if (data) strncpy(data, priv->last_if_response, datasize);
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
// else we drop through and do the real IF command
|
||||
}
|
||||
|
||||
if (strlen(cmdstr) > 2 || strcmp(cmdstr,"RX")==0 || strcmp(cmdstr,"TX") == 0)
|
||||
{
|
||||
// then we must be setting something so we'll invalidate the cache
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cache invalidated\n", __func__);
|
||||
priv->cache_start.tv_sec = 0;
|
||||
}
|
||||
|
||||
cmdtrm[0] = caps->cmdtrm;
|
||||
cmdtrm[1] = '\0';
|
||||
|
||||
|
@ -495,6 +519,13 @@ transaction_read:
|
|||
|
||||
transaction_quit:
|
||||
|
||||
// update the cache
|
||||
if (strcmp(cmdstr, "IF") == 0)
|
||||
{
|
||||
elapsed_ms(&priv->cache_start, 1);
|
||||
strncpy(priv->last_if_response, buffer, sizeof(priv->last_if_response));
|
||||
}
|
||||
|
||||
rs->hold_decode = 0;
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: returning retval=%d\n", __func__, retval);
|
||||
return retval;
|
||||
|
@ -523,7 +554,6 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf,
|
|||
{
|
||||
int err;
|
||||
int retry = 0;
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -532,30 +562,6 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf,
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
// if this is an IF cmd and not the first time through check cache
|
||||
if (strcmp(cmd, "IF") == 0 && priv->cache_start.tv_sec != 0)
|
||||
{
|
||||
int cache_age_ms;
|
||||
|
||||
cache_age_ms = elapsed_ms(&priv->cache_start, 0);
|
||||
|
||||
if (cache_age_ms < 500) // 500ms cache time
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cache hit, age=%dms\n", __func__, cache_age_ms);
|
||||
strcpy(buf, priv->last_if_response);
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
// else we drop through and do the real IF command
|
||||
}
|
||||
|
||||
if (strlen(cmd) > 2 || strcmp(cmd,"RX")==0 || strcmp(cmd,"TX") == 0)
|
||||
{
|
||||
// then we must be setting something so we'll invalidate the cache
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: cache invalidated\n", __func__);
|
||||
priv->cache_start.tv_sec = 0;
|
||||
}
|
||||
|
||||
memset(buf, 0, buf_size);
|
||||
|
||||
if (expected == 0)
|
||||
|
@ -588,13 +594,6 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf,
|
|||
}
|
||||
while (err != RIG_OK && ++retry < rig->state.rigport.retry);
|
||||
|
||||
// update the cache
|
||||
if (strcmp(cmd, "IF") == 0)
|
||||
{
|
||||
elapsed_ms(&priv->cache_start, 1);
|
||||
strcpy(priv->last_if_response, buf);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue