Fix SH command for FTDX101D and fix parsing of SH for different response lengths in newcat.c

https://github.com/Hamlib/Hamlib/issues/402
pull/412/head
Michael Black W9MDB 2020-10-07 15:19:44 +01:00
rodzic 8760d2576b
commit c479244fc1
1 zmienionych plików z 23 dodań i 2 usunięć

Wyświetl plik

@ -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);