Improve command verification for Kenwood & Elecraft

Allows for a single ';' for  verification with the Elecraft XG3 single
character commands.

Allow for rig specific instance data  (needed by the Elecraft XG3 that
is a bit different from the rest of the Kenwood/Elecraft group).

Do not send a startup command to  turn off AI mode to the Elecraft XG3
as it doesn't have that command or mode.

Restore the positive RTTY mode enabled  check to the Elecraft K2 as it
appears that the MD6; and MD9;  comamnds are valid even when RTTY mode
is disabled on the rig.
Hamlib-3.0
Bill Somerville 2015-01-19 10:52:18 +00:00
rodzic d92bea9538
commit bfbb1adc44
4 zmienionych plików z 59 dodań i 25 usunięć

Wyświetl plik

@ -185,10 +185,13 @@ int elecraft_open(RIG *rig)
return -RIG_EINVAL;
}
/* Currently we cannot cope with AI mode so turn it off in case last
client left it on */
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's not
supported */
if (RIG_MODEL_XG3 != rig->caps->rig_model)
{
/* currently we cannot cope with AI mode so turn it off in case
last client left it on */
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's
not supported */
}
return RIG_OK;
}

Wyświetl plik

@ -502,14 +502,20 @@ int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
/* Now begin the process of querying the available modes and filters. */
/* First try to put the K2 into RTTY mode and check if it's available. */
priv->k2_md_rtty = 0; /* Assume RTTY module not installed */
err = kenwood_simple_cmd(rig, "MD6");
if (err != RIG_OK && err != -RIG_ERJCTED)
return err;
if (RIG_OK == err)
{
/* Read back mode and test to see if K2 reports RTTY. */
err = kenwood_safe_transaction(rig, "MD", buf, KENWOOD_MAX_BUF_LEN, 4);
if (err != RIG_OK)
return err;
if (-RIG_ERJCTED == err)
priv->k2_md_rtty = 0; /* set flag for RTTY mode installed */
else
priv->k2_md_rtty = 1; /* RTTY module not installed */
if (!strcmp("MD6", buf))
priv->k2_md_rtty = 1; /* set flag for RTTY mode enabled */
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTTY flag is: %d\n", __func__, priv->k2_md_rtty);
i = (priv->k2_md_rtty == 1) ? 2 : 1;

Wyświetl plik

@ -206,9 +206,12 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
int retry_read = 0;
int reply_expected = data && *datasize > 0;
size_t length = *datasize;
static char const verify[] = "ID;"; /* command we can always send
to any rig even when the rig
is busy */
static char const std_verify[] = "ID;"; /* command we can always
send to any rig even when
the rig is busy */
static char const shrt_verify[] = ";"; /* alternate short verify
command XG3 etc. */
char const * verify = ',' == cmdstr[1] ? shrt_verify : std_verify;
rs = &rig->state;
rs->hold_decode = 1;
@ -314,15 +317,17 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
* single character commands we only check the first character in
* that case.
*/
if (!(reply_expected && priv->info[0] == cmdstr[0] && (cmdstr[1] == '\0' || priv->info[1] == cmdstr[1]))
|| (!reply_expected && verify[0] == priv->info[0] && (verify[1] == '\0' || verify[1] == priv->info[1]))) {
/*
* TODO: When RIG_TRN is enabled, we can pass the string
* to the decoder for callback. That way we don't ignore
* any commands.
*/
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %c%c for command %c%c\n",
__func__, priv->info[0], priv->info[1], cmdstr[0], cmdstr[1]);
if (reply_expected)
{
if (priv->info[0] != cmdstr[0] || (cmdstr[1] && priv->info[1] != cmdstr[1]))
{
/*
* TODO: When RIG_TRN is enabled, we can pass the string to
* the decoder for callback. That way we don't ignore any
* commands.
*/
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %c%c for command %c%c\n",
__func__, priv->info[0], priv->info[1], cmdstr[0], cmdstr[1]);
if (retry_read++ < rig->caps->retry)
goto transaction_write;
@ -331,16 +336,35 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
goto transaction_quit;
}
/* always give back a null terminated string without
* the command terminator.
/* always give back a null terminated string without the command
* terminator.
*/
int len = (*datasize < retval ? *datasize : retval) - 1;
strncpy (data, priv->info, len);
data[len] = '\0';
*datasize = retval; /* this is retval from successful
read_string above, don't assign
until here because IN value is
needed for retries */
read_string above, don't assign until
here because IN value is needed for
retries */
}
else
{
if (verify[0] != priv->info[0] || (verify[1] && verify[1] != priv->info[1]))
{
/*
* TODO: When RIG_TRN is enabled, we can pass the string to
* the decoder for callback. That way we don't ignore any
* commands.
*/
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %c%c for command verification %c%c\n",
__func__, priv->info[0], priv->info[1], verify[0], verify[1]);
if (retry_read++ < rig->caps->retry)
goto transaction_write;
retval = -RIG_EPROTO;
goto transaction_quit;
}
}
retval = RIG_OK;

Wyświetl plik

@ -76,6 +76,7 @@ struct kenwood_priv_data {
int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */
char *fw_rev; /* firmware revision level */
unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */
void * data; /* model specific data */
};