Merge branch 'yaesu-busy' of git://git.code.sf.net/u/bsomervi/hamlib

Hamlib-3.0
Nate Bargmann 2014-12-10 18:11:37 -06:00
commit 8bf6934f5d
1 zmienionych plików z 39 dodań i 23 usunięć

Wyświetl plik

@ -3941,9 +3941,15 @@ int newcat_vfomem_toggle(RIG * rig)
} }
/* /*
* Writes a null terminated command string in priv->cmd_str to the CAT * Writes a null terminated command string from priv->cmd_str to the
* port and returns a response from the rig in priv->ret_data which is * CAT port and returns a response from the rig in priv->ret_data
* also null terminated. * which is also null terminated.
*
* Honors the 'retry' capabilities field by resending the command up
* to 'retry' times until a valid response is received. In the special
* cases of receiving a valid response to a different command or the
* "?;" busy please wait response; the command is not resent but up to
* 'retry' retries to receive a valid response are made.
*/ */
int newcat_get_cmd (RIG *rig) int newcat_get_cmd (RIG *rig)
{ {
@ -3951,9 +3957,10 @@ int newcat_get_cmd (RIG *rig)
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int retry_count = 0; int retry_count = 0;
int rc = -RIG_EPROTO; int rc = -RIG_EPROTO;
int bytes_read;
while (rc != RIG_OK && retry_count++ <= state->rigport.retry) while (rc != RIG_OK && retry_count++ <= state->rigport.retry)
{
if (rc != -RIG_BUSBUSY)
{ {
/* send the command */ /* send the command */
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str); rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
@ -3961,21 +3968,29 @@ int newcat_get_cmd (RIG *rig)
{ {
return rc; return rc;
} }
}
/* read the reply */ /* read the reply */
if ((bytes_read = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data),
&cat_term, sizeof(cat_term))) <= 0) &cat_term, sizeof(cat_term))) <= 0)
{ {
continue; /* retry */ continue; /* usually a timeout - retry */
} }
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n", rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n",
__func__, bytes_read, priv->ret_data); __func__, rc, priv->ret_data);
rc = RIG_OK; /* received something */
/* Check that command termination is correct */ /* Check that command termination is correct - alternative is
response is longer that the buffer */
if (!strchr(&cat_term, priv->ret_data[strlen(priv->ret_data) - 1])) if (!strchr(&cat_term, priv->ret_data[strlen(priv->ret_data) - 1]))
{ {
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
__func__, priv->ret_data); __func__, priv->ret_data);
rc = -RIG_BUSBUSY; /* don't write command again */
/* we could decrement retry_count
here but there is a danger of
infinite looping so we just use up
a retry for safety's sake */
continue; /* retry */ continue; /* retry */
} }
@ -3990,7 +4005,7 @@ int newcat_get_cmd (RIG *rig)
switch (priv->ret_data[0]) switch (priv->ret_data[0])
{ {
case 'N': case 'N':
/* Command recognised by rig but invalid data entered. */ /* Command recognized by rig but invalid data entered. */
rig_debug(RIG_DEBUG_VERBOSE, "%s: NegAck for '%s'\n", __func__, priv->cmd_str); rig_debug(RIG_DEBUG_VERBOSE, "%s: NegAck for '%s'\n", __func__, priv->cmd_str);
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
@ -4007,11 +4022,12 @@ int newcat_get_cmd (RIG *rig)
break; /* retry */ break; /* retry */
case '?': case '?':
/* Command not understood by rig */ /* Rig busy wait please */
rig_debug(RIG_DEBUG_ERR, "%s: Unknown command '%s' or rig busy\n", __func__, priv->cmd_str); rig_debug(RIG_DEBUG_ERR, "%s: Rig busy\n", __func__, priv->cmd_str);
rc = -RIG_ERJCTED; rc = -RIG_BUSBUSY;
break; /* retry */ break; /* retry read only */
} }
continue;
} }
/* verify that reply was to the command we sent */ /* verify that reply was to the command we sent */
@ -4024,7 +4040,7 @@ int newcat_get_cmd (RIG *rig)
*/ */
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %.2s for command %.2s\n", rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %.2s for command %.2s\n",
__func__, priv->ret_data, priv->cmd_str); __func__, priv->ret_data, priv->cmd_str);
rc = -RIG_BUSBUSY; /* retry */ rc = -RIG_BUSBUSY; /* retry read only */
} }
} }