Fix newcat_get_rx_bandwith SH return values

https://github.com/Hamlib/Hamlib/issues/467
pull/474/head
Michael Black W9MDB 2020-12-15 15:25:28 -06:00
rodzic 1cd872e8cd
commit f05307dae8
2 zmienionych plików z 32 dodań i 7 usunięć

Wyświetl plik

@ -1034,6 +1034,7 @@ int newcat_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
if (*mode == '0')
{
rig_debug(RIG_DEBUG_ERR, "%s: *mode = '0'??\n", __func__);
return -RIG_EPROTO;
}
@ -7641,14 +7642,31 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
return err;
}
if (sscanf(priv->ret_data, "SH0%3d;", &w) != 1)
w = 0; // use default in case of error
if (strlen(priv->ret_data) == 7)
{
if (sscanf(priv->ret_data, "SH%3d;", &w) != 1)
int on;
int n = sscanf(priv->ret_data, "SH0%1d%3d", &on, &w);
if (n == 2) {
if (!on) { w = 0; }
}
else
{
err = -RIG_EPROTO;
}
}
}
rig_debug(RIG_DEBUG_TRACE, "%s: w=%d\n", __func__, w);
else if (strlen(priv->ret_data) == 6)
{
int n = sscanf(priv->ret_data, "SH%3d", &w);
if (n != 1) err = -RIG_EPROTO;
}
else
{
err = -RIG_EPROTO;
}
rig_debug(RIG_DEBUG_TRACE, "%s: w=%d\n", __func__, w);
if (err != RIG_OK)
{
@ -7779,6 +7797,7 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown mode=%s\n", __func__, rig_strrmode(mode));
return -RIG_EINVAL;
} /* end switch(mode) */
@ -7787,6 +7806,7 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
{
if ((narrow = get_narrow(rig, vfo)) < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: error narrow < 0, narrow=%d\n", __func__, narrow);
return -RIG_EPROTO;
}
@ -7846,7 +7866,9 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
case 17: *width = 3000; break;
default: return -RIG_EINVAL;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown w=%d\n", __func__, w);
return -RIG_EINVAL;
}
break;
@ -7899,7 +7921,9 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
case 21: *width = 3200; break;
default: return -RIG_EINVAL;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown mode=%s\n", __func__, rig_strrmode(mode));
return -RIG_EINVAL;
}
break;
@ -7919,6 +7943,7 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown mode=%s\n", __func__, rig_strrmode(mode));
return -RIG_EINVAL;
} /* end switch(mode) */

Wyświetl plik

@ -50,7 +50,7 @@
typedef char ncboolean;
/* shared function version */
#define NEWCAT_VER "20201213"
#define NEWCAT_VER "20201215"
/* Hopefully large enough for future use, 128 chars plus '\0' */
#define NEWCAT_DATA_LEN 129