From 4832cc1bb27a729fe34055ec679fe7392607e7d6 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 21 May 2023 08:15:47 -0500 Subject: [PATCH] Improve kenwood.c debug a little bit to reduce confusion https://github.com/Hamlib/Hamlib/issues/1298 --- rigs/kenwood/kenwood.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 0721e213e..496494557 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -246,9 +246,16 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, struct kenwood_priv_caps *caps = kenwood_caps(rig); struct rig_state *rs; - rig_debug(RIG_DEBUG_VERBOSE, "%s called cmd=%s datasize=%d\n", __func__, + if (datasize > 0 && datasize < strlen(cmdstr)) { + rig_debug(RIG_DEBUG_WARN, "%s called cmd=%s datasize=%d, datasize < cmd length?\n", __func__, cmdstr ? cmdstr : "(NULL)", (int)datasize); + } + else + { + rig_debug(RIG_DEBUG_VERBOSE, "%s called cmd=%s\n", __func__, + cmdstr ? cmdstr : "(NULL)"); + } if ((!cmdstr && !datasize) || (datasize && !data)) { @@ -385,13 +392,15 @@ transaction_write: transaction_read: /* allow room for most any response */ + // this len/expected stuff is confusing -- logic in some places includes the semicolon + // so we add 1 to our read_string length to cover these cases + // eventually we should be able to get rid of this but requires testing all Kenwood rigs len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 48, KENWOOD_MAX_BUF_LEN); retval = read_string(&rs->rigport, (unsigned char *) buffer, len, cmdtrm_str, strlen(cmdtrm_str), 0, 1); - rig_debug(RIG_DEBUG_TRACE, "%s: read_string(expected=%d, len=%d)='%s'\n", - __func__, - len, (int)strlen(buffer), buffer); + rig_debug(RIG_DEBUG_TRACE, "%s: read_string len=%d '%s'\n", __func__, + (int)strlen(buffer), buffer); if (retval < 0) { @@ -1253,7 +1262,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) rig_debug(RIG_DEBUG_VERBOSE, "%s: checking satellite mode status\n", __func__); SNPRINTF(cmdbuf, sizeof(cmdbuf), "SA"); - retval = kenwood_transaction(rig, cmdbuf, retbuf, 20); + retval = kenwood_transaction(rig, cmdbuf, retbuf, 4); if (retval != RIG_OK) {