Fit FT890S kenwood_get_power_minmax for AM mode

https://github.com/Hamlib/Hamlib/issues/399
pull/425/head
Michael Black W9MDB 2020-10-21 17:17:55 -05:00
rodzic 042b55a5f5
commit 88bda82a7d
1 zmienionych plików z 41 dodań i 15 usunięć

Wyświetl plik

@ -2255,15 +2255,27 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min,
// we set back to 0 for safety and if restore is true we restore power_min
// otherwise we expect calling routine to be setting new power level
// we batch these commands together for speed
char *cmd = "PC;PC000;PC;PC255;PC;PC000;";
char *cmd;
int n;
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (RIG_IS_TS890S || RIG_IS_TS990S || RIG_IS_TS950S)
switch (rig->caps->rig_model)
{
cmd = "PC;PC005;PC;PC255;PC;PC005;";
// TS890S can't take power levels outside 5-100 and 5-50
// So all we'll do is read power_now
case RIG_MODEL_TS890S:
rig->state.power_min = *power_min = 5;
rig->state.power_max = *power_max = 100;
if (rig->state.current_mode == RIG_MODE_AM) { *power_max = 50; }
cmd = "PC;";
break;
default:
cmd = "PC;PC000;PC;PC255;PC;PC000;";
}
// Don't do this if PTT is on...don't want to max out power!!
@ -2288,25 +2300,39 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min,
if (retval != 18)
{
rig_debug(RIG_DEBUG_ERR, "%s: expected 19, got %d in '%s'\n", __func__, retval,
rig_debug(RIG_DEBUG_ERR, "%s: expected 18, got %d in '%s'\n", __func__, retval,
levelbuf);
return -RIG_EPROTO;
}
n = sscanf(levelbuf, "PC%d;PC%d;PC%d", power_now, power_min, power_max);
if (n != 3)
if (RIG_IS_TS890S)
{
rig_debug(RIG_DEBUG_ERR, "%s: count not parse 3 values from '%s'\n", __func__,
levelbuf);
return -RIG_EPROTO;
n = sscanf(levelbuf, "PC%d;", power_now);
if (n != 1)
{
rig_debug(RIG_DEBUG_ERR, "%s: count not parse 1 value from '%s'\n", __func__,
levelbuf);
return -RIG_EPROTO;
}
}
if (restore)
else
{
snprintf(levelbuf, sizeof(levelbuf), "PC%03d;", *power_now);
retval = kenwood_transaction(rig, levelbuf, NULL, 0);
return retval;
n = sscanf(levelbuf, "PC%d;PC%d;PC%d", power_now, power_min, power_max);
if (n != 3)
{
rig_debug(RIG_DEBUG_ERR, "%s: count not parse 3 values from '%s'\n", __func__,
levelbuf);
return -RIG_EPROTO;
}
if (restore) // only need to restore if 3-value cmd is done
{
snprintf(levelbuf, sizeof(levelbuf), "PC%03d;", *power_now);
retval = kenwood_transaction(rig, levelbuf, NULL, 0);
return retval;
}
}
rig_debug(RIG_DEBUG_TRACE, "%s: returning now=%d, min=%d, max=%d\n", __func__,