[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 6779d04581b8c6dba61e6
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-01-14 22:39:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 6779d04581b8c6dba61e6097c936c8c1ea471fd3 (commit) via 30c2d34d87076d2d3ad85da45df95ef4d7397155 (commit) from 32d5f2b49e69ad00e91acd6f0f3030f9923f3878 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6779d04581b8c6dba61e6097c936c8c1ea471fd3 Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 14 16:38:31 2021 -0600 Add rig_flush to newcat_set_cmd_validate diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 78e3cde3..e8765a44 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -9424,6 +9424,7 @@ int newcat_set_cmd_validate(RIG *rig) } while (rc != RIG_OK && retry++ < retries) { + rig_flush(&state->rigport); /* discard any unsolicited data */ rc = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str)); if (rc != RIG_OK) return -RIG_EIO; rc = write_block(&state->rigport, valcmd, strlen(valcmd)); commit 30c2d34d87076d2d3ad85da45df95ef4d7397155 Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 14 16:32:55 2021 -0600 Implemented new Yaesu retry mechanism using command validation technique Cmds that are implemented are verified and 5 tries are made if answer != request https://github.com/Hamlib/Hamlib/issues/505 diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index b7fe8f39..78e3cde3 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -9374,6 +9374,73 @@ int newcat_get_cmd(RIG *rig) return rc; } +/* + * This tries to set and read to validate the set command actually worked + * returns RIG_OK if set, -RIG_EIMPL if not implemented yet, or -RIG_EPROTO if unsuccesful + */ +int newcat_set_cmd_validate(RIG *rig) +{ + struct rig_state *state = &rig->state; + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + char *valcmd; + int retries=5; + int retry=0; + int sleepms = 50; + int rc = -RIG_EPROTO; + + rig_debug(RIG_DEBUG_TRACE, "%s: priv->cmd_str=%s\n", __func__, priv->cmd_str); + if ((strncmp(priv->cmd_str,"FA",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "FA;"; + } + else if ((strncmp(priv->cmd_str,"FB",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "FB;"; + } + else if ((strncmp(priv->cmd_str,"MD",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "MD;"; + } + else if ((strncmp(priv->cmd_str,"TX",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "TX;"; + } + else if ((strncmp(priv->cmd_str,"FT",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "FT;"; + } + else if ((strncmp(priv->cmd_str,"BS",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "BS;"; + } + else if ((strncmp(priv->cmd_str,"AI",2)==0) && (strlen(priv->cmd_str)>3)) + { + valcmd = "AI;"; + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: %s not implemented\n", __func__, priv->cmd_str); + return -RIG_ENIMPL; + } + while (rc != RIG_OK && retry++ < retries) + { + rc = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str)); + if (rc != RIG_OK) return -RIG_EIO; + rc = write_block(&state->rigport, valcmd, strlen(valcmd)); + if (rc != RIG_OK) return -RIG_EIO; + rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), + &cat_term, sizeof(cat_term)); + if (rc == RIG_OK) + { + // if they match we are validated + if (strcmp(priv->cmd_str, priv->ret_data)==0) return RIG_OK; + else rc = -RIG_EPROTO; + } + rig_debug(RIG_DEBUG_ERR, "%s: cmd validation failed, try#%d\n", __func__, retry); + hl_usleep(sleepms*1000); + } while(--retry > 0); + return -RIG_EPROTO; +} /* * Writes a null terminated command string from priv->cmd_str to the * CAT port that is not expected to have a response. @@ -9401,6 +9468,12 @@ int newcat_set_cmd(RIG *rig) /* send the command */ rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str); + if (newcat_set_cmd_validate(rig)==RIG_OK) { + rig_debug(RIG_DEBUG_TRACE, "%s: cmd_validate OK\n", __func__); + return RIG_OK; + } + rig_debug(RIG_DEBUG_TRACE, "%s: cmd_validate not OK...continuing\n", __func__); + if (RIG_OK != (rc = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str)))) { diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 452cb283..3ad84a0d 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20210113" +#define NEWCAT_VER "20210114" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 ----------------------------------------------------------------------- Summary of changes: rigs/yaesu/newcat.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ rigs/yaesu/newcat.h | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |