From c479244fc1258f2a38f60cefd448abf6e669b278 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Wed, 7 Oct 2020 15:19:44 +0100 Subject: [PATCH] Fix SH command for FTDX101D and fix parsing of SH for different response lengths in newcat.c https://github.com/Hamlib/Hamlib/issues/402 --- rigs/yaesu/newcat.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 48c9ac812..e232c97f3 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -5875,7 +5875,14 @@ int newcat_set_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) /* end else */ - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "SH%c%02d;", main_sub_vfo, w); + if (is_ft101) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "SH%c0%02d;", main_sub_vfo, w); + } + else + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "SH%c%02d;", main_sub_vfo, w); + } rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str); @@ -5972,7 +5979,21 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width) return err; } - if (sscanf(priv->ret_data, "SH%*1d%3d", &w) != 1) + if (strlen(priv->ret_data) == 7) + { + if (sscanf(priv->ret_data, "SH%*1d0%3d", &w) != 1) + err = -RIG_EPROTO; + } + else if (strlen(priv->ret_data) == 6) + { + if (sscanf(priv->ret_data, "SH%*1d%3d", &w) != 1) + err = -RIG_EPROTO; + } + else { + rig_debug(RIG_DEBUG_ERR, "%s: unknown SH response='%s'\n", __func__, priv->ret_data); + return -RIG_EPROTO; + } + if (err != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: unable to parse width from '%s'\n", __func__, priv->ret_data);