kopia lustrzana https://github.com/Hamlib/Hamlib
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
rodzic
d92bea9538
commit
bfbb1adc44
|
@ -185,10 +185,13 @@ int elecraft_open(RIG *rig)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Currently we cannot cope with AI mode so turn it off in case last
|
if (RIG_MODEL_XG3 != rig->caps->rig_model)
|
||||||
client left it on */
|
{
|
||||||
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's not
|
/* currently we cannot cope with AI mode so turn it off in case
|
||||||
supported */
|
last client left it on */
|
||||||
|
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's
|
||||||
|
not supported */
|
||||||
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
14
kenwood/k2.c
14
kenwood/k2.c
|
@ -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. */
|
/* 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. */
|
/* 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");
|
err = kenwood_simple_cmd(rig, "MD6");
|
||||||
if (err != RIG_OK && err != -RIG_ERJCTED)
|
if (err != RIG_OK && err != -RIG_ERJCTED)
|
||||||
return err;
|
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)
|
if (!strcmp("MD6", buf))
|
||||||
priv->k2_md_rtty = 0; /* set flag for RTTY mode installed */
|
priv->k2_md_rtty = 1; /* set flag for RTTY mode enabled */
|
||||||
else
|
}
|
||||||
priv->k2_md_rtty = 1; /* RTTY module not installed */
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTTY flag is: %d\n", __func__, priv->k2_md_rtty);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTTY flag is: %d\n", __func__, priv->k2_md_rtty);
|
||||||
|
|
||||||
i = (priv->k2_md_rtty == 1) ? 2 : 1;
|
i = (priv->k2_md_rtty == 1) ? 2 : 1;
|
||||||
|
|
|
@ -206,9 +206,12 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
|
||||||
int retry_read = 0;
|
int retry_read = 0;
|
||||||
int reply_expected = data && *datasize > 0;
|
int reply_expected = data && *datasize > 0;
|
||||||
size_t length = *datasize;
|
size_t length = *datasize;
|
||||||
static char const verify[] = "ID;"; /* command we can always send
|
static char const std_verify[] = "ID;"; /* command we can always
|
||||||
to any rig even when the rig
|
send to any rig even when
|
||||||
is busy */
|
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 = &rig->state;
|
||||||
rs->hold_decode = 1;
|
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
|
* single character commands we only check the first character in
|
||||||
* that case.
|
* that case.
|
||||||
*/
|
*/
|
||||||
if (!(reply_expected && priv->info[0] == cmdstr[0] && (cmdstr[1] == '\0' || priv->info[1] == cmdstr[1]))
|
if (reply_expected)
|
||||||
|| (!reply_expected && verify[0] == priv->info[0] && (verify[1] == '\0' || verify[1] == priv->info[1]))) {
|
{
|
||||||
/*
|
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.
|
* TODO: When RIG_TRN is enabled, we can pass the string to
|
||||||
*/
|
* the decoder for callback. That way we don't ignore any
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %c%c for command %c%c\n",
|
* commands.
|
||||||
__func__, priv->info[0], priv->info[1], cmdstr[0], cmdstr[1]);
|
*/
|
||||||
|
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)
|
if (retry_read++ < rig->caps->retry)
|
||||||
goto transaction_write;
|
goto transaction_write;
|
||||||
|
@ -331,16 +336,35 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
|
||||||
goto transaction_quit;
|
goto transaction_quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* always give back a null terminated string without
|
/* always give back a null terminated string without the command
|
||||||
* the command terminator.
|
* terminator.
|
||||||
*/
|
*/
|
||||||
int len = (*datasize < retval ? *datasize : retval) - 1;
|
int len = (*datasize < retval ? *datasize : retval) - 1;
|
||||||
strncpy (data, priv->info, len);
|
strncpy (data, priv->info, len);
|
||||||
data[len] = '\0';
|
data[len] = '\0';
|
||||||
*datasize = retval; /* this is retval from successful
|
*datasize = retval; /* this is retval from successful
|
||||||
read_string above, don't assign
|
read_string above, don't assign until
|
||||||
until here because IN value is
|
here because IN value is needed for
|
||||||
needed for retries */
|
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;
|
retval = RIG_OK;
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct kenwood_priv_data {
|
||||||
int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */
|
int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */
|
||||||
char *fw_rev; /* firmware revision level */
|
char *fw_rev; /* firmware revision level */
|
||||||
unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */
|
unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */
|
||||||
|
void * data; /* model specific data */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue