From 60201aab40a9e3d59e8347fbef8a5679248b7c6f Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Sat, 26 Sep 2020 17:45:45 -0500 Subject: [PATCH] Allow yaesu 3+char read cmds to not invalidate the IF cache https://github.com/Hamlib/Hamlib/issues/385 --- rigs/yaesu/newcat.c | 85 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 21b98e8a9..ce813933c 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -889,7 +889,7 @@ int newcat_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } /* - * rig_set_vfo + * newcat_set_vfo * * set vfo and store requested vfo for later RIG_VFO_CURR * requests. @@ -3779,7 +3779,12 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CT0%c", cat_term); - priv->cmd_str[2] = main_sub_vfo; + + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + { + priv->cmd_str[2] = main_sub_vfo; + } + break; case RIG_FUNC_TSQL: @@ -3789,7 +3794,12 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CT0%c", cat_term); - priv->cmd_str[2] = main_sub_vfo; + + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + { + priv->cmd_str[2] = main_sub_vfo; + } + break; case RIG_FUNC_LOCK: @@ -3817,7 +3827,12 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } snprintf(priv->cmd_str, sizeof(priv->cmd_str), "NB0%c", cat_term); - priv->cmd_str[2] = main_sub_vfo; + + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + { + priv->cmd_str[2] = main_sub_vfo; + } + break; case RIG_FUNC_NR: @@ -3827,7 +3842,12 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } snprintf(priv->cmd_str, sizeof(priv->cmd_str), "NR0%c", cat_term); - priv->cmd_str[2] = main_sub_vfo; + + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + { + priv->cmd_str[2] = main_sub_vfo; + } + break; case RIG_FUNC_COMP: @@ -6442,6 +6462,7 @@ int newcat_get_cmd(RIG *rig) struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; int retry_count = 0; int rc = -RIG_EPROTO; + int is_read_cmd = 0; // try to cache rapid repeats of the IF command // this is for WSJT-X/JTDX sequence of v/f/m/t @@ -6463,8 +6484,60 @@ int newcat_get_cmd(RIG *rig) // we drop through and do the real IF command } + is_read_cmd = + strcmp(priv->cmd_str,"AG0;")==0 + || strcmp(priv->cmd_str,"AG1;")==0 + || strcmp(priv->cmd_str,"AN0;")==0 + || strcmp(priv->cmd_str,"AN1;")==0 + || strcmp(priv->cmd_str,"BP00;")==0 + || strcmp(priv->cmd_str,"BP01;")==0 + || strcmp(priv->cmd_str,"BP10;")==0 + || strcmp(priv->cmd_str,"BP11;")==0 + || strcmp(priv->cmd_str,"CN00;")==0 + || strcmp(priv->cmd_str,"CN10;")==0 + || strcmp(priv->cmd_str,"CO00;")==0 + || strcmp(priv->cmd_str,"CO01;")==0 + || strcmp(priv->cmd_str,"CO02;")==0 + || strcmp(priv->cmd_str,"CO03;")==0 + || strcmp(priv->cmd_str,"CO10;")==0 + || strcmp(priv->cmd_str,"CO11;")==0 + || strcmp(priv->cmd_str,"CO12;")==0 + || strcmp(priv->cmd_str,"CO13;")==0 + || strcmp(priv->cmd_str,"IS1;")==0 + || strcmp(priv->cmd_str,"IS0;")==0 + || strcmp(priv->cmd_str,"IS1;")==0 + || strcmp(priv->cmd_str,"MD0;")==0 + || strcmp(priv->cmd_str,"MD1;")==0 + || strcmp(priv->cmd_str,"NA0;")==0 + || strcmp(priv->cmd_str,"NA1;")==0 + || strcmp(priv->cmd_str,"NB0;")==0 + || strcmp(priv->cmd_str,"NB1;")==0 + || strcmp(priv->cmd_str,"NL0;")==0 + || strcmp(priv->cmd_str,"NL1;")==0 + || strcmp(priv->cmd_str,"NR0;")==0 + || strcmp(priv->cmd_str,"NR1;")==0 + || strcmp(priv->cmd_str,"OS0;")==0 + || strcmp(priv->cmd_str,"OS1;")==0 + || strcmp(priv->cmd_str,"PA0;")==0 + || strcmp(priv->cmd_str,"PA1;")==0 + || strcmp(priv->cmd_str,"RA0;")==0 + || strcmp(priv->cmd_str,"RA1;")==0 + || strcmp(priv->cmd_str,"RF0;")==0 + || strcmp(priv->cmd_str,"RF1;")==0 + || strcmp(priv->cmd_str,"RL0;")==0 + || strcmp(priv->cmd_str,"RL1;")==0 + || strcmp(priv->cmd_str,"RM0;")==0 + || strcmp(priv->cmd_str,"RM1;")==0 + || strcmp(priv->cmd_str,"SM0;")==0 + || strcmp(priv->cmd_str,"SM1;")==0 + || strcmp(priv->cmd_str,"SQ0;")==0 + || strcmp(priv->cmd_str,"SQ1;")==0 + || strcmp(priv->cmd_str,"VT0;")==0 + || strcmp(priv->cmd_str,"VT1;")==0 + || strcmp(priv->cmd_str,"SQ1;")==0; + if (priv->cmd_str[2] != - ';') // then we must be setting something so we'll invalidate the cache + ';' && !is_read_cmd) // 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;