diff --git a/NEWS b/NEWS index 9ae6a6253..a47f31cd8 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ Hamlib -- History of visible changes. Copyright (C) 2000-2003 Frank Singleton Copyright (C) 2000-2018 Stephane Fillod, and others +Copyright (C) 2000-2020 Michael Black W9MDB, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net @@ -15,9 +16,12 @@ Version 4.0 * New utility: rigctlcom. Mike, W9MDB * New model: FT847UNI for unidirectional early serial numbers. Mike, W9MDB * Remove GNU Texinfo files and build system dependency. + * Rig model numbers have changed to allow future growth * Fix a lot of static code analysis errors and warnings. Mike, W9MDB * Rearrange directory structure to put rigs and rotators sources under their own subdirectories. Mike, W9MDB + * rig_get_channel changed to add read_only flag + * rigctl(d) f command also returns VFO now Version 3.3 2018-08-12 diff --git a/c++/rigclass.cc b/c++/rigclass.cc index dd5fc98be..40dcfc225 100644 --- a/c++/rigclass.cc +++ b/c++/rigclass.cc @@ -648,9 +648,9 @@ void Rig::setChannel (const channel_t *chan) CHECK_RIG( rig_set_channel(theRig, chan) ); } -void Rig::getChannel (channel_t *chan) +void Rig::getChannel (channel_t *chan, int readOnly) { - CHECK_RIG( rig_get_channel(theRig, chan) ); + CHECK_RIG( rig_get_channel(theRig, chan, readOnly) ); } diff --git a/doc/index.doxygen b/doc/index.doxygen index 742cae0fb..5f08971d0 100644 --- a/doc/index.doxygen +++ b/doc/index.doxygen @@ -3,7 +3,7 @@ \section auth Authors Stéphane Fillod, F8CFE, and Frank Singleton, VK3FCS and the Hamlib Group -\n Documentation revisions by Martin Ewing, AA6E, Nate Bargmann, N0NB +\n Documentation revisions by Martin Ewing, AA6E, Nate Bargmann, N0NB, Michael Black, W9MDB \section s1 Preface diff --git a/dummy/dummy.c b/dummy/dummy.c index f5a25ca50..53d41d73f 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -1712,7 +1712,7 @@ static int dummy_set_channel(RIG *rig, const channel_t *chan) } -static int dummy_get_channel(RIG *rig, channel_t *chan) +static int dummy_get_channel(RIG *rig, channel_t *chan, int read_only) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; diff --git a/dummy/netrigctl.c b/dummy/netrigctl.c index 358f586ab..47aaf469b 100644 --- a/dummy/netrigctl.c +++ b/dummy/netrigctl.c @@ -2022,7 +2022,7 @@ static int netrigctl_set_channel(RIG *rig, const channel_t *chan) } -static int netrigctl_get_channel(RIG *rig, channel_t *chan) +static int netrigctl_get_channel(RIG *rig, channel_t *chan, int read_only) { return -RIG_ENIMPL; } diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 919c1838b..85887c1fa 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1762,7 +1762,7 @@ struct rig_caps { int (*decode_event)(RIG *rig); int (*set_channel)(RIG *rig, const channel_t *chan); - int (*get_channel)(RIG *rig, channel_t *chan); + int (*get_channel)(RIG *rig, channel_t *chan, int read_only); const char * (*get_info)(RIG *rig); @@ -2424,7 +2424,7 @@ rig_set_channel HAMLIB_PARAMS((RIG *rig, const channel_t *chan)); /* mem */ extern HAMLIB_EXPORT(int) rig_get_channel HAMLIB_PARAMS((RIG *rig, - channel_t *chan)); + channel_t *chan, int read_only)); extern HAMLIB_EXPORT(int) rig_set_chan_all HAMLIB_PARAMS((RIG *rig, diff --git a/include/hamlib/rigclass.h b/include/hamlib/rigclass.h index ed8336908..0ac47bf1b 100644 --- a/include/hamlib/rigclass.h +++ b/include/hamlib/rigclass.h @@ -127,7 +127,7 @@ public: int getMem(vfo_t vfo = RIG_VFO_CURR); void setChannel(const channel_t *chan); - void getChannel(channel_t *chan); + void getChannel(channel_t *chan, int readOnly); void setPowerStat(powerstat_t status); powerstat_t getPowerStat(void); diff --git a/rigs/aor/aor.c b/rigs/aor/aor.c index be4626067..db292a807 100644 --- a/rigs/aor/aor.c +++ b/rigs/aor/aor.c @@ -1240,7 +1240,7 @@ static int parse_chan_line(RIG *rig, channel_t *chan, char *basep, } -int aor_get_channel(RIG *rig, channel_t *chan) +int aor_get_channel(RIG *rig, channel_t *chan, int read_only) { struct aor_priv_caps *priv = (struct aor_priv_caps *)rig->caps->priv; char aorcmd[BUFSZ]; @@ -1330,6 +1330,11 @@ int aor_get_channel(RIG *rig, channel_t *chan) retval = parse_chan_line(rig, chan, chanbuf, mem_caps); +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return retval; } diff --git a/rigs/aor/aor.h b/rigs/aor/aor.h index 0bdea8c50..07cdb98af 100644 --- a/rigs/aor/aor.h +++ b/rigs/aor/aor.h @@ -60,7 +60,7 @@ int aor_set_mem(RIG *rig, vfo_t vfo, int ch); int aor_get_mem(RIG *rig, vfo_t vfo, int *ch); int aor_set_bank(RIG *rig, vfo_t vfo, int bank); -int aor_get_channel(RIG *rig, channel_t *chan); +int aor_get_channel(RIG *rig, channel_t *chan, int read_only); int aor_set_channel(RIG *rig, const channel_t *chan); int aor_get_chan_all_cb (RIG * rig, chan_cb_t chan_cb, rig_ptr_t); diff --git a/rigs/aor/ar3030.c b/rigs/aor/ar3030.c index 695caaad2..5adea08ef 100644 --- a/rigs/aor/ar3030.c +++ b/rigs/aor/ar3030.c @@ -45,7 +45,7 @@ static int ar3030_set_mem(RIG *rig, vfo_t vfo, int ch); static int ar3030_get_mem(RIG *rig, vfo_t vfo, int *ch); static int ar3030_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); static int ar3030_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); -static int ar3030_get_channel(RIG *rig, channel_t *chan); +static int ar3030_get_channel(RIG *rig, channel_t *chan, int read_only); static int ar3030_init(RIG *rig); static int ar3030_cleanup(RIG *rig); static int ar3030_close(RIG *rig); @@ -721,7 +721,7 @@ int ar3030_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } -int ar3030_get_channel(RIG *rig, channel_t *chan) +int ar3030_get_channel(RIG *rig, channel_t *chan, int read_only) { struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv; char cmdbuf[BUFSZ], infobuf[BUFSZ]; @@ -805,6 +805,11 @@ int ar3030_get_channel(RIG *rig, channel_t *chan) chan->levels[LVL_AGC].i = infobuf[8] == '0' ? RIG_AGC_SLOW : RIG_AGC_FAST; chan->flags = infobuf[4] == '1' ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE; +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/aor/ar7030p.c b/rigs/aor/ar7030p.c index fcf8e4fd7..89d621613 100644 --- a/rigs/aor/ar7030p.c +++ b/rigs/aor/ar7030p.c @@ -1638,7 +1638,7 @@ static int ar7030p_set_channel(RIG *rig, const channel_t *chan) return (-RIG_ENIMPL); } -static int ar7030p_get_channel(RIG *rig, channel_t *chan) +static int ar7030p_get_channel(RIG *rig, channel_t *chan, int read_only) { int rc = RIG_OK; unsigned char v; @@ -1754,6 +1754,11 @@ static int ar7030p_get_channel(RIG *rig, channel_t *chan) rc = lockRx(rig, LOCK_0); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return (rc); } diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index 8ec5c96a6..c8808dfe0 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -670,7 +670,7 @@ int drake_set_chan(RIG *rig, const channel_t *chan) * drake_get_chan * Assumes rig!=NULL */ -int drake_get_chan(RIG *rig, channel_t *chan) +int drake_get_chan(RIG *rig, channel_t *chan, int read_only) { struct drake_priv_data *priv = rig->state.priv; vfo_t old_vfo; @@ -854,6 +854,7 @@ int drake_get_chan(RIG *rig, channel_t *chan) strncpy(chan->channel_desc, mdbuf + 25, 7); //now put the radio back the way it was + //we apparently can't do a read-only channel read if (old_vfo != RIG_VFO_MEM) { retval = drake_set_vfo(rig, RIG_VFO_VFO); diff --git a/rigs/drake/drake.h b/rigs/drake/drake.h index f044a901c..f46b1560f 100644 --- a/rigs/drake/drake.h +++ b/rigs/drake/drake.h @@ -43,7 +43,7 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_ 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); -int drake_get_chan(RIG *rig, channel_t *chan); +int drake_get_chan(RIG *rig, channel_t *chan, int read_only); int drake_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); int drake_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); int drake_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index d5096ecea..c6953ecff 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -153,7 +153,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_get_channel(RIG *rig, channel_t *chan, int read_only); 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); @@ -904,7 +904,7 @@ int ic746_get_parm(RIG *rig, setting_t parm, value_t *val) * * If memory is empty it will return RIG_OK,but every thing will be null. Where do we boundary check? */ -int ic746pro_get_channel(RIG *rig, channel_t *chan) +int ic746pro_get_channel(RIG *rig, channel_t *chan, int read_only) { struct icom_priv_data *priv; struct rig_state *rs; @@ -1053,6 +1053,11 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) chan->channel_desc); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/icom/icr75.c b/rigs/icom/icr75.c index ef40bcd86..719368391 100644 --- a/rigs/icom/icr75.c +++ b/rigs/icom/icr75.c @@ -92,7 +92,7 @@ } static int icr75_set_channel(RIG *rig, const channel_t *chan); -static int icr75_get_channel(RIG *rig, channel_t *chan); +static int icr75_get_channel(RIG *rig, channel_t *chan, int read_only); int icr75_set_parm(RIG *rig, setting_t parm, value_t val); int icr75_get_parm(RIG *rig, setting_t parm, value_t *val); @@ -319,7 +319,7 @@ int icr75_set_channel(RIG *rig, const channel_t *chan) * Assumes rig!=NULL, rig->state.priv!=NULL, chan!=NULL * TODO: still a WIP --SF */ -int icr75_get_channel(RIG *rig, channel_t *chan) +int icr75_get_channel(RIG *rig, channel_t *chan, int read_only) { struct icom_priv_data *priv; struct rig_state *rs; @@ -416,6 +416,11 @@ int icr75_get_channel(RIG *rig, channel_t *chan) strncpy(chan->channel_desc, (char *)(chanbuf + chan_len), 8); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c index ee242a928..5a6ca0d15 100644 --- a/rigs/jrc/jrc.c +++ b/rigs/jrc/jrc.c @@ -1414,7 +1414,7 @@ int jrc_set_chan(RIG *rig, const channel_t *chan) /* read first to get current values */ current.channel_num = chan->channel_num; - if ((retval = jrc_get_chan(rig, ¤t)) != RIG_OK) { return retval; } + if ((retval = jrc_get_chan(rig, ¤t, 1)) != RIG_OK) { return retval; } sprintf(cmdbuf, "K%03d000", chan->channel_num); @@ -1466,7 +1466,7 @@ int jrc_set_chan(RIG *rig, const channel_t *chan) * jrc_get_chan * Assumes rig!=NULL */ -int jrc_get_chan(RIG *rig, channel_t *chan) +int jrc_get_chan(RIG *rig, channel_t *chan, int read_only) { struct jrc_priv_caps *priv = (struct jrc_priv_caps *)rig->caps->priv; char membuf[BUFSZ], cmdbuf[BUFSZ]; diff --git a/rigs/jrc/jrc.h b/rigs/jrc/jrc.h index 940576b3c..f301ea2f4 100644 --- a/rigs/jrc/jrc.h +++ b/rigs/jrc/jrc.h @@ -55,7 +55,7 @@ int jrc_set_trn(RIG *rig, int trn); int jrc_set_mem(RIG *rig, vfo_t vfo, int ch); int jrc_get_mem(RIG *rig, vfo_t vfo, int *ch); int jrc_set_chan(RIG *rig, const channel_t *chan); -int jrc_get_chan(RIG *rig, channel_t *chan); +int jrc_get_chan(RIG *rig, channel_t *chan, int read_only); int jrc_set_powerstat(RIG *rig, powerstat_t status); int jrc_get_powerstat(RIG *rig, powerstat_t *status); int jrc_reset(RIG *rig, reset_t reset); diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c index f8214fcb7..3e9c912dc 100644 --- a/rigs/kenwood/ic10.c +++ b/rigs/kenwood/ic10.c @@ -634,7 +634,7 @@ int ic10_set_mem(RIG *rig, vfo_t vfo, int ch) } -int ic10_get_channel(RIG *rig, channel_t *chan) +int ic10_get_channel(RIG *rig, channel_t *chan, int read_only) { char membuf[16], infobuf[32]; int retval, info_len, len; @@ -717,6 +717,11 @@ int ic10_get_channel(RIG *rig, channel_t *chan) } } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/ic10.h b/rigs/kenwood/ic10.h index f523a6806..4cc8b1440 100644 --- a/rigs/kenwood/ic10.h +++ b/rigs/kenwood/ic10.h @@ -47,7 +47,7 @@ int ic10_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); int ic10_set_mem(RIG *rig, vfo_t vfo, int ch); int ic10_get_mem(RIG *rig, vfo_t vfo, int *ch); int ic10_set_channel(RIG *rig, const channel_t *chan); -int ic10_get_channel(RIG *rig, channel_t *chan); +int ic10_get_channel(RIG *rig, channel_t *chan, int read_only); int ic10_set_powerstat(RIG *rig, powerstat_t status); int ic10_get_powerstat(RIG *rig, powerstat_t *status); int ic10_set_trn(RIG *rig, int trn); diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 4e27235a4..d19b373d5 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -3744,7 +3744,7 @@ int kenwood_get_mem_if(RIG *rig, vfo_t vfo, int *ch) return RIG_OK; } -int kenwood_get_channel(RIG *rig, channel_t *chan) +int kenwood_get_channel(RIG *rig, channel_t *chan, int read_only) { int err; char buf[26]; @@ -3853,6 +3853,11 @@ int kenwood_get_channel(RIG *rig, channel_t *chan) chan->split = RIG_SPLIT_ON; } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index def3cda2b..8de062c42 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -192,7 +192,7 @@ int kenwood_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); int kenwood_set_mem(RIG *rig, vfo_t vfo, int ch); int kenwood_get_mem(RIG *rig, vfo_t vfo, int *ch); int kenwood_get_mem_if(RIG *rig, vfo_t vfo, int *ch); -int kenwood_get_channel(RIG *rig, channel_t *chan); +int kenwood_get_channel(RIG *rig, channel_t *chan, int read_only); int kenwood_set_channel(RIG *rig, const channel_t *chan); int kenwood_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch); const char *kenwood_get_info(RIG *rig); diff --git a/rigs/kenwood/pihpsdr.c b/rigs/kenwood/pihpsdr.c index 053f867f7..1367161fc 100644 --- a/rigs/kenwood/pihpsdr.c +++ b/rigs/kenwood/pihpsdr.c @@ -64,7 +64,7 @@ static int pihpsdr_open(RIG *rig); static int pihpsdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static int pihpsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); -static int pihspdr_get_channel(RIG *rig, channel_t *chan); +static int pihspdr_get_channel(RIG *rig, channel_t *chan, int read_only); static int pihspdr_set_channel(RIG *rig, const channel_t *chan); @@ -335,7 +335,7 @@ const struct rig_caps pihpsdr_caps = */ -int pihspdr_get_channel(RIG *rig, channel_t *chan) +int pihspdr_get_channel(RIG *rig, channel_t *chan, int read_only) { int err; int tmp; @@ -560,6 +560,11 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan) chan->split = RIG_SPLIT_ON; } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/th.c b/rigs/kenwood/th.c index 470b6989f..c67380055 100644 --- a/rigs/kenwood/th.c +++ b/rigs/kenwood/th.c @@ -1935,7 +1935,7 @@ int th_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) /* get and set channel tested on thg71&thf7e */ /* must work on other th and tm kenwood rigs */ /* --------------------------------------------------------------------- */ -int th_get_channel(RIG *rig, channel_t *chan) +int th_get_channel(RIG *rig, channel_t *chan, int read_only) { char membuf[64], ackbuf[ACKBUF_LEN]; int retval; @@ -2226,6 +2226,11 @@ int th_get_channel(RIG *rig, channel_t *chan) chan->channel_desc[ack_len] = '\0'; } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/th.h b/rigs/kenwood/th.h index d09035521..a8346cf1a 100644 --- a/rigs/kenwood/th.h +++ b/rigs/kenwood/th.h @@ -60,7 +60,7 @@ extern int th_get_mem(RIG *rig, vfo_t vfo, int *ch); extern int th_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); 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_get_channel(RIG *rig, channel_t *chan, int read_only); extern int th_set_channel(RIG *rig, const channel_t *chan); 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 dummy, value_t *option, ant_t * ant_curr, ant_t *ant_tx, ant_t *ant_rx); diff --git a/rigs/kenwood/thd72.c b/rigs/kenwood/thd72.c index 4226bc365..6eeb5633d 100644 --- a/rigs/kenwood/thd72.c +++ b/rigs/kenwood/thd72.c @@ -1358,7 +1358,7 @@ static int thd72_parse_channel(int kind, const char *buf, channel_t *chan) return RIG_OK; } -static int thd72_get_channel(RIG *rig, channel_t *chan) +static int thd72_get_channel(RIG *rig, channel_t *chan, int read_only) { int retval; char buf[72]; @@ -1407,6 +1407,11 @@ static int thd72_get_channel(RIG *rig, channel_t *chan) return thd72_parse_channel(0, buf, chan); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/thd74.c b/rigs/kenwood/thd74.c index 8307642c0..6bedae71e 100644 --- a/rigs/kenwood/thd74.c +++ b/rigs/kenwood/thd74.c @@ -1275,7 +1275,7 @@ static int thd74_parse_channel(int kind, const char *buf, channel_t *chan) return RIG_OK; } -static int thd74_get_channel(RIG *rig, channel_t *chan) +static int thd74_get_channel(RIG *rig, channel_t *chan, int read_only) { int retval; char buf[72]; @@ -1324,6 +1324,11 @@ static int thd74_get_channel(RIG *rig, channel_t *chan) return thd74_parse_channel(0, buf, chan); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/tmd710.c b/rigs/kenwood/tmd710.c index 55cd13697..b1d013f97 100644 --- a/rigs/kenwood/tmd710.c +++ b/rigs/kenwood/tmd710.c @@ -71,7 +71,7 @@ static int tmd710_set_mem(RIG *rig, vfo_t vfo, int ch); static int tmd710_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code); static int tmd710_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code); static int tmd710_set_channel(RIG *rig, const channel_t *chan); -static int tmd710_get_channel(RIG *rig, channel_t *chan); +static int tmd710_get_channel(RIG *rig, channel_t *chan, int read_only); static int tmd710_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int tmd710_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); static int tmd710_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); @@ -1833,7 +1833,7 @@ int tmd710_set_mem(RIG *rig, vfo_t vfo, int ch) return kenwood_safe_transaction(rig, cmd, membuf, sizeof(membuf), 8); } -int tmd710_get_channel(RIG *rig, channel_t *chan) +int tmd710_get_channel(RIG *rig, channel_t *chan, int read_only) { int retval; tmd710_me me_struct; @@ -1933,6 +1933,11 @@ int tmd710_get_channel(RIG *rig, channel_t *chan) // TODO: chan->levels chan->ext_levels = NULL; +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/kenwood/tmv7.c b/rigs/kenwood/tmv7.c index 20aa3702a..4e424ab23 100644 --- a/rigs/kenwood/tmv7.c +++ b/rigs/kenwood/tmv7.c @@ -87,7 +87,7 @@ static int tmv7_decode_event(RIG *rig); static int tmv7_set_vfo(RIG *rig, vfo_t vfo); static int tmv7_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); static int tmv7_get_powerstat(RIG *rig, powerstat_t *status); -static int tmv7_get_channel(RIG *rig, channel_t *chan); +static int tmv7_get_channel(RIG *rig, channel_t *chan, int read_only); static int tmv7_set_channel(RIG *rig, const channel_t *chan); /* @@ -496,7 +496,7 @@ int tmv7_get_powerstat(RIG *rig, powerstat_t *status) /* --------------------------------------------------------------------- */ -int tmv7_get_channel(RIG *rig, channel_t *chan) +int tmv7_get_channel(RIG *rig, channel_t *chan, int read_only) { char membuf[64], ackbuf[ACKBUF_LEN]; int retval; @@ -649,6 +649,11 @@ int tmv7_get_channel(RIG *rig, channel_t *chan) memcpy(chan->channel_desc, &ackbuf[10], 7); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } /* --------------------------------------------------------------------- */ diff --git a/rigs/kenwood/ts2000.c b/rigs/kenwood/ts2000.c index 00042cecf..36c933bf5 100644 --- a/rigs/kenwood/ts2000.c +++ b/rigs/kenwood/ts2000.c @@ -58,7 +58,7 @@ /* prototypes */ static int ts2000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); -static int ts2000_get_channel(RIG *rig, channel_t *chan); +static int ts2000_get_channel(RIG *rig, channel_t *chan, int read_only); static int ts2000_set_channel(RIG *rig, const channel_t *chan); /* @@ -368,7 +368,7 @@ const struct rig_caps ts2000_caps = */ -int ts2000_get_channel(RIG *rig, channel_t *chan) +int ts2000_get_channel(RIG *rig, channel_t *chan, int read_only) { int err; int tmp; @@ -593,6 +593,11 @@ int ts2000_get_channel(RIG *rig, channel_t *chan) chan->split = RIG_SPLIT_ON; } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c index 30c8121f1..0eab18513 100644 --- a/rigs/prm80/prm80.c +++ b/rigs/prm80/prm80.c @@ -201,7 +201,7 @@ int prm80_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) memset(&chan, 0, sizeof(chan)); chan.vfo = RIG_VFO_CURR; - ret = prm80_get_channel(rig, &chan); + ret = prm80_get_channel(rig, &chan, 0); if (ret != RIG_OK) { @@ -246,7 +246,7 @@ int prm80_get_mem(RIG *rig, vfo_t vfo, int *ch) memset(&chan, 0, sizeof(chan)); chan.vfo = RIG_VFO_CURR; - ret = prm80_get_channel(rig, &chan); + ret = prm80_get_channel(rig, &chan, 0); if (ret != RIG_OK) { @@ -276,7 +276,7 @@ static int hhtoi(const char *p) * prm80_get_channel * Assumes rig!=NULL */ -int prm80_get_channel(RIG *rig, channel_t *chan) +int prm80_get_channel(RIG *rig, channel_t *chan, int read_only) { char statebuf[BUFSZ]; int statebuf_len = BUFSZ; @@ -329,6 +329,11 @@ int prm80_get_channel(RIG *rig, channel_t *chan) chan->tx_freq = ((hhtoi(statebuf + 16) << 8) + hhtoi(statebuf + 18)) * 12500; chan->rptr_offs = chan->tx_freq - chan->freq; +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } @@ -421,7 +426,7 @@ int prm80_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) memset(&chan, 0, sizeof(chan)); chan.vfo = RIG_VFO_CURR; - ret = prm80_get_channel(rig, &chan); + ret = prm80_get_channel(rig, &chan, 1); if (ret != RIG_OK) { diff --git a/rigs/prm80/prm80.h b/rigs/prm80/prm80.h index 28e80452b..33a82f174 100644 --- a/rigs/prm80/prm80.h +++ b/rigs/prm80/prm80.h @@ -43,7 +43,7 @@ int prm80_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); int prm80_set_mem (RIG *rig, vfo_t vfo, int ch); int prm80_get_mem (RIG *rig, vfo_t vfo, int *ch); int prm80_set_channel(RIG * rig, const channel_t * chan); -int prm80_get_channel(RIG * rig, channel_t * chan); +int prm80_get_channel(RIG * rig, channel_t * chan, int read_only); const char* prm80_get_info(RIG *rig); diff --git a/rigs/uniden/uniden.c b/rigs/uniden/uniden.c index 75b84339b..3153ecf3f 100644 --- a/rigs/uniden/uniden.c +++ b/rigs/uniden/uniden.c @@ -561,7 +561,7 @@ int uniden_get_mem(RIG *rig, vfo_t vfo, int *ch) * uniden_get_channel * Assumes rig!=NULL */ -int uniden_get_channel(RIG *rig, channel_t *chan) +int uniden_get_channel(RIG *rig, channel_t *chan, int read_only) { char cmdbuf[BUFSZ], membuf[BUFSZ]; size_t cmd_len = BUFSZ, mem_len = BUFSZ; @@ -641,6 +641,11 @@ int uniden_get_channel(RIG *rig, channel_t *chan) strncpy(chan->channel_desc, membuf + 9, rig->caps->chan_desc_sz); } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/uniden/uniden.h b/rigs/uniden/uniden.h index 12801e877..2212dbc58 100644 --- a/rigs/uniden/uniden.h +++ b/rigs/uniden/uniden.h @@ -65,7 +65,7 @@ int uniden_get_mem(RIG *rig, vfo_t vfo, int *ch); int uniden_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); int uniden_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); int uniden_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); -int uniden_get_channel(RIG *rig, channel_t *chan); +int uniden_get_channel(RIG *rig, channel_t *chan, int read_only); int uniden_set_channel(RIG *rig, const channel_t *chan); const char* uniden_get_info(RIG *rig); diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 8b40e86bb..d57ab4321 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -2715,7 +2715,7 @@ int ft1000d_set_channel(RIG *rig, const channel_t *chan) * Status for split operation, active rig functions and tuning steps * are only relevant for currVFO */ -int ft1000d_get_channel(RIG *rig, channel_t *chan) +int ft1000d_get_channel(RIG *rig, channel_t *chan, int read_only) { struct ft1000d_priv_data *priv; ft1000d_op_data_t *p; @@ -3168,6 +3168,11 @@ int ft1000d_get_channel(RIG *rig, channel_t *chan) chan->flags |= RIG_CHFLAG_SKIP; } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/yaesu/ft1000d.h b/rigs/yaesu/ft1000d.h index 40971b458..65d8f792c 100644 --- a/rigs/yaesu/ft1000d.h +++ b/rigs/yaesu/ft1000d.h @@ -194,7 +194,7 @@ int ft1000d_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); int ft1000d_set_mem(RIG *rig, vfo_t vfo, int ch); int ft1000d_get_mem(RIG *rig, vfo_t vfo, int *ch); int ft1000d_set_channel (RIG *rig, const channel_t *chan); -int ft1000d_get_channel (RIG *rig, channel_t *chan); +int ft1000d_get_channel (RIG *rig, channel_t *chan, int read_only); /* diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index b7c4f0132..828fdbafc 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -2664,7 +2664,7 @@ int ft990_set_channel(RIG *rig, const channel_t *chan) * Status for split operation, active rig functions and tuning steps * are only relevant for currVFO */ -int ft990_get_channel(RIG *rig, channel_t *chan) +int ft990_get_channel(RIG *rig, channel_t *chan, int read_only) { struct ft990_priv_data *priv; ft990_op_data_t *p; @@ -3115,6 +3115,11 @@ int ft990_get_channel(RIG *rig, channel_t *chan) chan->flags |= RIG_CHFLAG_SKIP; } +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/yaesu/ft990.h b/rigs/yaesu/ft990.h index bd82dcda6..159237594 100644 --- a/rigs/yaesu/ft990.h +++ b/rigs/yaesu/ft990.h @@ -176,7 +176,7 @@ int ft990_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); int ft990_set_mem(RIG *rig, vfo_t vfo, int ch); int ft990_get_mem(RIG *rig, vfo_t vfo, int *ch); int ft990_set_channel (RIG *rig, const channel_t *chan); -int ft990_get_channel (RIG *rig, channel_t *chan); +int ft990_get_channel (RIG *rig, channel_t *chan, int read_only); /* diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 753391180..bfb2b92e9 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -3992,7 +3992,7 @@ int newcat_set_mem(RIG *rig, vfo_t vfo, int ch) /* Test for valid usable channel, skip if empty */ memset(&valid_chan, 0, sizeof(channel_t)); valid_chan.channel_num = ch; - err = newcat_get_channel(rig, &valid_chan); + err = newcat_get_channel(rig, &valid_chan, 1); if (err < 0) { @@ -4460,7 +4460,7 @@ int newcat_set_channel(RIG *rig, const channel_t *chan) } -int newcat_get_channel(RIG *rig, channel_t *chan) +int newcat_get_channel(RIG *rig, channel_t *chan, int read_only) { struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; char *retval; @@ -4636,6 +4636,11 @@ int newcat_get_channel(RIG *rig, channel_t *chan) retval = priv->ret_data + 5; chan->freq = atof(retval); +#warning Need to add setting rig to channel values + if (!read_only) { + // Set rig to channel values + } + return RIG_OK; } diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 7cb305eec..8edc1377e 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -177,6 +177,6 @@ int newcat_get_ts(RIG * rig, vfo_t vfo, shortfreq_t * ts); int newcat_set_trn(RIG * rig, int trn); int newcat_get_trn(RIG * rig, int *trn); int newcat_set_channel(RIG * rig, const channel_t * chan); -int newcat_get_channel(RIG * rig, channel_t * chan); +int newcat_get_channel(RIG * rig, channel_t * chan, int read_only); #endif /* _NEWCAT_H */ diff --git a/src/mem.c b/src/mem.c index b389fe11a..c698c7abc 100644 --- a/src/mem.c +++ b/src/mem.c @@ -693,9 +693,6 @@ int HAMLIB_API rig_set_channel(RIG *rig, const channel_t *chan) vfo_t vfo; /* requested vfo */ int retcode; int can_emulate_by_vfo_mem, can_emulate_by_vfo_op; -#ifdef PARANOID_CHANNEL_HANDLING - channel_t curr_chan; -#endif rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -745,10 +742,6 @@ int HAMLIB_API rig_set_channel(RIG *rig, const channel_t *chan) } curr_vfo = rig->state.current_vfo; - /* may be needed if the restore_channel has some side effects */ -#ifdef PARANOID_CHANNEL_HANDLING - generic_save_channel(rig, &curr_chan); -#endif if (vfo == RIG_VFO_MEM) { @@ -793,9 +786,6 @@ int HAMLIB_API rig_set_channel(RIG *rig, const channel_t *chan) rig_set_vfo(rig, curr_vfo); } -#ifdef PARANOID_CHANNEL_HANDLING - generic_restore_channel(rig, &curr_chan); -#endif return retcode; } @@ -804,6 +794,7 @@ int HAMLIB_API rig_set_channel(RIG *rig, const channel_t *chan) * \brief get channel data * \param rig The rig handle * \param chan The location where to store the channel data + * \param read_only if true chan info will be filled but rig will not change, if false rig will update to chan info * * Retrieves the data associated with a channel. This channel can either * be the state of a VFO specified by \a chan->vfo, or a memory channel @@ -817,6 +808,7 @@ int HAMLIB_API rig_set_channel(RIG *rig, const channel_t *chan) chan->vfo = RIG_VFO_MEM; chan->channel_num = 10; + char->read_only = 1; err = rig_get_channel(rig, &chan); if (err != RIG_OK) error("get_channel failed: %s", rigerror(err)); @@ -837,17 +829,14 @@ int HAMLIB_API rig_set_channel(RIG *rig, const channel_t *chan) * * \sa rig_set_channel() */ -int HAMLIB_API rig_get_channel(RIG *rig, channel_t *chan) +int HAMLIB_API rig_get_channel(RIG *rig, channel_t *chan, int read_only) { struct rig_caps *rc; int curr_chan_num, get_mem_status = RIG_OK; vfo_t curr_vfo; vfo_t vfo; /* requested vfo */ - int retcode; + int retcode = RIG_OK; int can_emulate_by_vfo_mem, can_emulate_by_vfo_op; -#ifdef PARANOID_CHANNEL_HANDLING - channel_t curr_chan; -#endif rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -864,7 +853,7 @@ int HAMLIB_API rig_get_channel(RIG *rig, channel_t *chan) if (rc->get_channel) { - return rc->get_channel(rig, chan); + return rc->get_channel(rig, chan, 0); } /* @@ -897,57 +886,54 @@ int HAMLIB_API rig_get_channel(RIG *rig, channel_t *chan) } curr_vfo = rig->state.current_vfo; - /* may be needed if the restore_channel has some side effects */ -#ifdef PARANOID_CHANNEL_HANDLING - generic_save_channel(rig, &curr_chan); -#endif if (vfo == RIG_VFO_MEM) { get_mem_status = rig_get_mem(rig, RIG_VFO_CURR, &curr_chan_num); } - if (can_emulate_by_vfo_mem && curr_vfo != vfo) + if (!read_only) { - retcode = rig_set_vfo(rig, vfo); - - if (retcode != RIG_OK) + if (can_emulate_by_vfo_mem && curr_vfo != vfo) { - return retcode; + retcode = rig_set_vfo(rig, vfo); + + if (retcode != RIG_OK) + { + return retcode; + } } - } - if (vfo == RIG_VFO_MEM) - { - rig_set_mem(rig, RIG_VFO_CURR, chan->channel_num); - } - - if (!can_emulate_by_vfo_mem && can_emulate_by_vfo_op) - { - retcode = rig_vfo_op(rig, RIG_VFO_CURR, RIG_OP_TO_VFO); - - if (retcode != RIG_OK) + if (vfo == RIG_VFO_MEM) { - return retcode; + rig_set_mem(rig, RIG_VFO_CURR, chan->channel_num); } + + if (!can_emulate_by_vfo_mem && can_emulate_by_vfo_op) + { + retcode = rig_vfo_op(rig, RIG_VFO_CURR, RIG_OP_TO_VFO); + + if (retcode != RIG_OK) + { + return retcode; + } + } + + retcode = generic_save_channel(rig, chan); + + /* restore current memory number */ + if (vfo == RIG_VFO_MEM && get_mem_status == RIG_OK) + { + rig_set_mem(rig, RIG_VFO_CURR, curr_chan_num); + } + + if (can_emulate_by_vfo_mem) + { + rig_set_vfo(rig, curr_vfo); + } + } - retcode = generic_save_channel(rig, chan); - - /* restore current memory number */ - if (vfo == RIG_VFO_MEM && get_mem_status == RIG_OK) - { - rig_set_mem(rig, RIG_VFO_CURR, curr_chan_num); - } - - if (can_emulate_by_vfo_mem) - { - rig_set_vfo(rig, curr_vfo); - } - -#ifdef PARANOID_CHANNEL_HANDLING - generic_restore_channel(rig, &curr_chan); -#endif return retcode; } @@ -991,7 +977,7 @@ int get_chan_all_cb_generic(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg) /* * TODO: if doesn't have rc->get_channel, special generic */ - retval = rig_get_channel(rig, chan); + retval = rig_get_channel(rig, chan, 1); if (retval == -RIG_ENAVAIL) { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 3f1631b21..34fd1a118 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -3595,7 +3595,7 @@ declare_proto_rig(get_channel) chan.channel_num = 0; } - status = rig_get_channel(rig, &chan); + status = rig_get_channel(rig, &chan, 0); if (status != RIG_OK) {