diff --git a/kenwood/elecraft.c b/kenwood/elecraft.c index 86ac0b809..30a1045f7 100644 --- a/kenwood/elecraft.c +++ b/kenwood/elecraft.c @@ -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; } diff --git a/kenwood/k2.c b/kenwood/k2.c index 60037fa7c..5a9aed2e2 100644 --- a/kenwood/k2.c +++ b/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. */ /* 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; diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index 93d363d76..065b90718 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -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; diff --git a/kenwood/kenwood.h b/kenwood/kenwood.h index b6efe508c..d9c7fcbb8 100644 --- a/kenwood/kenwood.h +++ b/kenwood/kenwood.h @@ -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 */ };