From 38d76f33bf565fffb69b0a1e371f5e210e1ef3f4 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Tue, 21 Jan 2020 10:45:08 +0100 Subject: [PATCH 01/20] tests/{memcsv.c,memsave.c}: partially revert commit 4072f9f4 this partially revert the commit 4072f9f4 because it introduced duplication of channel_desc --- tests/memcsv.c | 10 ---------- tests/memsave.c | 6 ------ 2 files changed, 16 deletions(-) diff --git a/tests/memcsv.c b/tests/memcsv.c index 1383efe71..d0ce5a0dd 100644 --- a/tests/memcsv.c +++ b/tests/memcsv.c @@ -548,11 +548,6 @@ void dump_csv_name(const channel_cap_t *mem_caps, FILE *f) fprintf(f, "flags%c", csv_sep); } - if (mem_caps->channel_desc) - { - fprintf(f, "channel_desc%c", csv_sep); - } - fprintf(f, "\n"); } @@ -708,11 +703,6 @@ int dump_csv_chan(RIG *rig, fprintf(f, "%x%c", chan.flags, csv_sep); } - if (mem_caps->channel_desc) - { - fprintf(f, "%s", chan.channel_desc); - } - fprintf(f, "\n"); /* diff --git a/tests/memsave.c b/tests/memsave.c index 218a805fa..fca02853b 100644 --- a/tests/memsave.c +++ b/tests/memsave.c @@ -285,12 +285,6 @@ int dump_xml_chan(RIG *rig, xmlNewProp(node, (unsigned char *) "flags", (unsigned char *) attrbuf); } - if (mem_caps->channel_desc) - { - sprintf(attrbuf, "%s", chan.channel_desc); - xmlNewProp(node, (unsigned char *) "channel_desc", (unsigned char *) attrbuf); - } - return 0; } #endif From 2ce77215069e7e6af1466a203b07e5175fd69a71 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 21 Jan 2020 11:58:25 -0600 Subject: [PATCH 02/20] Add -ldl to tests/Makefile.am --- tests/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0028d8ee9..97839a739 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ rigmem_SOURCES = rigmem.c memsave.c memload.c memcsv.c sprintflst.c sprintflst.h rigctl_CPPFLAGS = -I$(top_srcdir) $(AM_CPPFLAGS) # all the programs need this -LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la +LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la -ldl rigmem_CFLAGS = $(AM_CFLAGS) $(LIBXML2_CFLAGS) rigctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) @@ -36,7 +36,7 @@ rotctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) ampctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) rigctlcom_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -rigctl_LDADD = $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) +rigctl_LDADD = $(PTHREAD_LIBS) $(READLINE_LIBS) $(LDADD) rigctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) rotctl_LDADD = $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) rotctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) From d853c36fb35e82455f68ec5a7ab0c1c08ed123ac Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 21 Jan 2020 17:53:12 -0600 Subject: [PATCH 03/20] Change get_ant to add another option for icom rigs (and others if needed) --- bindings/rig.swg | 9 +++++++-- c++/rigclass.cc | 10 ++++------ dummy/dummy.c | 9 ++++++--- dummy/netrigctl.c | 33 ++++++++++++++++++++++++++++----- include/hamlib/rig.h | 10 ++++++---- include/hamlib/rigclass.h | 4 ++-- rigs/drake/drake.c | 8 ++++---- rigs/drake/drake.h | 4 ++-- rigs/elad/elad.c | 4 ++-- rigs/elad/elad.h | 4 ++-- rigs/flexradio/dttsp.c | 6 +++--- rigs/icom/icom.c | 13 ++++++++----- rigs/icom/icom.h | 4 ++-- rigs/kenwood/ic10.c | 4 ++-- rigs/kenwood/ic10.h | 4 ++-- rigs/kenwood/kenwood.c | 6 +++--- rigs/kenwood/kenwood.h | 6 +++--- rigs/kenwood/th.c | 4 ++-- rigs/kenwood/th.h | 4 ++-- rigs/kit/elektor507.c | 8 ++++---- rigs/kit/hiqsdr.c | 6 ++---- rigs/racal/ra37xx.c | 4 ++-- rigs/racal/ra37xx.h | 4 ++-- rigs/tentec/orion.c | 4 ++-- rigs/tentec/orion.h | 4 ++-- rigs/yaesu/newcat.c | 4 ++-- rigs/yaesu/newcat.h | 4 ++-- src/mem.c | 6 ++++-- src/rig.c | 12 ++++++------ tests/rigctl.c | 2 +- tests/rigctl_parse.c | 19 +++++++++++++++---- 31 files changed, 134 insertions(+), 89 deletions(-) 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; } From 2b96ab4907c80d8ccf1ff25cfb2d801f2317baea Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 21 Jan 2020 18:03:50 -0600 Subject: [PATCH 04/20] Remove -ldl from tests/Makefile.am -- need to find another solution --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 97839a739..375a240d7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ rigmem_SOURCES = rigmem.c memsave.c memload.c memcsv.c sprintflst.c sprintflst.h rigctl_CPPFLAGS = -I$(top_srcdir) $(AM_CPPFLAGS) # all the programs need this -LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la -ldl +LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la rigmem_CFLAGS = $(AM_CFLAGS) $(LIBXML2_CFLAGS) rigctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) From bf8e90d21484ef129e52904afe9dc61545076c46 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 21 Jan 2020 18:08:05 -0600 Subject: [PATCH 05/20] Remove unused var in netrigctl.c --- dummy/netrigctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dummy/netrigctl.c b/dummy/netrigctl.c index 79ae0e1aa..4f0e6faa0 100644 --- a/dummy/netrigctl.c +++ b/dummy/netrigctl.c @@ -1760,7 +1760,7 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t *ant, value_t *option) { - int ret, len, ioption; + int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; char vfostr[6] = ""; From cab9cffdd873dd702f5a99a2238f1ea08770243b Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 21 Jan 2020 22:52:35 -0600 Subject: [PATCH 06/20] Add CM108, GPIO, and GPION to rigctl.1 man page --- doc/man1/rigctl.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index 7f68ec4e3..cf66393f0 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -111,7 +111,7 @@ Use of Push-To-Talk device. .IP Supported types are \(oqRIG\(cq (CAT command), \(oqDTR\(cq, \(oqRTS\(cq, -\(oqPARALLEL\(cq, \(oqNONE\(cq, overriding PTT type defined in the rig's +\(oqPARALLEL\(cq, \(oqCM108\(cq, \(oqGPIO\(cq, \(oqGPION\(cq, \(oqNONE\(cq, overriding PTT type defined in the rig's backend. .IP Some side effects of this command are that when type is set to DTR, read @@ -127,7 +127,7 @@ Use of Data Carrier Detect device. .IP Supported types are \(oqRIG\(cq (CAT command), \(oqDSR\(cq, \(oqCTS\(cq, -\(oqCD\(cq, \(oqPARALLEL\(cq, \(oqNONE\(cq. +\(oqCD\(cq, \(oqPARALLEL\(cq, \(oqCM108\(cq, \(oqGPIO\(cq, \(oqGPION\(cq, \(oqNONE\(cq. . .TP .BR \-s ", " \-\-serial\-speed = \fIbaud\fP From 999bc11b74e97b2345e19a88070bb709aa3ed3ab Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Tue, 21 Jan 2020 10:47:56 +0100 Subject: [PATCH 07/20] ic746.c: correct chanbuf length, fix channel structure and support split on channel_str_t - enable pol to align the structure with membuf needed by ic746pro_get_channel() to save the description name on ic746pro_get_channel() - fix chanbuf length - add split configuration --- rigs/icom/ic746.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index a17a04ced..27759b108 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -131,8 +131,7 @@ typedef struct unsigned char tone_sql[3]; /* tone squelch frequency as tone */ struct { - //unsigned char - //pol; /* DTCS polarity by nibbles Tx pol | Rx pol; 0 = normal; 1 = rev */ + unsigned char pol; /* DTCS polarity by nibbles Tx pol | Rx pol; 0 = normal; 1 = rev */ unsigned char code[2]; /* DTCS code bigendian */ } dcs; } channel_str_t; @@ -905,7 +904,7 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) { struct icom_priv_data *priv; struct rig_state *rs; - unsigned char chanbuf[50]; + unsigned char chanbuf[MAXFRAMELEN]; mem_buf_t *membuf; int chan_len, freq_len, retval, data_len; @@ -984,7 +983,8 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) membuf = (mem_buf_t *)(chanbuf + 4); - chan->flags = membuf->chan_flag && 0x01 ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE; + chan->split = membuf->chan_flag & 0x10 ? RIG_SPLIT_ON : RIG_SPLIT_OFF; + chan->flags = membuf->chan_flag & 0x01 ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE; rig_debug(RIG_DEBUG_TRACE, "%s: chan->flags=0x%02x\n", __func__, chan->flags); /* data mode on */ rig_debug(RIG_DEBUG_TRACE, "%s: membuf->rx.data=0x%02x\n", __func__, membuf->rx.data); @@ -1003,7 +1003,7 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) rig_debug(RIG_DEBUG_TRACE, "%s: chan->rptr_shift=%d\n", __func__, chan->rptr_shift); /* offset is default for the band & is not stored in channel memory. - The following retrieves the system default for the band */ + The following retrieves the system default for the band */ band = (int) chan->freq / 1000000; /* hf, 2m or 6 m */ if (band < 50) { sc = S_MEM_HF_DUP_OFST; } From ccd1010e3e4471b638613c4b3ed507cc4f203639 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Sun, 19 Jan 2020 10:54:57 +0100 Subject: [PATCH 08/20] ic746.c: add ic746pro_set_channel() to load memory from csv tested with IC-7400 (aka IC-746Pro) note: if the csv line is without frequency or mode the memory channel will be cleared Closes: https://github.com/Hamlib/Hamlib/issues/125 --- rigs/icom/ic746.c | 157 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 3 deletions(-) diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index 27759b108..2023a3160 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -42,7 +42,6 @@ * * TODO: * - advanced scanning functions - * - set_channel * - set_ctcss_tone/ctcss_sql * - set keyer? * - test all that stuff.. @@ -115,9 +114,9 @@ typedef struct { - unsigned char freq[5]; /* little endian frequency */ + unsigned char freq[5]; /* little endian frequency */ unsigned char mode; - unsigned char pb; /* passband or filter selection*/ + signed char pb; /* passband or filter selection*/ unsigned char data; /* data port 0=off 1=on */ unsigned char dup; /* duplex, tone, tonesql and DTCS Values in hex are "or"ed together @@ -156,6 +155,7 @@ typedef channel_str_t band_stack_reg_t; static int ic746_set_parm(RIG *rig, setting_t parm, value_t val); static int ic746_get_parm(RIG *rig, setting_t parm, value_t *val); static int ic746pro_get_channel(RIG *rig, channel_t *chan); +static int ic746pro_set_channel(RIG *rig, const channel_t *chan); static int ic746pro_set_ext_parm(RIG *rig, token_t token, value_t val); static int ic746pro_get_ext_parm(RIG *rig, token_t token, value_t *val); @@ -575,6 +575,7 @@ const struct rig_caps ic746pro_caps = .set_ext_parm = ic746pro_set_ext_parm, .get_ext_parm = ic746pro_get_ext_parm, .get_channel = ic746pro_get_channel, + .set_channel = ic746pro_set_channel, }; @@ -1041,3 +1042,153 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) return RIG_OK; } + +/* + * ic746pro_set_channel + * Assumes rig!=NULL, rig->state.priv!=NULL, chan!=NULL + */ +int ic746pro_set_channel(RIG *rig, const channel_t *chan) +{ + struct icom_priv_data *priv; + struct rig_state *rs; + mem_buf_t membuf = {0}; + unsigned char chanbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; + int chan_len, ack_len, freq_len, retval; + + rs = &rig->state; + priv = (struct icom_priv_data *)rs->priv; + + freq_len = priv->civ_731_mode ? 4 : 5; + + // set memory channel + to_bcd_be(chanbuf, chan->channel_num, 4); + chan_len = 2; + + // if good value, we change the memory otherwise clear + if (chan->freq != 0 || chan->mode != 0) + { + if (chan->split == RIG_SPLIT_ON) + membuf.chan_flag |= 0x10; + else + membuf.chan_flag |= chan->flags & RIG_CHFLAG_SKIP ? 0x01 : 0x00; + + // RX + to_bcd(membuf.rx.freq, chan->freq, freq_len * 2); + + retval = rig2icom_mode(rig, chan->mode, chan->width, + &membuf.rx.mode, &membuf.rx.pb); + + if (retval != RIG_OK) + { + return retval; + } + + if(membuf.rx.pb == -1) + membuf.rx.pb = PD_MEDIUM_3; + + membuf.rx.data = chan->flags & RIG_CHFLAG_DATA ? 1 : 0; + membuf.rx.dup = chan->rptr_shift; + + // not empty otherwise the call fail + if (chan->ctcss_tone == 0) + to_bcd_be(membuf.rx.tone, 885, 6); + else + to_bcd_be(membuf.rx.tone, chan->ctcss_tone, 6); + if (chan->ctcss_sql == 0) + to_bcd_be(membuf.rx.tone_sql, 885, 6); + else + to_bcd_be(membuf.rx.tone_sql, chan->ctcss_sql, 6); + + if (chan->dcs_code == 0) + to_bcd_be(membuf.rx.dcs.code, 23, 4); + else + to_bcd_be(membuf.rx.dcs.code, chan->dcs_code, 4); + + // TX + to_bcd(membuf.tx.freq, chan->tx_freq, freq_len * 2); + + retval = rig2icom_mode(rig, chan->tx_mode, chan->tx_width, + &membuf.tx.mode, &membuf.tx.pb); + + if (retval != RIG_OK) + { + return retval; + } + + if(membuf.tx.pb == -1) + membuf.tx.pb = PD_MEDIUM_3; + + membuf.tx.data = chan->flags | RIG_CHFLAG_DATA ? 1 : 0; + membuf.tx.dup = chan->rptr_shift; + + // not empty otherwise the call fail + if (chan->ctcss_tone == 0) + to_bcd_be(membuf.tx.tone, 885, 6); + else + to_bcd_be(membuf.tx.tone, chan->ctcss_tone, 6); + if (chan->ctcss_sql == 0) + to_bcd_be(membuf.tx.tone_sql, 885, 6); + else + to_bcd_be(membuf.tx.tone_sql, chan->ctcss_sql, 6); + + if (chan->dcs_code == 0) + to_bcd_be(membuf.tx.dcs.code, 23, 4); + else + to_bcd_be(membuf.tx.dcs.code, chan->dcs_code, 4); + + // set description + memcpy(membuf.name, chan->channel_desc, sizeof(membuf.name)); + + memcpy(chanbuf+chan_len, &membuf, sizeof(mem_buf_t)); + chan_len += sizeof(mem_buf_t); + + retval = icom_transaction(rig, C_CTL_MEM, S_MEM_CNTNT, + chanbuf, chan_len, ackbuf, &ack_len); + + if (retval != RIG_OK) + { + return retval; + } + + if (ack_len != 1 || ackbuf[0] != ACK) + { + rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; + } + } + else + { + retval = icom_transaction(rig, C_SET_MEM, -1, + chanbuf, chan_len, ackbuf, &ack_len); + + if (retval != RIG_OK) + { + return retval; + } + + if (ack_len != 1 || ackbuf[0] != ACK) + { + rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; + } + + retval = icom_transaction(rig, C_CLR_MEM, -1, NULL, 0, ackbuf, &ack_len); + + if (retval != RIG_OK) + { + return retval; + } + + if (ack_len != 1 || ackbuf[0] != ACK) + { + rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; + } + + } + + return RIG_OK; +} From 5903cda8c6b1488b3855f9dc673814aac7fe0b13 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Wed, 22 Jan 2020 17:04:25 -0600 Subject: [PATCH 09/20] Fix DLL warning on debug.c --- src/debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/debug.c b/src/debug.c index bd2bd1f62..96c6834d6 100644 --- a/src/debug.c +++ b/src/debug.c @@ -49,6 +49,7 @@ #endif #include +#include #include "misc.h" #define DUMP_HEX_WIDTH 16 From 54ce2f745d61cea47272f0d4e3e6909fac03ed9d Mon Sep 17 00:00:00 2001 From: Michael Black Date: Wed, 22 Jan 2020 17:04:43 -0600 Subject: [PATCH 10/20] Fix cppcheck warning on drake.c --- rigs/drake/drake.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index 842037b33..0fb38ea11 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -618,6 +618,8 @@ int drake_set_chan(RIG *rig, const channel_t *chan) int mdbuf_len, ack_len, retval; value_t dummy; + dummy.i = 0; + drake_get_vfo(rig, &old_vfo); old_chan = 0; From 09df074570ad932c181e2e1de1c158fb44e049de Mon Sep 17 00:00:00 2001 From: Michael Black Date: Wed, 22 Jan 2020 23:39:03 -0600 Subject: [PATCH 11/20] Fix -ldl linking when --disable-winradio is used --- configure.ac | 8 ++++++++ tests/Makefile.am | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a7f043788..a5c8c5908 100644 --- a/configure.ac +++ b/configure.ac @@ -660,6 +660,14 @@ dnl Check for libdl and set DL_LIBS if found--used for linradio WR-G313 backend. [AC_MSG_WARN([dlopen was not found in libdl--linradio backend will be disabled])]) ]) +# Still need -ldl if we have it +AS_IF([test x"${cf_with_winradio}" = "xno"], + [RIGS_BACKEND_LIST="$RIGS_BACKEND_LIST" +dnl Check for libdl and set DL_LIBS if found--used for linradio WR-G313 backend. + AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl"], + [AC_MSG_WARN([dlopen was not found in libdl--linradio backend will be disabled])]) + ]) + dnl Set conditional compilation for G-313. AS_CASE(["$host_os"], [mingw* | pw32* | cygwin ], [ diff --git a/tests/Makefile.am b/tests/Makefile.am index 375a240d7..f78b7f5d7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ rigmem_SOURCES = rigmem.c memsave.c memload.c memcsv.c sprintflst.c sprintflst.h rigctl_CPPFLAGS = -I$(top_srcdir) $(AM_CPPFLAGS) # all the programs need this -LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la +LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la $(DL_LIBS) rigmem_CFLAGS = $(AM_CFLAGS) $(LIBXML2_CFLAGS) rigctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) From f143d8abd9ba2c388871410d11eb1d90a37503fb Mon Sep 17 00:00:00 2001 From: Michael Black Date: Thu, 23 Jan 2020 17:20:41 -0600 Subject: [PATCH 12/20] Fix cppcheck warnings --- rigs/icom/ic746.c | 13 ++++++------- src/debug.c | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index 2023a3160..8a01c884b 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -130,7 +130,6 @@ typedef struct unsigned char tone_sql[3]; /* tone squelch frequency as tone */ struct { - unsigned char pol; /* DTCS polarity by nibbles Tx pol | Rx pol; 0 = normal; 1 = rev */ unsigned char code[2]; /* DTCS code bigendian */ } dcs; } channel_str_t; @@ -906,7 +905,6 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) struct icom_priv_data *priv; struct rig_state *rs; unsigned char chanbuf[MAXFRAMELEN]; - mem_buf_t *membuf; int chan_len, freq_len, retval, data_len; rs = &rig->state; @@ -981,11 +979,12 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) int band; int sc; unsigned char databuf[32]; + mem_buf_t *membuf; membuf = (mem_buf_t *)(chanbuf + 4); - chan->split = membuf->chan_flag & 0x10 ? RIG_SPLIT_ON : RIG_SPLIT_OFF; - chan->flags = membuf->chan_flag & 0x01 ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE; + chan->split = (membuf->chan_flag & 0x10) ? RIG_SPLIT_ON : RIG_SPLIT_OFF; + chan->flags = (membuf->chan_flag & 0x01) ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE; rig_debug(RIG_DEBUG_TRACE, "%s: chan->flags=0x%02x\n", __func__, chan->flags); /* data mode on */ rig_debug(RIG_DEBUG_TRACE, "%s: membuf->rx.data=0x%02x\n", __func__, membuf->rx.data); @@ -1070,7 +1069,7 @@ int ic746pro_set_channel(RIG *rig, const channel_t *chan) if (chan->split == RIG_SPLIT_ON) membuf.chan_flag |= 0x10; else - membuf.chan_flag |= chan->flags & RIG_CHFLAG_SKIP ? 0x01 : 0x00; + membuf.chan_flag |= (chan->flags & RIG_CHFLAG_SKIP) ? 0x01 : 0x00; // RX to_bcd(membuf.rx.freq, chan->freq, freq_len * 2); @@ -1086,7 +1085,7 @@ int ic746pro_set_channel(RIG *rig, const channel_t *chan) if(membuf.rx.pb == -1) membuf.rx.pb = PD_MEDIUM_3; - membuf.rx.data = chan->flags & RIG_CHFLAG_DATA ? 1 : 0; + membuf.rx.data = (chan->flags & RIG_CHFLAG_DATA) ? 1 : 0; membuf.rx.dup = chan->rptr_shift; // not empty otherwise the call fail @@ -1118,7 +1117,7 @@ int ic746pro_set_channel(RIG *rig, const channel_t *chan) if(membuf.tx.pb == -1) membuf.tx.pb = PD_MEDIUM_3; - membuf.tx.data = chan->flags | RIG_CHFLAG_DATA ? 1 : 0; + membuf.tx.data = (chan->flags | RIG_CHFLAG_DATA) ? 1 : 0; membuf.tx.dup = chan->rptr_shift; // not empty otherwise the call fail diff --git a/src/debug.c b/src/debug.c index 96c6834d6..f138a072e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -61,13 +61,14 @@ static FILE *rig_debug_stream; static vprintf_cb_t rig_vprintf_cb; static rig_ptr_t rig_vprintf_arg; +extern HAMLIB_EXPORT(void) dump_hex(const unsigned char ptr[], size_t size); /** * \param ptr Pointer to memory area * \param size Number of chars to words to dump * \brief Do a hex dump of the unsigned char array. */ -HAMLIB_EXPORT(void) dump_hex(const unsigned char ptr[], size_t size) +void dump_hex(const unsigned char ptr[], size_t size) { /* example * 0000 4b 30 30 31 34 35 30 30 30 30 30 30 30 35 30 32 K001450000000502 From 3ea6aceb2e0998556e7fe5885c38c97e0532079c Mon Sep 17 00:00:00 2001 From: Michael Black Date: Thu, 23 Jan 2020 22:47:13 -0600 Subject: [PATCH 13/20] Fix rig dependency in src/Makefile.am --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 35dd67e68..b53926a4f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,6 @@ libhamlib_la_LDFLAGS = $(WINLDFLAGS) $(OSXLDFLAGS) -no-undefined -version-info $ libhamlib_la_LIBADD = $(top_builddir)/lib/libmisc.la \ $(BACKENDEPS) $(RIG_BACKENDEPS) $(ROT_BACKENDEPS) $(AMP_BACKENDEPS) $(NET_LIBS) $(MATH_LIBS) $(LIBUSB_LIBS) -libhamlib_la_DEPENDENCIES = $(top_builddir)/lib/libmisc.la $(BACKENDEPS) $(RIG_BACKEND_DEPS) $(ROT_BACKENDEPS) $(AMP_BACKENDEPS) +libhamlib_la_DEPENDENCIES = $(top_builddir)/lib/libmisc.la $(BACKENDEPS) $(RIG_BACKENDEPS) $(ROT_BACKENDEPS) $(AMP_BACKENDEPS) EXTRA_DIST = Android.mk From 99e1948cd3a32c4b199f09231af26e07f06999a6 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 10:46:57 +0000 Subject: [PATCH 14/20] Made PTT and DCD options consistent between rigctl and rigctld --- tests/rigctld.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/rigctld.c b/tests/rigctld.c index 8d5dc2962..911ad2300 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -352,6 +352,14 @@ int main(int argc, char *argv[]) { ptt_type = RIG_PTT_CM108; } + else if (!strcmp(optarg, "GPIO")) + { + ptt_type = RIG_PTT_GPIO; + } + else if (!strcmp(optarg, "GPION")) + { + ptt_type = RIG_PTT_GPION; + } else if (!strcmp(optarg, "NONE")) { ptt_type = RIG_PTT_NONE; @@ -390,6 +398,18 @@ int main(int argc, char *argv[]) { dcd_type = RIG_DCD_PARALLEL; } + else if (!strcmp(optarg, "CM108")) + { + dcd_type = RIG_DCD_CM108; + } + else if (!strcmp(optarg, "GPIO")) + { + dcd_type = RIG_DCD_GPIO; + } + else if (!strcmp(optarg, "GPION")) + { + dcd_type = RIG_DCD_GPION; + } else if (!strcmp(optarg, "NONE")) { dcd_type = RIG_DCD_NONE; From 376b328ecb24c1cb0ec5e5618821d81e2a592b85 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 11:31:40 +0000 Subject: [PATCH 15/20] Report unrecognised PTT and DCD types in rigctl and rigctld --- tests/rigctl.c | 6 ++++-- tests/rigctld.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/rigctl.c b/tests/rigctl.c index cce1d2a7f..f1c8e2059 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -259,7 +259,8 @@ int main(int argc, char *argv[]) } else { - ptt_type = atoi(optarg); + puts("Unrecognised PTT type, using NONE"); + ptt_type = RIG_PTT_NONE; } break; @@ -309,7 +310,8 @@ int main(int argc, char *argv[]) } else { - dcd_type = atoi(optarg); + puts("Unrecognised DCD type, using NONE"); + dcd_type = RIG_DCD_NONE; } break; diff --git a/tests/rigctld.c b/tests/rigctld.c index 911ad2300..d49dfbbf0 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -366,7 +366,8 @@ int main(int argc, char *argv[]) } else { - ptt_type = atoi(optarg); + puts("Unrecognised PTT type, using NONE"); + ptt_type = RIG_PTT_NONE; } break; @@ -416,7 +417,8 @@ int main(int argc, char *argv[]) } else { - dcd_type = atoi(optarg); + puts("Unrecognised DCD type, using NONE"); + dcd_type = RIG_DCD_NONE; } break; From 5edceddcea2fad5e7a1159dcba41fe461cee7c3a Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 12:23:42 +0000 Subject: [PATCH 16/20] Update i/o functions to support GPIO(N) port closure --- src/iofunc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/iofunc.c b/src/iofunc.c index 3c5f70c7f..8f172db6a 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -53,6 +53,7 @@ #include "usb_port.h" #include "network.h" #include "cm108.h" +#include "gpio.h" /** * \brief Open a hamlib_port based on its rig port type @@ -209,6 +210,11 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type) ret = cm108_close(p); break; + case RIG_PORT_GPIO: + case RIG_PORT_GPION: + ret = gpio_close(p); + break; + case RIG_PORT_USB: ret = usb_port_close(p); break; From 6573a283a81d43a699d92b8fdedd8086b0b60c95 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 12:50:07 +0000 Subject: [PATCH 17/20] Fixed erroneous messages in rig_close with GPIO(N) PTT or DCD types --- src/rig.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rig.c b/src/rig.c index 6091db1d5..94bf0541d 100644 --- a/src/rig.c +++ b/src/rig.c @@ -981,6 +981,7 @@ int HAMLIB_API rig_close(RIG *rig) case RIG_PTT_GPION: gpio_ptt_set(&rs->pttport, RIG_PTT_OFF); port_close(&rs->pttport, RIG_PORT_GPIO); + break; default: rig_debug(RIG_DEBUG_ERR, @@ -1012,6 +1013,7 @@ int HAMLIB_API rig_close(RIG *rig) case RIG_DCD_GPIO: case RIG_DCD_GPION: port_close(&rs->dcdport, RIG_PORT_GPIO); + break; default: rig_debug(RIG_DEBUG_ERR, From be0f371bdef014cd08b05f861a519f09f84e9d32 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 14:46:21 +0000 Subject: [PATCH 18/20] Remove duplication across GPIO and GPION handling of PTT and DCD --- src/rig.c | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/src/rig.c b/src/rig.c index 94bf0541d..fc650bd9b 100644 --- a/src/rig.c +++ b/src/rig.c @@ -690,31 +690,12 @@ int HAMLIB_API rig_open(RIG *rig) break; case RIG_PTT_GPIO: - rs->pttport.fd = gpio_open(&rs->pttport, 1, 1); - - if (rs->pttport.fd < 0) - { - rig_debug(RIG_DEBUG_ERR, - "%s: cannot open PTT device \"%s\"\n", - __func__, - rs->pttport.pathname); - status = -RIG_EIO; - } - else - { - gpio_ptt_set(&rs->pttport, RIG_PTT_OFF); - gpio_close(&rs->pttport); - } - - break; - case RIG_PTT_GPION: - rs->pttport.fd = gpio_open(&rs->pttport, 1, 0); - + rs->pttport.fd = gpio_open(&rs->pttport, 1, RIG_PTT_GPION == rs->pttport.type.ptt ? 0 : 1); if (rs->pttport.fd < 0) { rig_debug(RIG_DEBUG_ERR, - "%s: cannot open PTT device \"%s\"\n", + "%s: cannot open PTT device \"GPIO%s\"\n", __func__, rs->pttport.pathname); status = -RIG_EIO; @@ -785,29 +766,12 @@ int HAMLIB_API rig_open(RIG *rig) break; case RIG_DCD_GPIO: - rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 1); - - if (rs->dcdport.fd < 0) - { - rig_debug(RIG_DEBUG_ERR, - "%s: cannot open DCD device \"%s\"\n", - __func__, - rs->dcdport.pathname); - status = -RIG_EIO; - } - else { - gpio_close(&rs->dcdport); - } - - break; - case RIG_DCD_GPION: - rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 0); - + rs->dcdport.fd = gpio_open(&rs->dcdport, 0, RIG_DCD_GPION == rs->dcdport.type.dcd ? 0 : 1); if (rs->dcdport.fd < 0) { rig_debug(RIG_DEBUG_ERR, - "%s: cannot open DCD device \"%s\"\n", + "%s: cannot open DCD device \"GPIO%s\"\n", __func__, rs->dcdport.pathname); status = -RIG_EIO; From caed2d73a18bcff88792c3e4340bc0c87f477b0b Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 14:53:04 +0000 Subject: [PATCH 19/20] Improved get PTT state handling in dummy backend --- dummy/dummy.c | 52 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/dummy/dummy.c b/dummy/dummy.c index cb3d479f1..5e5b9b52e 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -33,6 +33,8 @@ #include "hamlib/rig.h" #include "serial.h" #include "parallel.h" +#include "cm108.h" +#include "gpio.h" #include "misc.h" #include "tones.h" #include "idx_builtin.h" @@ -496,29 +498,57 @@ static int dummy_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int dummy_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; + int rc; int status = 0; - ptt_t par_status = RIG_PTT_OFF; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - *ptt = priv->ptt; // sneak a look at the hardware PTT and OR that in with our result // as if it had keyed us switch (rig->state.pttport.type.ptt) { - case RIG_PTT_SERIAL_DTR: if (rig->state.pttport.fd >= 0) ser_get_dtr( - &rig->state.pttport, &status); break; + case RIG_PTT_SERIAL_DTR: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = ser_get_dtr(&rig->state.pttport, &status))) return rc; + *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; + } + break; - case RIG_PTT_SERIAL_RTS: if (rig->state.pttport.fd >= 0) ser_get_rts( - &rig->state.pttport, &status); break; + case RIG_PTT_SERIAL_RTS: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = ser_get_rts(&rig->state.pttport, &status))) return rc; + *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; + } + break; - case RIG_PTT_PARALLEL: if (rig->state.pttport.fd >= 0) par_ptt_get( - &rig->state.pttport, &par_status); break; + case RIG_PTT_PARALLEL: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = par_ptt_get(&rig->state.pttport, ptt))) return rc; + } + break; - default: break; + case RIG_PTT_CM108: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = cm108_ptt_get(&rig->state.pttport, ptt))) return rc; + } + break; + + case RIG_PTT_GPIO: + case RIG_PTT_GPION: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = gpio_ptt_get(&rig->state.pttport, ptt))) return rc; + } + break; + + default: + *ptt = priv->ptt; + break; } - - *ptt = *ptt || status || RIG_PTT_ON == par_status; return RIG_OK; } From e1e6969e9ecd438ea9a28f7418dd4308ace6b0e9 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 19:04:57 +0000 Subject: [PATCH 20/20] Simplify closing of device files By treating PTT/DCD devices differently from rig control devices. --- src/iofunc.c | 15 --------------- src/rig.c | 14 +++++--------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/iofunc.c b/src/iofunc.c index 8f172db6a..81ac515af 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -185,8 +185,6 @@ int HAMLIB_API port_open(hamlib_port_t *p) * \param p rig port descriptor * \param port_type equivalent rig port type * \return status - * - * This function may also be used with ptt and dcd ports. */ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type) { @@ -202,19 +200,6 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type) ret = ser_close(p); break; - case RIG_PORT_PARALLEL: - ret = par_close(p); - break; - - case RIG_PORT_CM108: - ret = cm108_close(p); - break; - - case RIG_PORT_GPIO: - case RIG_PORT_GPION: - ret = gpio_close(p); - break; - case RIG_PORT_USB: ret = usb_port_close(p); break; diff --git a/src/rig.c b/src/rig.c index fc650bd9b..1cd87a2db 100644 --- a/src/rig.c +++ b/src/rig.c @@ -703,7 +703,6 @@ int HAMLIB_API rig_open(RIG *rig) else { gpio_ptt_set(&rs->pttport, RIG_PTT_OFF); - gpio_close(&rs->pttport); } break; @@ -776,9 +775,6 @@ int HAMLIB_API rig_open(RIG *rig) rs->dcdport.pathname); status = -RIG_EIO; } - else { - gpio_close(&rs->dcdport); - } break; @@ -933,18 +929,18 @@ int HAMLIB_API rig_close(RIG *rig) case RIG_PTT_PARALLEL: par_ptt_set(&rs->pttport, RIG_PTT_OFF); - port_close(&rs->pttport, RIG_PORT_PARALLEL); + par_close(&rs->pttport); break; case RIG_PTT_CM108: cm108_ptt_set(&rs->pttport, RIG_PTT_OFF); - port_close(&rs->pttport, RIG_PORT_CM108); + cm108_close(&rs->pttport); break; case RIG_PTT_GPIO: case RIG_PTT_GPION: gpio_ptt_set(&rs->pttport, RIG_PTT_OFF); - port_close(&rs->pttport, RIG_PORT_GPIO); + gpio_close(&rs->pttport); break; default: @@ -971,12 +967,12 @@ int HAMLIB_API rig_close(RIG *rig) break; case RIG_DCD_PARALLEL: - port_close(&rs->dcdport, RIG_PORT_PARALLEL); + par_close(&rs->dcdport); break; case RIG_DCD_GPIO: case RIG_DCD_GPION: - port_close(&rs->dcdport, RIG_PORT_GPIO); + gpio_close(&rs->dcdport); break; default: