diff --git a/bindings/rig.swg b/bindings/rig.swg index 8e5d49c9d..134bc3248 100644 --- a/bindings/rig.swg +++ b/bindings/rig.swg @@ -344,7 +344,7 @@ typedef channel_t * const_channel_t_p; METHOD3(set_rit, shortfreq_t) METHOD3(set_xit, shortfreq_t) METHOD3(set_ts, shortfreq_t) - METHOD3(set_ant, ant_t) + METHOD2(set_ant, ant_t, value_t) METHOD2(set_func, setting_t, int) METHOD3(set_bank, int) METHOD3(set_mem, int) @@ -436,7 +436,7 @@ typedef channel_t * const_channel_t_p; METHOD1VGET(get_rit, shortfreq_t) METHOD1VGET(get_xit, shortfreq_t) METHOD1VGET(get_ts, shortfreq_t) - METHOD1VGET(get_ant, ant_t) + extern void get_ant(value_t * OUTPUT, ant_t * OUTPUT, vfo_t vfo = RIG_VFO_CURR); METHOD1VGET(get_mem, int) METHOD1GET(get_powerstat, powerstat_t) METHOD1GET(get_trn, int) @@ -557,6 +557,11 @@ void Rig_get_split_mode(Rig *self, rmode_t *mode, pbwidth_t *width, vfo_t vfo) self->error_status = rig_get_split_mode(self->rig, vfo, mode, width); } +void Rig_get_ant(Rig *self, value_t *option, ant_t *ant, vfo_t vfo) +{ + self->error_status = rig_get_ant(self->rig, vfo, ant, option); +} + struct channel *Rig_get_chan_all(Rig *self) { struct channel *chans; diff --git a/c++/rigclass.cc b/c++/rigclass.cc index 6ea2d999b..ebfebbb76 100644 --- a/c++/rigclass.cc +++ b/c++/rigclass.cc @@ -535,16 +535,14 @@ shortfreq_t Rig::getXit(vfo_t vfo) return xit; } -void Rig::setAnt(ant_t ant, vfo_t vfo) +void Rig::setAnt(value_t option, ant_t ant, vfo_t vfo) { - CHECK_RIG(rig_set_ant(theRig, vfo, ant)); + CHECK_RIG(rig_set_ant(theRig, vfo, ant, option)); } -ant_t Rig::getAnt(vfo_t vfo) +ant_t Rig::getAnt(value_t &option, ant_t &ant, vfo_t vfo) { - ant_t ant; - - CHECK_RIG( rig_get_ant(theRig, vfo, &ant) ); + CHECK_RIG( rig_get_ant(theRig, vfo, &ant, &option) ); return ant; } diff --git a/dummy/dummy.c b/dummy/dummy.c index a6eb34f15..cb3d479f1 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -54,6 +54,7 @@ struct dummy_priv_data powerstat_t powerstat; int bank; value_t parms[RIG_SETTING_MAX]; + int ant_option; channel_t *curr; /* points to vfo_a, vfo_b or mem[] */ @@ -1302,25 +1303,27 @@ static int dummy_get_ext_parm(RIG *rig, token_t token, value_t *val) -static int dummy_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +static int dummy_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; channel_t *curr = priv->curr; curr->ant = ant; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + priv->ant_option = option.i; + rig_debug(RIG_DEBUG_VERBOSE, "%s called ant=%d, option=%d\n", __func__, ant, option.i); return RIG_OK; } -static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; channel_t *curr = priv->curr; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); *ant = curr->ant; + option->i = priv->ant_option; return RIG_OK; } diff --git a/dummy/netrigctl.c b/dummy/netrigctl.c index 3c98344ef..79ae0e1aa 100644 --- a/dummy/netrigctl.c +++ b/dummy/netrigctl.c @@ -1730,7 +1730,7 @@ static int netrigctl_get_parm(RIG *rig, setting_t parm, value_t *val) } -static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { int ret, len; char cmd[CMD_MAX]; @@ -1743,7 +1743,7 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant) if (ret != RIG_OK) { return ret; } - len = sprintf(cmd, "Y%s %d\n", vfostr, ant); + len = sprintf(cmd, "Y%s %d %d\n", vfostr, ant, option.i); ret = netrigctl_transaction(rig, cmd, len, buf); @@ -1758,9 +1758,9 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant) } -static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { - int ret, len; + int ret, len, ioption; char cmd[CMD_MAX]; char buf[BUF_MAX]; char vfostr[6] = ""; @@ -1780,7 +1780,30 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) return (ret < 0) ? ret : -RIG_EPROTO; } - *ant = atoi(buf); + rig_debug(RIG_DEBUG_TRACE, "%s: buf='%s'\n", __func__, buf); + ret = sscanf(buf, "%d\n", ant); + + if (ret != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s: expected 1 ant integer in '%s', got %d\n", __func__, buf, + ret); + } + + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + + if (ret <= 0) + { + return (ret < 0) ? ret : -RIG_EPROTO; + } + + ret = sscanf(buf, "%d\n",&(option->i)); + + if (ret != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n", __func__, buf, + ret); + } + return RIG_OK; } diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index b6de8fe11..edd0f4c90 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1568,8 +1568,8 @@ struct rig_caps { int (*reset)(RIG *rig, reset_t reset); - int (*set_ant)(RIG *rig, vfo_t vfo, ant_t ant); - int (*get_ant)(RIG *rig, vfo_t vfo, ant_t *ant); + int (*set_ant)(RIG *rig, vfo_t vfo, ant_t ant, value_t option); + int (*get_ant)(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); int (*set_level)(RIG *rig, vfo_t vfo, setting_t level, value_t val); int (*get_level)(RIG *rig, vfo_t vfo, setting_t level, value_t *val); @@ -2151,11 +2151,13 @@ rig_cleanup HAMLIB_PARAMS((RIG *rig)); extern HAMLIB_EXPORT(int) rig_set_ant HAMLIB_PARAMS((RIG *rig, vfo_t vfo, - ant_t ant)); /* antenna */ + ant_t ant, /* antenna */ + value_t option)); /* optional ant info */ extern HAMLIB_EXPORT(int) rig_get_ant HAMLIB_PARAMS((RIG *rig, vfo_t vfo, - ant_t *ant)); + ant_t *ant, + value_t *option)); extern HAMLIB_EXPORT(setting_t) rig_has_get_level HAMLIB_PARAMS((RIG *rig, diff --git a/include/hamlib/rigclass.h b/include/hamlib/rigclass.h index da66a47e0..ecb3d6486 100644 --- a/include/hamlib/rigclass.h +++ b/include/hamlib/rigclass.h @@ -156,8 +156,8 @@ public: void setXit(shortfreq_t xit, vfo_t vfo = RIG_VFO_CURR); shortfreq_t getXit(vfo_t vfo = RIG_VFO_CURR); - void setAnt(ant_t ant, vfo_t vfo = RIG_VFO_CURR); - ant_t getAnt(vfo_t vfo = RIG_VFO_CURR); + void setAnt(value_t option, ant_t ant, vfo_t vfo = RIG_VFO_CURR); + ant_t getAnt(value_t &option, ant_t &ant, vfo_t vfo = RIG_VFO_CURR); void sendDtmf(const char *digits, vfo_t vfo = RIG_VFO_CURR); int recvDtmf(char *digits, vfo_t vfo = RIG_VFO_CURR); diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index ea1d1b75b..842037b33 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -487,7 +487,7 @@ int drake_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) * drake_set_ant * Assumes rig!=NULL */ -int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { unsigned char buf[16], ackbuf[16]; int len, ack_len, retval; @@ -504,7 +504,7 @@ int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant) * drake_get_ant * Assumes rig!=NULL */ -int drake_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int drake_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { int mdbuf_len, retval; char mdbuf[BUFSZ]; @@ -541,7 +541,6 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) *ant = RIG_ANT_NONE; return -RIG_EINVAL; } - return RIG_OK; } @@ -617,6 +616,7 @@ int drake_set_chan(RIG *rig, const channel_t *chan) int old_chan; char mdbuf[16], ackbuf[16]; int mdbuf_len, ack_len, retval; + value_t dummy; drake_get_vfo(rig, &old_vfo); old_chan = 0; @@ -634,7 +634,7 @@ int drake_set_chan(RIG *rig, const channel_t *chan) } /* set all memory features */ - drake_set_ant(rig, RIG_VFO_CURR, chan->ant); + drake_set_ant(rig, RIG_VFO_CURR, chan->ant, dummy); drake_set_freq(rig, RIG_VFO_CURR, chan->freq); drake_set_mode(rig, RIG_VFO_CURR, chan->mode, chan->width); drake_set_func(rig, RIG_VFO_CURR, RIG_FUNC_NB, diff --git a/rigs/drake/drake.h b/rigs/drake/drake.h index 25f4dd34f..a3f0cc66b 100644 --- a/rigs/drake/drake.h +++ b/rigs/drake/drake.h @@ -38,8 +38,8 @@ int drake_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); int drake_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); int drake_init(RIG *rig); int drake_cleanup(RIG *rig); -int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant); -int drake_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +int drake_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); int drake_set_mem(RIG *rig, vfo_t vfo, int ch); int drake_get_mem(RIG *rig, vfo_t vfo, int *ch); int drake_set_chan(RIG *rig, const channel_t *chan); diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c index a701f5936..9293b3748 100644 --- a/rigs/elad/elad.c +++ b/rigs/elad/elad.c @@ -2785,7 +2785,7 @@ int elad_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) /* * set the aerial/antenna to use */ -int elad_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int elad_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { char cmd[8]; char a; @@ -2875,7 +2875,7 @@ int elad_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant) /* * get the aerial/antenna in use */ -int elad_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int elad_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { char ackbuf[8]; int offs; diff --git a/rigs/elad/elad.h b/rigs/elad/elad.h index e9e462dba..d9fefbfd2 100644 --- a/rigs/elad/elad.h +++ b/rigs/elad/elad.h @@ -138,9 +138,9 @@ int elad_set_powerstat(RIG *rig, powerstat_t status); int elad_get_powerstat(RIG *rig, powerstat_t *status); int elad_reset(RIG *rig, reset_t reset); int elad_send_morse(RIG *rig, vfo_t vfo, const char *msg); -int elad_set_ant (RIG * rig, vfo_t vfo, ant_t ant); +int elad_set_ant (RIG * rig, vfo_t vfo, ant_t ant, value_t option); int elad_set_ant_no_ack(RIG * rig, vfo_t vfo, ant_t ant); -int elad_get_ant (RIG * rig, vfo_t vfo, ant_t * ant); +int elad_get_ant (RIG * rig, vfo_t vfo, ant_t * ant, value_t *option); int elad_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); int elad_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); int elad_set_ptt_safe(RIG *rig, vfo_t vfo, ptt_t ptt); diff --git a/rigs/flexradio/dttsp.c b/rigs/flexradio/dttsp.c index bc36dcf7d..29d2fc9fb 100644 --- a/rigs/flexradio/dttsp.c +++ b/rigs/flexradio/dttsp.c @@ -94,7 +94,7 @@ static int dttsp_get_conf(RIG *rig, token_t token, char *val); static int dttsp_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); static int dttsp_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static int dttsp_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); -static int dttsp_set_ant(RIG *rig, vfo_t vfo, ant_t ant); +static int dttsp_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); static int dttsp_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int dttsp_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); @@ -992,13 +992,13 @@ int dttsp_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) } -int dttsp_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int dttsp_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { struct dttsp_priv_data *priv = (struct dttsp_priv_data *)rig->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s: ant %d, try tuner\n", __func__, ant); - return rig_set_ant(priv->tuner, vfo, ant); + return rig_set_ant(priv->tuner, vfo, ant, option); } diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 76dd50eb1..1f8d948de 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -5042,7 +5042,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) } i = 0; - retry = 10; + retry = 2; if (status == RIG_POWER_ON) // wait for wakeup only { @@ -5218,7 +5218,7 @@ int icom_set_bank(RIG *rig, vfo_t vfo, int bank) * icom_set_ant * Assumes rig!=NULL, rig->state.priv!=NULL */ -int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { unsigned char antarg; unsigned char ackbuf[MAXFRAMELEN]; @@ -5249,11 +5249,11 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant) break; default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported ant %#x", __func__, ant); + rig_debug(RIG_DEBUG_ERR, "%s: unsupported ant %#x\n", __func__, ant); return -RIG_EINVAL; } - antarg = 0; + antarg = option.i; ant_len = ((rig->caps->rig_model == RIG_MODEL_ICR75) || (rig->caps->rig_model == RIG_MODEL_ICR8600) || (rig->caps->rig_model == RIG_MODEL_ICR6) @@ -5281,7 +5281,7 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant) * Assumes rig!=NULL, rig->state.priv!=NULL * only meaningfull for HF */ -int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *rxant) { unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf), retval; @@ -5305,6 +5305,9 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) /* Note: with IC756/IC-756Pro/IC-7800, ackbuf[2] deals with [RX ANT] */ *ant = RIG_ANT_N(ackbuf[1]); + if (ack_len == 3) { // then this should be rx ant on/off status + rxant->i = RIG_ANT_N(ackbuf[2]); + } return RIG_OK; } diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index bf53c9b50..5e1d39061 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -252,8 +252,8 @@ int icom_set_conf(RIG *rig, token_t token, const char *val); int icom_get_conf(RIG *rig, token_t token, char *val); int icom_set_powerstat(RIG *rig, powerstat_t status); int icom_get_powerstat(RIG *rig, powerstat_t *status); -int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant); -int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +int icom_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); int icom_decode_event(RIG *rig); int icom_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode); diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c index e6100341f..6f177ac86 100644 --- a/rigs/kenwood/ic10.c +++ b/rigs/kenwood/ic10.c @@ -428,7 +428,7 @@ int ic10_set_freq(RIG *rig, vfo_t vfo, freq_t freq) * ic10_set_ant * Assumes rig!=NULL */ -int ic10_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int ic10_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { char buf[6], ackbuf[16]; int len, ack_len, retval; @@ -445,7 +445,7 @@ int ic10_set_ant(RIG *rig, vfo_t vfo, ant_t ant) * ic10_get_ant * Assumes rig!=NULL, ptt!=NULL */ -int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { char infobuf[50]; int info_len, retval; diff --git a/rigs/kenwood/ic10.h b/rigs/kenwood/ic10.h index b5c56a619..01150f2ac 100644 --- a/rigs/kenwood/ic10.h +++ b/rigs/kenwood/ic10.h @@ -32,8 +32,8 @@ int ic10_set_split_vfo(RIG *rig, vfo_t vfo , split_t split, vfo_t txvfo); int ic10_get_split_vfo(RIG *rig, vfo_t vfo , split_t *split, vfo_t *txvfo); int ic10_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); int ic10_set_freq(RIG *rig, vfo_t vfo, freq_t freq); -int ic10_set_ant(RIG *rig, vfo_t vfo, ant_t ant); -int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +int ic10_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); int ic10_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); int ic10_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); int ic10_set_parm(RIG *rig, setting_t parm, value_t val); diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 4a8bf3e34..5b022a25f 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -3005,7 +3005,7 @@ int kenwood_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) /* * set the aerial/antenna to use */ -int kenwood_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int kenwood_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { char cmd[8]; char a; @@ -3061,7 +3061,7 @@ int kenwood_set_ant(RIG *rig, vfo_t vfo, ant_t ant) return kenwood_transaction(rig, cmd, NULL, 0); } -int kenwood_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant) +int kenwood_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { const char *cmd; @@ -3095,7 +3095,7 @@ int kenwood_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant) /* * get the aerial/antenna in use */ -int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { char ackbuf[8]; int offs; diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 2593c38ee..331d5a059 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -157,9 +157,9 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status); int kenwood_get_powerstat(RIG *rig, powerstat_t *status); int kenwood_reset(RIG *rig, reset_t reset); int kenwood_send_morse(RIG *rig, vfo_t vfo, const char *msg); -int kenwood_set_ant(RIG *rig, vfo_t vfo, ant_t ant); -int kenwood_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant); -int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +int kenwood_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +int kenwood_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); int kenwood_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); int kenwood_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); int kenwood_set_ptt_safe(RIG *rig, vfo_t vfo, ptt_t ptt); diff --git a/rigs/kenwood/th.c b/rigs/kenwood/th.c index 9c80bd3f4..2ca014b8c 100644 --- a/rigs/kenwood/th.c +++ b/rigs/kenwood/th.c @@ -2521,7 +2521,7 @@ int th_set_channel(RIG *rig, const channel_t *chan) /* * set the aerial/antenna to use */ -int th_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int th_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { const char *cmd; @@ -2552,7 +2552,7 @@ int th_set_ant(RIG *rig, vfo_t vfo, ant_t ant) /* * get the aerial/antenna in use */ -int th_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int th_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { char buf[8]; int retval; diff --git a/rigs/kenwood/th.h b/rigs/kenwood/th.h index e7e99a1a2..9c0f79de8 100644 --- a/rigs/kenwood/th.h +++ b/rigs/kenwood/th.h @@ -62,8 +62,8 @@ extern int th_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); extern int th_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); extern int th_get_channel(RIG *rig, channel_t *chan); extern int th_set_channel(RIG *rig, const channel_t *chan); -extern int th_set_ant (RIG * rig, vfo_t vfo, ant_t ant); -extern int th_get_ant (RIG * rig, vfo_t vfo, ant_t * ant); +extern int th_set_ant (RIG * rig, vfo_t vfo, ant_t ant, value_t option); +extern int th_get_ant (RIG * rig, vfo_t vfo, ant_t * ant, value_t *option); extern int th_reset(RIG *rig, reset_t reset); extern int th_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch); diff --git a/rigs/kit/elektor507.c b/rigs/kit/elektor507.c index 004415fa3..90e764f71 100644 --- a/rigs/kit/elektor507.c +++ b/rigs/kit/elektor507.c @@ -53,8 +53,8 @@ static int elektor507_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); static int elektor507_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); -static int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant); -static int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +static int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +static int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); static int elektor507_set_conf(RIG *rig, token_t token, const char *val); static int elektor507_get_conf(RIG *rig, token_t token, char *val); @@ -1147,7 +1147,7 @@ int elektor507_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } -int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { struct elektor507_priv_data *priv = (struct elektor507_priv_data *) rig->state.priv; @@ -1191,7 +1191,7 @@ int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant) return (ret != 0) ? -RIG_EIO : RIG_OK; } -int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { struct elektor507_priv_data *priv = (struct elektor507_priv_data *) rig->state.priv; diff --git a/rigs/kit/hiqsdr.c b/rigs/kit/hiqsdr.c index 0891058e6..374ca8d7c 100644 --- a/rigs/kit/hiqsdr.c +++ b/rigs/kit/hiqsdr.c @@ -66,7 +66,7 @@ static int hiqsdr_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, static int hiqsdr_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); static int hiqsdr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); static int hiqsdr_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); -static int hiqsdr_set_ant(RIG *rig, vfo_t vfo, ant_t ant); +static int hiqsdr_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); static int hiqsdr_set_conf(RIG *rig, token_t token, const char *val); static int hiqsdr_get_conf(RIG *rig, token_t token, char *val); @@ -502,7 +502,7 @@ int hiqsdr_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) return ret; } -int hiqsdr_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int hiqsdr_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv; int ret = RIG_OK; @@ -525,8 +525,6 @@ int hiqsdr_set_ant(RIG *rig, vfo_t vfo, ant_t ant) } -/* - */ int hiqsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { struct hiqsdr_priv_data *priv = (struct hiqsdr_priv_data *)rig->state.priv; diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c index bb2041738..5fe5c74b6 100644 --- a/rigs/racal/ra37xx.c +++ b/rigs/racal/ra37xx.c @@ -726,7 +726,7 @@ const char *ra37xx_get_info(RIG *rig) return infobuf + 2; } -int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { char buf[BUFSZ]; int i_ant; @@ -751,7 +751,7 @@ int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant) return ra37xx_transaction(rig, buf, NULL, NULL); } -int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { char buf[BUFSZ]; int retval, buflen, ra_ant; diff --git a/rigs/racal/ra37xx.h b/rigs/racal/ra37xx.h index 740424a00..205ddd5e8 100644 --- a/rigs/racal/ra37xx.h +++ b/rigs/racal/ra37xx.h @@ -76,8 +76,8 @@ int ra37xx_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); int ra37xx_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); int ra37xx_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); const char* ra37xx_get_info(RIG *rig); -int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant); -int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); +int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); int ra37xx_set_mem(RIG *rig, vfo_t vfo, int ch); int ra37xx_get_mem(RIG *rig, vfo_t vfo, int *ch); int ra37xx_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch); diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index 7024cc4ca..1306ae4c0 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -2019,7 +2019,7 @@ int tt565_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) * The efficient way would be to keep current config in rig priv area, but we will * ask the rig what its state is each time... */ -int tt565_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int tt565_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { char respbuf[TT565_BUFSIZE]; int resp_len, retval; @@ -2116,7 +2116,7 @@ int tt565_set_ant(RIG *rig, vfo_t vfo, ant_t ant) * * \sa tt565_set_ant */ -int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { char respbuf[TT565_BUFSIZE]; int resp_len, retval; diff --git a/rigs/tentec/orion.h b/rigs/tentec/orion.h index 102dfc7b0..3d16d416c 100644 --- a/rigs/tentec/orion.h +++ b/rigs/tentec/orion.h @@ -77,8 +77,8 @@ static const char* tt565_get_info(RIG *rig); static int tt565_send_morse(RIG *rig, vfo_t vfo, const char *msg); static int tt565_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); static int tt565_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); -static int tt565_set_ant(RIG * rig, vfo_t vfo, ant_t ant); -static int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t *ant); +static int tt565_set_ant(RIG * rig, vfo_t vfo, ant_t ant, value_t option); +static int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option); /** \brief Orion private data */ struct tt565_priv_data { diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 434cb881f..3b60a1f18 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -2361,7 +2361,7 @@ int newcat_reset(RIG *rig, reset_t reset) } -int newcat_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int newcat_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; int err; @@ -2450,7 +2450,7 @@ int newcat_set_ant(RIG *rig, vfo_t vfo, ant_t ant) } -int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; int err; diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 41bd52f4e..c362731d1 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -145,8 +145,8 @@ int newcat_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); int newcat_get_ptt(RIG * rig, vfo_t vfo, ptt_t * ptt); -int newcat_set_ant(RIG * rig, vfo_t vfo, ant_t ant); -int newcat_get_ant(RIG * rig, vfo_t vfo, ant_t * ant); +int newcat_set_ant(RIG * rig, vfo_t vfo, ant_t ant, value_t option); +int newcat_get_ant(RIG * rig, vfo_t vfo, ant_t * ant, value_t * option); int newcat_set_level(RIG * rig, vfo_t vfo, setting_t level, value_t val); int newcat_get_level(RIG * rig, vfo_t vfo, setting_t level, value_t * val); int newcat_set_func(RIG * rig, vfo_t vfo, setting_t func, int status); diff --git a/src/mem.c b/src/mem.c index 2400340c2..6cffebd8d 100644 --- a/src/mem.c +++ b/src/mem.c @@ -363,6 +363,7 @@ static int generic_save_channel(RIG *rig, channel_t *chan) vfo_t vfo; setting_t setting; const channel_cap_t *mem_cap = NULL; + value_t vdummy; chan_num = chan->channel_num; vfo = chan->vfo; @@ -446,7 +447,7 @@ static int generic_save_channel(RIG *rig, channel_t *chan) if (mem_cap->ant) { - rig_get_ant(rig, RIG_VFO_CURR, &chan->ant); + rig_get_ant(rig, RIG_VFO_CURR, &chan->ant, &vdummy); } if (mem_cap->tuning_step) @@ -529,6 +530,7 @@ static int generic_restore_channel(RIG *rig, const channel_t *chan) struct ext_list *p; setting_t setting; const channel_cap_t *mem_cap = NULL; + value_t vdummy; if (chan->vfo == RIG_VFO_MEM) { @@ -596,7 +598,7 @@ static int generic_restore_channel(RIG *rig, const channel_t *chan) if (mem_cap->ant) { - rig_set_ant(rig, RIG_VFO_CURR, chan->ant); + rig_set_ant(rig, RIG_VFO_CURR, chan->ant, vdummy); } if (mem_cap->tuning_step) diff --git a/src/rig.c b/src/rig.c index 6a3b96d4c..6091db1d5 100644 --- a/src/rig.c +++ b/src/rig.c @@ -3521,7 +3521,7 @@ int HAMLIB_API rig_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts) * * \sa rig_get_ant() */ -int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) { const struct rig_caps *caps; int retcode, rc2; @@ -3545,7 +3545,7 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { - return caps->set_ant(rig, vfo, ant); + return caps->set_ant(rig, vfo, ant, option); } if (!caps->set_vfo) @@ -3561,7 +3561,7 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant) return retcode; } - retcode = caps->set_ant(rig, vfo, ant); + retcode = caps->set_ant(rig, vfo, ant, option); /* try and revert even if we had an error above */ rc2 = caps->set_vfo(rig, curr_vfo); @@ -3589,7 +3589,7 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant) * * \sa rig_set_ant() */ -int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { const struct rig_caps *caps; int retcode, rc2; @@ -3613,7 +3613,7 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { - return caps->get_ant(rig, vfo, ant); + return caps->get_ant(rig, vfo, ant, option); } if (!caps->set_vfo) @@ -3629,7 +3629,7 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) return retcode; } - retcode = caps->get_ant(rig, vfo, ant); + retcode = caps->get_ant(rig, vfo, ant, option); /* try and revert even if we had an error above */ rc2 = caps->set_vfo(rig, curr_vfo); diff --git a/tests/rigctl.c b/tests/rigctl.c index 499bfa27c..cce1d2a7f 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -519,7 +519,7 @@ int main(int argc, char *argv[]) if (retcode != RIG_OK) { fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode)); - exit(2); +// exit(2); } if (verbose > 0) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index a3aea8559..e31d64139 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -286,8 +286,8 @@ static struct test_table test_list[] = { 'j', "get_rit", ACTION(get_rit), ARG_OUT, "RIT" }, { 'Z', "set_xit", ACTION(set_xit), ARG_IN, "XIT" }, { 'z', "get_xit", ACTION(get_xit), ARG_OUT, "XIT" }, - { 'Y', "set_ant", ACTION(set_ant), ARG_IN, "Antenna" }, - { 'y', "get_ant", ACTION(get_ant), ARG_OUT, "Antenna" }, + { 'Y', "set_ant", ACTION(set_ant), ARG_IN, "Antenna", "Option" }, + { 'y', "get_ant", ACTION(get_ant), ARG_OUT, "Antenna", "Option" }, { 0x87, "set_powerstat", ACTION(set_powerstat), ARG_IN | ARG_NOVFO, "Power Status" }, { 0x88, "get_powerstat", ACTION(get_powerstat), ARG_OUT | ARG_NOVFO, "Power Status" }, { 0x89, "send_dtmf", ACTION(send_dtmf), ARG_IN, "Digits" }, @@ -3936,9 +3936,12 @@ declare_proto_rig(dump_conf) declare_proto_rig(set_ant) { ant_t ant; + value_t option; // some rigs have a another option for the antenna CHKSCN1ARG(sscanf(arg1, "%d", &ant)); - return rig_set_ant(rig, vfo, rig_idx2setting(ant)); + CHKSCN1ARG(sscanf(arg2, "%d", &option.i)); // assuming they are integer values + + return rig_set_ant(rig, vfo, rig_idx2setting(ant), option); } @@ -3947,8 +3950,9 @@ declare_proto_rig(get_ant) { int status; ant_t ant; + value_t option; - status = rig_get_ant(rig, vfo, &ant); + status = rig_get_ant(rig, vfo, &ant, &option); if (status != RIG_OK) { @@ -3962,6 +3966,13 @@ declare_proto_rig(get_ant) fprintf(fout, "%d%c", rig_setting2idx(ant), resp_sep); + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) + { + fprintf(fout, "%s: ", cmd->arg2); + } + + fprintf(fout, "%d%c", option.i, resp_sep); + return status; }