Add caching for the Yaesu IF command

It should speed up the WSJT-X/JTDX sequence of v,f,m,t by a fair bit removing two unnecessary IF commands that should get cached
pull/234/head
mdblack98 2020-04-26 15:44:38 -05:00
rodzic 5eb5b6f3d8
commit eb7829bd06
4 zmienionych plików z 54 dodań i 2 usunięć

Wyświetl plik

@ -4637,8 +4637,10 @@ int newcat_get_channel(RIG *rig, channel_t *chan, int read_only)
chan->freq = atof(retval);
#warning Need to add setting rig to channel values
if (!read_only) {
// Set rig to channel values
if (!read_only)
{
// Set rig to channel values
}
return RIG_OK;
@ -6130,6 +6132,25 @@ int newcat_get_cmd(RIG *rig)
int retry_count = 0;
int rc = -RIG_EPROTO;
// try to cache rapid repeats of the IF command
// this is for WSJT-X/JTDX sequence of v/f/m/t
// should reduce 3 IF requests to 1 request and 2 cache hits
if (strcmp(priv->cmd_str, "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(priv->ret_data, priv->last_if_response);
return RIG_OK;
}
// else we drop through and do the real IF command
}
while (rc != RIG_OK && retry_count++ <= state->rigport.retry)
{
if (rc != -RIG_BUSBUSY)
@ -6223,6 +6244,10 @@ int newcat_get_cmd(RIG *rig)
}
}
// update the cache
elapsed_ms(&priv->cache_start, 1);
strcpy(priv->last_if_response, priv->ret_data);
return rc;
}

Wyświetl plik

@ -88,6 +88,8 @@ struct newcat_priv_data {
int trn_state; /* AI state found at startup */
int fast_set_commands; /* do not check for ACK/NAK; needed for high throughput > 100 commands/s */
int width_frequency; /* found at startup */
struct timespec cache_start;
char last_if_response[NEWCAT_DATA_LEN];
};

Wyświetl plik

@ -1252,6 +1252,29 @@ void HAMLIB_API rig_no_restore_ai()
no_restore_ai = -1;
}
//! @cond Doxygen_Suppress
int HAMLIB_API elapsed_ms(struct timespec *start, int flag_start)
{
// If flag_start then we are starting the timing, else we get elapsed
struct timespec stop;
double elapsed_secs;
if (flag_start)
{
clock_gettime(CLOCK_REALTIME, start);
return 0;
}
else
{
clock_gettime(CLOCK_REALTIME, &stop);
}
elapsed_secs = (stop.tv_sec - start->tv_sec) * 1e6 + (stop.tv_nsec -
start->tv_nsec) / 1e3;
return elapsed_secs / 1000;
}
//! @endcond
/** @} */

Wyświetl plik

@ -100,6 +100,8 @@ extern HAMLIB_EXPORT(setting_t) rig_idx2setting(int i);
extern HAMLIB_EXPORT(int) hl_usleep(useconds_t usec);
extern HAMLIB_EXPORT(int) elapsed_ms(struct timespec *start, int start_flag);
#ifdef PRId64
/** \brief printf(3) format to be used for long long (64bits) type */
# define PRIll PRId64