Fix get/set_xit for Yaesu rigs to avoid vfo swapping

Fix get_xit to return VFOA/B appropriately
THe IF/OI commands apparently always return VFOA/B respectively so vfo swapping is not needed to read info
https://github.com/Hamlib/Hamlib/issues/430
pull/435/head
Michael Black W9MDB 2020-11-03 09:28:00 -06:00
rodzic 20fc303686
commit 11058e63ff
2 zmienionych plików z 49 dodań i 27 usunięć

Wyświetl plik

@ -1170,6 +1170,29 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo)
return RIG_OK;
}
// Either returns a valid RIG_VFO* or if < 0 an error code
static vfo_t newcat_set_vfo_if_needed(RIG *rig, vfo_t vfo)
{
vfo_t oldvfo = rig->state.current_vfo;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, oldvfo=%s\n", __func__, rig_strvfo(vfo),
rig_strvfo(oldvfo));
if (oldvfo != vfo)
{
int ret;
ret = newcat_set_vfo(rig, vfo);
if (ret != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: error setting vfo=%s\n", __func__,
rig_strvfo(vfo));
return ret;
}
}
return oldvfo;
}
/*
* rig_get_vfo
@ -1731,11 +1754,9 @@ int newcat_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
return RIG_OK;
}
int newcat_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int vfo_swap = 0;
vfo_t oldvfo;
int ret;
@ -1744,19 +1765,9 @@ int newcat_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
return -RIG_ENAVAIL;
}
if (rig->state.current_vfo != vfo)
{
oldvfo = rig->state.current_vfo;
ret = newcat_set_vfo(rig, vfo);
oldvfo = newcat_set_vfo_if_needed(rig, vfo);
if (ret != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: error setting vfo=%s\n", __func__,
rig_strvfo(vfo));
}
vfo_swap = 1;
}
if (oldvfo < 0) { return oldvfo; }
if (rit > rig->caps->max_rit)
{
@ -1785,16 +1796,9 @@ int newcat_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
ret = newcat_set_cmd(rig);
if (vfo_swap)
{
newcat_set_vfo(rig, oldvfo);
oldvfo = newcat_set_vfo_if_needed(rig, oldvfo);
if (ret != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: error setting vfo=%s\n", __func__,
rig_strvfo(vfo));
}
}
if (oldvfo < 0) { return oldvfo; }
return ret;
}
@ -1865,12 +1869,18 @@ int newcat_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
int newcat_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
vfo_t oldvfo;
int ret;
if (!newcat_valid_command(rig, "XT"))
{
return -RIG_ENAVAIL;
}
oldvfo = newcat_set_vfo_if_needed(rig, vfo);
if (oldvfo < 0) { return oldvfo; }
if (xit > rig->caps->max_xit)
{
xit = rig->caps->max_xit; /* + */
@ -1897,7 +1907,13 @@ int newcat_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
labs(xit), cat_term);
}
return newcat_set_cmd(rig);
ret = newcat_set_cmd(rig);
oldvfo = newcat_set_vfo_if_needed(rig, vfo);
if (oldvfo < 0) { return oldvfo; }
return ret;
}
@ -1907,8 +1923,14 @@ int newcat_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
char *retval;
int err;
int offset = 0;
char *cmd = "IF";
if (!newcat_valid_command(rig, "IF"))
if (vfo == RIG_VFO_B || vfo == RIG_VFO_SUB)
{
cmd = "OI";
}
if (!newcat_valid_command(rig, cmd))
{
return -RIG_ENAVAIL;
}
@ -1917,7 +1939,7 @@ int newcat_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", "IF", cat_term);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", cmd, cat_term);
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str);

Wyświetl plik

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