From 04b4b83f15564f020106a0e02e07a4e9a27f0fd0 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Fri, 2 Apr 2021 08:19:15 -0500 Subject: [PATCH] Add a ptt check to ensure ptt is off for FTDX3000 and FTDX5000 Will wait up to 300ms for PTT off to occur Should help prevent trying to set freq while ptt is on https://github.com/Hamlib/Hamlib/issues/639 --- rigs/yaesu/newcat.c | 19 ++++++++++++++++--- rigs/yaesu/newcat.h | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 9dad47bcf..8c601c8ab 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -806,13 +806,26 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if (is_ftdx3000 || is_ftdx5000) { // we have a few rigs that can't set freq while PTT_ON + // so we'll try a few times to see if we just need to wait a bit + // 3 retries should be about 400ms -- hopefully more than enough ptt_t ptt; + int retry = 3; - if (RIG_OK != (err = newcat_get_ptt(rig, vfo, &ptt))) + do { - ERRMSG(err, "newcat_set_cmd failed"); - RETURNFUNC(err); + if (RIG_OK != (err = newcat_get_ptt(rig, vfo, &ptt))) + { + ERRMSG(err, "newcat_set_cmd failed"); + RETURNFUNC(err); + } + + if (ptt == RIG_PTT_ON) + { + rig_debug(RIG_DEBUG_WARN, "%s: ptt still on...retry#%d\n", __func__, retry); + hl_usleep(100 * 1000); // 100ms pause if ptt still on + } } + while (err == RIG_OK && ptt == RIG_PTT_ON && retry-- > 0); if (ptt) { return RIG_ENTARGET; } } diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index f13ca3629..3c7b5e384 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20210327" +#define NEWCAT_VER "20210330" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129