From 09e6ab6ef12357cf9a92fa4648e67b40449547b0 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 11 Mar 2018 19:43:01 +0000 Subject: [PATCH] FT-817 status queries honour retries and timeout This is to help with owners of Arduino boards like the ubitx that emulate an FT-817 but respond badly to a DTR signal glitch which is inevitable when opening a Linux serial port. The glitch triggers the Arduino boot-loader which must be allowed to time out before the FT-817 emulation starts. --- yaesu/ft817.c | 17 ++++++++++------- yaesu/ft817.h | 9 +-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/yaesu/ft817.c b/yaesu/ft817.c index e1fd8ecb8..e3cf62cc4 100644 --- a/yaesu/ft817.c +++ b/yaesu/ft817.c @@ -177,7 +177,7 @@ const struct rig_caps ft817_caps = { .write_delay = FT817_WRITE_DELAY, .post_write_delay = FT817_POST_WRITE_DELAY, .timeout = FT817_TIMEOUT, - .retry = 0, + .retry = 3, .has_get_func = RIG_FUNC_NONE, .has_set_func = RIG_FUNC_LOCK | RIG_FUNC_TONE | RIG_FUNC_TSQL, .has_get_level = RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER, @@ -402,6 +402,7 @@ static int ft817_get_status(RIG *rig, int status) unsigned char *data; int len; int n; + int retries = rig->state.rigport.retry; switch (status) { case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS: @@ -424,13 +425,16 @@ static int ft817_get_status(RIG *rig, int status) return -RIG_EINTERNAL; } - serial_flush(&rig->state.rigport); + do + { + serial_flush(&rig->state.rigport); + write_block(&rig->state.rigport, (char *) p->pcs[status].nseq, YAESU_CMD_LENGTH); + n = read_block(&rig->state.rigport, (char *) data, len); + } + while (retries-- && n < 0); - write_block(&rig->state.rigport, (char *) p->pcs[status].nseq, YAESU_CMD_LENGTH); - - if ((n = read_block(&rig->state.rigport, (char *) data, len)) < 0) + if (n < 0) return n; - if (n != len) return -RIG_EIO; @@ -1153,4 +1157,3 @@ int ft817_mW2power (RIG *rig, float *power, unsigned int mwpower, /* ---------------------------------------------------------------------- */ - diff --git a/yaesu/ft817.h b/yaesu/ft817.h index e102b878b..78aad0ba9 100644 --- a/yaesu/ft817.h +++ b/yaesu/ft817.h @@ -50,7 +50,7 @@ /* * Read timeout. */ -#define FT817_TIMEOUT 200 +#define FT817_TIMEOUT 1000 /* * The time the TX, RX and FREQ/MODE status are cached (in millisec). @@ -161,10 +161,3 @@ static int ft817_mW2power (RIG *rig, float *power, unsigned int mwpower, freq_t freq, rmode_t mode); #endif /* _FT817_H */ - - - - - - -