Use rig->state.current_vfo to store vfo value.

NewCAT was saving the VFO value in the private rig data structure which
is inaccessable to the front end library.  Tested currVFO in rigctl with
W0MDN's FT-450.
Hamlib-1.2.14
Nate Bargmann 2011-07-08 22:27:06 -05:00
rodzic f500a67b49
commit 20c4203268
1 zmienionych plików z 110 dodań i 100 usunięć

Wyświetl plik

@ -212,7 +212,7 @@ int valid_commands_count = sizeof(valid_commands) / sizeof(y
struct newcat_priv_data {
unsigned int read_update_delay; /* depends on pacing value */
vfo_t current_vfo; /* active VFO from last cmd */
// vfo_t current_vfo; /* active VFO from last cmd */
char cmd_str[NEWCAT_DATA_LEN]; /* command string buffer */
char ret_data[NEWCAT_DATA_LEN]; /* returned data--max value, most are less */
int current_mem; /* private memory channel number */
@ -275,7 +275,7 @@ int newcat_init(RIG *rig) {
priv->read_update_delay = NEWCAT_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */
// priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */
priv->current_vfo = RIG_VFO_A;
// priv->current_vfo = RIG_VFO_A;
rig->state.priv = (void *)priv;
@ -375,8 +375,12 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
priv = (struct newcat_priv_data *)rig->state.priv;
caps = rig->caps;
state = &rig->state;
// vfo_t tvfo;
// tvfo = (vfo == RIG_VFO_CURR || vfo == RIG_VFO_VFO) ? state->current_vfo : vfo;
rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo);
// rig_debug(RIG_DEBUG_TRACE, "%s: translated vfo = 0x%02x\n", __func__, tvfo);
rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq);
/* additional debugging */
@ -391,6 +395,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
if (err < 0)
return err;
/* vfo should now be modified to a valid VFO constant. */
switch (vfo) {
case RIG_VFO_A:
c = 'A';
@ -773,7 +778,7 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) {
err = newcat_get_vfo_mode(rig, &vfo_mode);
if (vfo_mode == RIG_VFO_MEM) {
priv->current_mem = NC_MEM_CHANNEL_NONE;
priv->current_vfo = RIG_VFO_A;
state->current_vfo = RIG_VFO_A;
err = newcat_vfomem_toggle(rig);
return err;
}
@ -781,7 +786,7 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) {
case RIG_VFO_MEM:
if (priv->current_mem == NC_MEM_CHANNEL_NONE) {
/* Only works correctly for VFO A */
if (priv->current_vfo == RIG_VFO_B)
if (state->current_vfo == RIG_VFO_B)
return -RIG_ENTARGET;
/* get current memory channel */
@ -798,7 +803,7 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) {
priv->current_mem = mem;
}
/* Set current_vfo now */
priv->current_vfo = vfo;
state->current_vfo = vfo;
return RIG_OK;
default:
return -RIG_ENIMPL; /* sorry, VFO not implemented */
@ -813,9 +818,9 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) {
if (err != RIG_OK)
return err;
priv->current_vfo = vfo; /* if set_vfo worked, set current_vfo */
state->current_vfo = vfo; /* if set_vfo worked, set current_vfo */
rig_debug(RIG_DEBUG_TRACE, "%s: priv->current_vfo = 0x%02x\n", __func__, vfo);
rig_debug(RIG_DEBUG_TRACE, "%s: rig->state.current_vfo = 0x%02x\n", __func__, vfo);
return RIG_OK;
}
@ -841,6 +846,9 @@ int newcat_get_vfo(RIG *rig, vfo_t *vfo) {
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
if (!rig || !vfo)
return -RIG_EINVAL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!newcat_valid_command(rig, command))
@ -876,7 +884,7 @@ int newcat_get_vfo(RIG *rig, vfo_t *vfo) {
if (strcmp(priv->ret_data, cat_unknown_cmd) == 0) {
rig_debug(RIG_DEBUG_TRACE, "%s: Unrecognized command, get VFO\n", __func__);
*vfo = RIG_VFO_A;
priv->current_vfo = RIG_VFO_A;
state->current_vfo = RIG_VFO_A;
return -RIG_EPROTO;
}
@ -903,9 +911,9 @@ int newcat_get_vfo(RIG *rig, vfo_t *vfo) {
if (vfo_mode == RIG_VFO_MEM)
*vfo = RIG_VFO_MEM;
priv->current_vfo = *vfo; /* set now */
state->current_vfo = *vfo; /* set now */
rig_debug(RIG_DEBUG_TRACE, "%s: set vfo = 0x%02x\n", __func__, *vfo);
rig_debug(RIG_DEBUG_TRACE, "%s: rig->state.current_vfo = 0x%02x\n", __func__, state->current_vfo);
return RIG_OK;
@ -914,13 +922,13 @@ int newcat_get_vfo(RIG *rig, vfo_t *vfo) {
int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
struct newcat_priv_data *priv;
// struct newcat_priv_data *priv;
struct rig_state *state;
int err;
char txon[] = "TX1;";
char txoff[] = "TX0;";
priv = (struct newcat_priv_data *)rig->state.priv;
// priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
if (!newcat_valid_command(rig, "TX"))
@ -3305,7 +3313,7 @@ int newcat_set_channel(RIG * rig, const channel_t * chan)
return -RIG_ENAVAIL;
/* Set Restore to VFO or leave in memory mode */
switch (priv->current_vfo) {
switch (state->current_vfo) {
case RIG_VFO_A:
/* Jump back from memory channel */
restore_vfo = TRUE;
@ -3834,9 +3842,9 @@ int newcat_get_tx_vfo(RIG * rig, vfo_t * tx_vfo) {
int newcat_set_vfo_from_alias(RIG * rig, vfo_t * vfo) {
struct newcat_priv_data *priv;
// struct newcat_priv_data *priv;
priv = (struct newcat_priv_data *)rig->state.priv;
// priv = (struct newcat_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: alias vfo = 0x%02x\n", __func__, *vfo);
@ -3848,11 +3856,11 @@ int newcat_set_vfo_from_alias(RIG * rig, vfo_t * vfo) {
break;
case RIG_VFO_CURR: /* RIG_VFO_RX == RIG_VFO_CURR */
case RIG_VFO_VFO:
*vfo = priv->current_vfo;
*vfo = rig->state.current_vfo;
break;
case RIG_VFO_TX:
/* set to another vfo for split or uplink */
*vfo = (priv->current_vfo == RIG_VFO_B) ? RIG_VFO_A : RIG_VFO_B;
*vfo = (rig->state.current_vfo == RIG_VFO_B) ? RIG_VFO_A : RIG_VFO_B;
break;
case RIG_VFO_MAIN:
*vfo = RIG_VFO_A;
@ -4401,12 +4409,12 @@ int newcat_get_rigid(RIG * rig)
*/
int newcat_get_vfo_mode(RIG * rig, vfo_t * vfo_mode)
{
struct rig_state *state;
// struct rig_state *state;
char * retval;
int err;
newcat_cmd_data_t cmd;
state = &rig->state;
// state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -4457,6 +4465,8 @@ int newcat_set_cmd(RIG * rig, newcat_cmd_data_t * cmd)
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, cmd->cmd_str);
err = write_block(&state->rigport, cmd->cmd_str, strlen(cmd->cmd_str));
if (err != RIG_OK)
return err;
return RIG_OK;
}