From 600a674891e8ad19b96a4e56cc0293742ad65a2d Mon Sep 17 00:00:00 2001 From: mdblack98 Date: Mon, 27 Apr 2020 09:36:40 -0500 Subject: [PATCH] Add cache invalidation for kenwood and yaesu Reset all kenwood/yaesu backend versions to 0 since main backend is new https://github.com/Hamlib/Hamlib/issues/226 --- rigs/kenwood/kenwood.c | 25 +++++++++++++++++-------- rigs/kenwood/kenwood.h | 2 +- rigs/kenwood/pihpsdr.c | 2 +- rigs/kenwood/ts480.c | 2 +- rigs/kenwood/ts950.c | 2 +- rigs/yaesu/newcat.c | 20 +++++++++++++++----- tests/config/unix.exp | 16 +++++++++++++++- 7 files changed, 51 insertions(+), 18 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index ccfb4ea5c..4a90116dd 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -532,8 +532,8 @@ 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 (strncmp(cmd, "IF", 2) == 0 && priv->cache_start.tv_sec != 0) + // if this is an IF; cmd and not the first time through check cache + if (strncmp(cmd, "IF;", 3) == 0 && priv->cache_start.tv_sec != 0) { int cache_age_ms; @@ -548,6 +548,13 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf, // else we drop through and do the real IF command } + else if (cmd[2] != ';') + { + // 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); @@ -581,12 +588,12 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf, } } while (err != RIG_OK && ++retry < rig->state.rigport.retry); - + // update the cache - if (strncmp(cmd, "IF", 2) == 0) + if (strncmp(cmd, "IF;", 3) == 0) { - elapsed_ms(&priv->cache_start, 1); - strcpy(priv->last_if_response, buf); + elapsed_ms(&priv->cache_start, 1); + strcpy(priv->last_if_response, buf); } return err; @@ -3880,8 +3887,10 @@ int kenwood_get_channel(RIG *rig, channel_t *chan, int read_only) } #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; diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 8ca23e44f..ee1daf6e7 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -27,7 +27,7 @@ #include #include "token.h" -#define BACKEND_VER "20200426" +#define BACKEND_VER "20200427" #define EOM_KEN ';' #define EOM_TH '\r' diff --git a/rigs/kenwood/pihpsdr.c b/rigs/kenwood/pihpsdr.c index 060a23fcc..cdd4fd348 100644 --- a/rigs/kenwood/pihpsdr.c +++ b/rigs/kenwood/pihpsdr.c @@ -102,7 +102,7 @@ const struct rig_caps pihpsdr_caps = RIG_MODEL(RIG_MODEL_HPSDR), .model_name = "PiHPSDR", .mfg_name = "OpenHPSDR", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c index fecc3d94b..c3b9cf36c 100644 --- a/rigs/kenwood/ts480.c +++ b/rigs/kenwood/ts480.c @@ -634,7 +634,7 @@ const struct rig_caps pt8000a_caps = RIG_MODEL(RIG_MODEL_PT8000A), .model_name = "PT-8000A", .mfg_name = "Hilberling", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".0", .copyright = "LGPL", .status = RIG_STATUS_BETA, .rig_type = RIG_TYPE_TRANSCEIVER, diff --git a/rigs/kenwood/ts950.c b/rigs/kenwood/ts950.c index 5c44c9bba..e454b6831 100644 --- a/rigs/kenwood/ts950.c +++ b/rigs/kenwood/ts950.c @@ -60,7 +60,7 @@ const struct rig_caps ts950s_caps = RIG_MODEL(RIG_MODEL_TS950S), .model_name = "TS-950S", .mfg_name = "Kenwood", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 04de8ba4a..f2fc8c4c1 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -864,6 +864,8 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) priv = (struct newcat_priv_data *)rig->state.priv; state = &rig->state; + priv->cache_start.tv_sec = 0; // invalidate the cache + rig_debug(RIG_DEBUG_TRACE, "%s: called, passed vfo = %s\n", __func__, rig_strvfo(vfo)); @@ -1055,6 +1057,8 @@ int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) char txon[] = "TX1;"; char txoff[] = "TX0;"; + priv->cache_start.tv_sec = 0; // invalidate the cache + if (!newcat_valid_command(rig, "TX")) { return -RIG_ENAVAIL; @@ -5937,8 +5941,9 @@ int newcat_get_cmd(RIG *rig) // 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 (strncmp(priv->cmd_str, "IF", 2) == 0 && priv->cache_start.tv_sec != 0) + // should allow rapid repeat of any call using the IF; cmd + // Any call that changes something in the IF response should invalidate the cache + if (strncmp(priv->cmd_str, "IF;", 2) == 0 && priv->cache_start.tv_sec != 0) { int cache_age_ms; @@ -5950,9 +5955,14 @@ int newcat_get_cmd(RIG *rig) strcpy(priv->ret_data, priv->last_if_response); return RIG_OK; } - - // else we drop through and do the real IF command + // we drop through and do the real IF command } + else if (priv->cmd_str[2] != ';') // 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; + } + while (rc != RIG_OK && retry_count++ <= state->rigport.retry) { @@ -6048,7 +6058,7 @@ int newcat_get_cmd(RIG *rig) } // update the cache - if (strncmp(priv->cmd_str, "IF", 2) == 0) + if (strncmp(priv->cmd_str, "IF;", 3) == 0) { elapsed_ms(&priv->cache_start, 1); strcpy(priv->last_if_response, priv->ret_data); diff --git a/tests/config/unix.exp b/tests/config/unix.exp index 6d6e35b80..ff023e709 100644 --- a/tests/config/unix.exp +++ b/tests/config/unix.exp @@ -17,7 +17,8 @@ # Please email any bugs, comments, and/or additions to this file to: # hamlib-developer@lists.sourceforge.net -set RIGCTL "$srcdir/rigctl" +set RIGCTL "../rigctl" +set verbose 0 if ![info exists prompt] then { set prompt "Rig command: " @@ -70,3 +71,16 @@ proc rigctl_start {} { } rigctl_start +send "v\n" +expect { -re ""} +expect { -re "v*"} +expect { -re "VFO:*"} +expect { -re "Rig Command:"} +#send "f\n" +#expect { -re "Frequency:*"} +#interact +#send "m\n" +#expect { -re "Mode:*"} +#send "t\n" +#expect { -re "PTT:*"} +rigctl_exit