From 4a65bddb7e17d30bf16f9ff1d629bcf24b462124 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Thu, 21 Mar 2019 09:28:59 -0500 Subject: [PATCH 01/17] Add set/get powerstat for ic785x.c --- icom/ic785x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/icom/ic785x.c b/icom/ic785x.c index 28cadf333..eff87b498 100644 --- a/icom/ic785x.c +++ b/icom/ic785x.c @@ -88,9 +88,9 @@ const struct rig_caps ic785x_caps = { .rig_model = RIG_MODEL_IC785x, .model_name = "IC-785x", .mfg_name = "Icom", -.version = BACKEND_VER ".1", +.version = BACKEND_VER ".2", .copyright = "LGPL", -.status = RIG_STATUS_ALPHA, +.status = RIG_STATUS_BETA, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_RIG, @@ -232,5 +232,7 @@ const struct rig_caps ic785x_caps = { .get_split_mode = icom_get_split_mode, .set_split_vfo = icom_set_split_vfo, .get_split_vfo = icom_mem_get_split_vfo, +.set_powerstat = icom_set_powerstat, +.get_powerstat = icom_get_powerstat, }; From 03b4c0912e8c6800d05a6b7898937f6a27ecea16 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Sat, 23 Mar 2019 22:32:33 -0500 Subject: [PATCH 02/17] Have kenwood set_powerstat ON wait for get_powerstat --- kenwood/kenwood.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index b82c56372..9ffc57f96 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -2796,7 +2796,18 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status) if (!rig) return -RIG_EINVAL; - return kenwood_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", NULL, 0); + int retval = kenwood_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", NULL, 0); + + if (retval == RIG_OK && status==RIG_POWER_ON) { // wait for wakeup only + for(int i=0;i<15;++i) { // up to 15 seconds + sleep(1); + powerstat_t status; + retval = kenwood_get_powerstat(rig, &status); + if (retval == RIG_OK) return retval; + rig_debug(RIG_DEBUG_TRACE,"Wait %d of 15 for powerstatus\n",i+1); + } + } + return retval; } /* From 40519ef2d80786506c44066d87c7831ef5150056 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Mon, 25 Mar 2019 15:47:15 -0500 Subject: [PATCH 03/17] Fix set_powerstat wait loop --- kenwood/kenwood.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index 9ffc57f96..e45459d60 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -2798,16 +2798,21 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status) int retval = kenwood_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", NULL, 0); - if (retval == RIG_OK && status==RIG_POWER_ON) { // wait for wakeup only - for(int i=0;i<15;++i) { // up to 15 seconds + int i=0; + if (status==RIG_POWER_ON) { // wait for wakeup only + for(i=0;i<15;++i) { // up to 15 seconds sleep(1); powerstat_t status; retval = kenwood_get_powerstat(rig, &status); if (retval == RIG_OK) return retval; - rig_debug(RIG_DEBUG_TRACE,"Wait %d of 15 for powerstatus\n",i+1); + rig_debug(RIG_DEBUG_TRACE,"%s: Wait %d of 15 for get_powerstat\n",__func__,i+1); } } - return retval; + if (i==15) { + rig_debug(RIG_DEBUG_TRACE,"%s: Wait for get_powerstat\n",__func__,i+1); + retval = -RIG_ETIMEOUT; + } + return retval; } /* From e17c013a15980f689598d6c8dc908a9ca90c9768 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 26 Mar 2019 07:24:31 -0500 Subject: [PATCH 04/17] Bump version for kenwood.c --- kenwood/kenwood.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kenwood/kenwood.h b/kenwood/kenwood.h index 53825fc42..7a8b0a9c0 100644 --- a/kenwood/kenwood.h +++ b/kenwood/kenwood.h @@ -27,7 +27,7 @@ #include #include "token.h" -#define BACKEND_VER "1.1" +#define BACKEND_VER "1.2" #define EOM_KEN ';' #define EOM_TH '\r' From aa055a23be649baba6e4ca06e7b13a25248fb79d Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 26 Mar 2019 15:46:24 -0500 Subject: [PATCH 05/17] Add wait for set_powerstat in icom.c --- icom/icom.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/icom/icom.c b/icom/icom.c index c1a6fcaea..9e621eaa2 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -3294,10 +3294,26 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) ackbuf, &ack_len); retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); + rig_debug(RIG_DEBUG_VERBOSE, "%s #2 called retval=%d\n", __func__,retval); + int i=0; + if (status==RIG_POWER_ON) { // wait for wakeup only + for(i=0;i<15;++i) { // up to 15 seconds + sleep(1); + powerstat_t status; + retval = rig_get_powerstat(rig, &status); + if (retval == RIG_OK) return retval; + rig_debug(RIG_DEBUG_TRACE,"%s: Wait %d of 15 for get_powerstat\n",__func__,i+1); + } + } + if (i==15) { + rig_debug(RIG_DEBUG_TRACE,"%s: Wait for get_powerstat\n",__func__,i+1); + retval = -RIG_ETIMEOUT; + } + if (retval != RIG_OK) return retval; - if (ack_len != 1 || ackbuf[0] != ACK) { + if (status==RIG_POWER_OFF && (ack_len != 1 || ackbuf[0] != ACK)) { rig_debug(RIG_DEBUG_ERR,"icom_set_powerstat: ack NG (%#.2x), " "len=%d\n", ackbuf[0],ack_len); return -RIG_ERJCTED; From fbdc494c5bdb0cf05ba9f7b219b4f787269463e0 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Wed, 27 Mar 2019 14:25:46 -0500 Subject: [PATCH 06/17] Change powerstat to wait for get_freq as this is generic to all --- icom/icom.c | 5 +++-- kenwood/kenwood.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/icom/icom.c b/icom/icom.c index 9e621eaa2..b267952eb 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -3299,8 +3299,9 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) if (status==RIG_POWER_ON) { // wait for wakeup only for(i=0;i<15;++i) { // up to 15 seconds sleep(1); - powerstat_t status; - retval = rig_get_powerstat(rig, &status); + freq_t freq = 0; + // Use get_freq as all rigs should repond to this + retval = rig_get_freq(rig, RIG_VFO_A, &freq); if (retval == RIG_OK) return retval; rig_debug(RIG_DEBUG_TRACE,"%s: Wait %d of 15 for get_powerstat\n",__func__,i+1); } diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index e45459d60..c2cdc7969 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -2802,14 +2802,14 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status) if (status==RIG_POWER_ON) { // wait for wakeup only for(i=0;i<15;++i) { // up to 15 seconds sleep(1); - powerstat_t status; - retval = kenwood_get_powerstat(rig, &status); + freq_t freq; + retval = rig_get_freq(rig, RIG_VFO_A, &freq); if (retval == RIG_OK) return retval; - rig_debug(RIG_DEBUG_TRACE,"%s: Wait %d of 15 for get_powerstat\n",__func__,i+1); + rig_debug(RIG_DEBUG_TRACE,"%s: Wait %d of 15 for power up\n",__func__,i+1); } } if (i==15) { - rig_debug(RIG_DEBUG_TRACE,"%s: Wait for get_powerstat\n",__func__,i+1); + rig_debug(RIG_DEBUG_TRACE,"%s: timeout waiting for powerup\n",__func__,i+1); retval = -RIG_ETIMEOUT; } return retval; From c6f9e07711fcc27496250e94ae2992acfed2be8e Mon Sep 17 00:00:00 2001 From: Michael Black Date: Fri, 29 Mar 2019 11:52:42 -0500 Subject: [PATCH 07/17] cache timeout when swapping vfos on ft817 and ft897 --- yaesu/ft817.c | 1 + yaesu/ft897.c | 1 + 2 files changed, 2 insertions(+) diff --git a/yaesu/ft817.c b/yaesu/ft817.c index 8b236b68d..95afcd5a6 100644 --- a/yaesu/ft817.c +++ b/yaesu/ft817.c @@ -1114,6 +1114,7 @@ int ft817_vfo_op (RIG *rig, vfo_t vfo, vfo_op_t op) switch (op) { case RIG_OP_TOGGLE: + rig_force_cache_timeout(&((struct ft817_priv_data *)rig->state.priv)->fm_status_tv); return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB); default: diff --git a/yaesu/ft897.c b/yaesu/ft897.c index cd091ca68..d9c08f5c3 100644 --- a/yaesu/ft897.c +++ b/yaesu/ft897.c @@ -847,6 +847,7 @@ int ft897_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) switch (op) { case RIG_OP_TOGGLE: + rig_force_cache_timeout(&((struct ft897_priv_data *) rig->state.priv)->tx_status_tv); index = FT897_NATIVE_CAT_SET_VFOAB; break; default: From 9570d6c6694ccc13e32dba8acebfcc64b058ec6a Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 2 Apr 2019 08:49:56 -0500 Subject: [PATCH 08/17] Add flush to serial open --- src/serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/serial.c b/src/serial.c index c4e384af7..14f5e4959 100644 --- a/src/serial.c +++ b/src/serial.c @@ -194,6 +194,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp) CLOSE(fd); return err; } + serial_flush(rp); // ensure nothing is there when we open return RIG_OK; } From 3417acdbb77b94f63f9aa61e49f0e4d7c0f2a33d Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 2 Apr 2019 08:51:32 -0500 Subject: [PATCH 09/17] Add set/get vfo to ft857 --- yaesu/ft857.c | 32 ++++++++++++++++++++++++++++++-- yaesu/ft857.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/yaesu/ft857.c b/yaesu/ft857.c index 50d44bf5a..651b0e334 100755 --- a/yaesu/ft857.c +++ b/yaesu/ft857.c @@ -150,9 +150,9 @@ const struct rig_caps ft857_caps = { .rig_model = RIG_MODEL_FT857, .model_name = "FT-857", .mfg_name = "Yaesu", - .version = "0.5", + .version = "0.6", .copyright = "LGPL", - .status = RIG_STATUS_BETA, + .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_RIG, @@ -259,6 +259,8 @@ const struct rig_caps ft857_caps = { .rig_cleanup = ft857_cleanup, .rig_open = ft857_open, .rig_close = ft857_close, + .get_vfo = ft857_get_vfo, + .set_vfo = ft857_set_vfo, .set_freq = ft857_set_freq, .get_freq = ft857_get_freq, .set_mode = ft857_set_mode, @@ -495,6 +497,32 @@ static int ft857_send_icmd(RIG *rig, int index, unsigned char *data) /* ---------------------------------------------------------------------- */ +int ft857_get_vfo(RIG *rig, vfo_t *vfo) +{ + unsigned char c; + int n; + *vfo = RIG_VFO_B; + if ((n = ft857_read_eeprom(rig, 0x0068, &c)) < 0) { /* get vfo status */ + return -RIG_EPROTO; + } + if ((c&0x1)==0) *vfo = RIG_VFO_A; + return RIG_OK; +} + +int ft857_set_vfo(RIG *rig, vfo_t vfo) +{ + vfo_t curvfo; + int retval = ft857_get_vfo(rig,&curvfo); + if (retval != RIG_OK) { + rig_debug(RIG_DEBUG_ERR,"%s: error get_vfo '%s'\n",__func__,rigerror(retval)); + return retval; + } + if (curvfo == vfo) { + return RIG_OK; + } + return ft857_send_cmd(rig, FT857_NATIVE_CAT_SET_VFOAB); +} + int ft857_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv; diff --git a/yaesu/ft857.h b/yaesu/ft857.h index c4d754065..cc798bce3 100644 --- a/yaesu/ft857.h +++ b/yaesu/ft857.h @@ -139,6 +139,8 @@ static int ft857_init(RIG *rig); static int ft857_open(RIG *rig); static int ft857_cleanup(RIG *rig); static int ft857_close(RIG *rig); +static int ft857_set_vfo(RIG *rig, vfo_t vfo); +static int ft857_get_vfo(RIG *rig, vfo_t *vfo); static int ft857_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft857_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int ft857_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); From dbcaee4b77cb5760da3dc1efd9dd1dafd9753ed8 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Wed, 3 Apr 2019 09:13:08 -0500 Subject: [PATCH 10/17] Improved set_powerstat for icom & kenwood --- icom/icom.c | 13 +++++++------ icom/icom.h | 2 +- kenwood/kenwood.c | 9 +++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/icom/icom.c b/icom/icom.c index b267952eb..98895a9e8 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -3273,7 +3273,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) unsigned char fe_buf[200]; // for FE's to power up int fe_len = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called status=\n", __func__,status); switch (status) { case RIG_POWER_ON: pwr_sc = RIG_POWER_ON; @@ -3289,25 +3289,26 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) } // we can ignore this retval - // sending more than enough 0xfe's to take up the rs232 + // sending more than enough 0xfe's to wake up the rs232 icom_transaction(rig, 0xfe, 0xfe, fe_buf, fe_len, ackbuf, &ack_len); retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); rig_debug(RIG_DEBUG_VERBOSE, "%s #2 called retval=%d\n", __func__,retval); int i=0; + int retry = 3/rig->state.rigport.retry; if (status==RIG_POWER_ON) { // wait for wakeup only - for(i=0;i<15;++i) { // up to 15 seconds + for(i=0;i #endif -#define BACKEND_VER "0.8" +#define BACKEND_VER "0.9" /* * defines used by comp_cal_str in rig.c diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index c2cdc7969..3196af7fc 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -2791,7 +2791,7 @@ int kenwood_get_trn(RIG *rig, int *trn) */ int kenwood_set_powerstat(RIG *rig, powerstat_t status) { - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called status=%d\n", __func__, status); if (!rig) return -RIG_EINVAL; @@ -2799,16 +2799,17 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status) int retval = kenwood_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", NULL, 0); int i=0; + int retry=3/rig->state.rigport.retry; if (status==RIG_POWER_ON) { // wait for wakeup only - for(i=0;i<15;++i) { // up to 15 seconds + for(i=0;i Date: Sat, 6 Apr 2019 13:59:25 -0500 Subject: [PATCH 11/17] Add IC-9700 to ic7300.c --- icom/ic7300.c | 176 +++++++++++++++++++++++++++++++++++++++ icom/icom.c | 1 + icom/icom.h | 1 + include/bandplan.h | 3 + include/hamlib/riglist.h | 3 +- 5 files changed, 183 insertions(+), 1 deletion(-) diff --git a/icom/ic7300.c b/icom/ic7300.c index e68ad16e4..44970d7bb 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -285,6 +285,182 @@ const struct rig_caps ic7300_caps = { }; +const struct rig_caps ic9700_caps = { +.rig_model = RIG_MODEL_IC9700, +.model_name = "IC-9700", +.mfg_name = "Icom", +.version = BACKEND_VER ".1a", +.copyright = "LGPL", +.status = RIG_STATUS_ALPHA, +.rig_type = RIG_TYPE_TRANSCEIVER, +.ptt_type = RIG_PTT_RIG, +.dcd_type = RIG_DCD_RIG, +.port_type = RIG_PORT_SERIAL, +.serial_rate_min = 4800, +.serial_rate_max = 38400, +.serial_data_bits = 8, +.serial_stop_bits = 1, +.serial_parity = RIG_PARITY_NONE, +.serial_handshake = RIG_HANDSHAKE_NONE, +.write_delay = 0, +.post_write_delay = 0, +.timeout = 1000, +.retry = 3, +.has_get_func = IC7300_FUNCS, +.has_set_func = IC7300_FUNCS, +.has_get_level = IC7300_LEVELS, +.has_set_level = RIG_LEVEL_SET(IC7300_LEVELS), +.has_get_parm = IC7300_PARMS, +.has_set_parm = RIG_PARM_SET(IC7300_PARMS), +.level_gran = { + [LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } }, +}, +.parm_gran = {}, +.extlevels = ic7300_ext_levels, +.ctcss_list = full_ctcss_list, +.dcs_list = NULL, +.preamp = { 1, 2, RIG_DBLST_END, }, +.attenuator = { 1, RIG_DBLST_END, }, /* value taken from p.45 of manual*/ +.max_rit = Hz(9999), +.max_xit = Hz(9999), +.max_ifshift = Hz(0), +.targetable_vfo = 0, +.vfo_ops = IC7300_VFO_OPS, +.scan_ops = IC7300_SCAN_OPS, +.transceive = RIG_TRN_RIG, +.bank_qty = 1, +.chan_desc_sz = 0, + +.chan_list = { + { 1, 99, RIG_MTYPE_MEM }, + { 100, 101, RIG_MTYPE_EDGE }, /* two by two */ + RIG_CHAN_END, + }, + +.rx_range_list1 = { {kHz(30),MHz(74.8),IC7300_ALL_RX_MODES,-1,-1,IC7300_VFOS}, RIG_FRNG_END, }, +.tx_range_list1 = { + FRQ_RNG_HF(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_60m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_6m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_4m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_HF(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_60m(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_6m(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_4m(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_2m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_70cm(1,IC7300_OTHER_TX_MODES, W(2),W(75),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_23cm(1,IC7300_OTHER_TX_MODES, W(2),W(23),IC7300_VFOS,RIG_ANT_3), + RIG_FRNG_END, }, + +.rx_range_list2 = { {kHz(30),MHz(74.8),IC7300_ALL_RX_MODES,-1,-1,IC7300_VFOS}, RIG_FRNG_END, }, +.tx_range_list2 = { + FRQ_RNG_HF(2,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_60m(2,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_6m(2,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), + FRQ_RNG_HF(2,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_60m(2,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_6m(2,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ + FRQ_RNG_70cm(1,IC7300_OTHER_TX_MODES, W(2),W(75),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_23cm(1,IC7300_OTHER_TX_MODES, W(2),W(23),IC7300_VFOS,RIG_ANT_3), + RIG_FRNG_END, }, + +.tuning_steps = { + {IC7300_ALL_RX_MODES,Hz(1)}, + {IC7300_ALL_RX_MODES,kHz(1)}, + {IC7300_ALL_RX_MODES,kHz(5)}, + {IC7300_ALL_RX_MODES,kHz(9)}, + {IC7300_ALL_RX_MODES,kHz(10)}, + {IC7300_ALL_RX_MODES,kHz(12.5)}, + {IC7300_ALL_RX_MODES,kHz(20)}, + {IC7300_ALL_RX_MODES,kHz(25)}, + RIG_TS_END, + }, + + /* mode/filter list, remember: order matters! But duplication may speed up search. Put the most commonly used modes first! Remember these are defaults, with dsp rigs you can change them to anything you want except FM and WFM which are fixed */ +.filters = { + {RIG_MODE_SSB, kHz(2.4)}, + {RIG_MODE_SSB, kHz(1.8)}, + {RIG_MODE_SSB, kHz(3)}, + {RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY|RIG_MODE_RTTYR, Hz(500)}, + {RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY|RIG_MODE_RTTYR, Hz(250)}, + {RIG_MODE_CW|RIG_MODE_CWR, kHz(1.2)}, + {RIG_MODE_RTTY|RIG_MODE_RTTYR, kHz(2.4)}, + {RIG_MODE_AM|RIG_MODE_PKTAM, kHz(6)}, + {RIG_MODE_AM|RIG_MODE_PKTAM, kHz(3)}, + {RIG_MODE_AM|RIG_MODE_PKTAM, kHz(9)}, + {RIG_MODE_FM|RIG_MODE_PKTFM, kHz(15)}, + {RIG_MODE_FM|RIG_MODE_PKTFM, kHz(10)}, + {RIG_MODE_FM|RIG_MODE_PKTFM, kHz(7)}, + RIG_FLT_END, + }, + +.str_cal = IC7300_STR_CAL, + +.cfgparams = icom_cfg_params, +.set_conf = icom_set_conf, +.get_conf = icom_get_conf, + +.priv = (void*)&IC7300_priv_caps, +.rig_init = icom_init, +.rig_cleanup = icom_cleanup, +.rig_open = NULL, +.rig_close = NULL, + +.set_freq = icom_set_freq, +.get_freq = icom_get_freq, +.set_mode = icom_set_mode_with_data, +.get_mode = icom_get_mode_with_data, +//.get_vfo = icom_get_vfo, +.set_vfo = icom_set_vfo, +.set_ant = NULL, +.get_ant = NULL, + +.set_rit = ic7300_set_rit, +.get_rit = ic7300_get_rit, +// the 7300 has only one register for both RIT and Delta TX +// you can turn one or both on -- but both end up just being in sync +// so we'll just reuse the rit settings +.get_xit = ic7300_get_rit, +.set_xit = ic7300_set_xit, + +.decode_event = icom_decode_event, +.set_level = ic7300_set_level, +.get_level = ic7300_get_level, +.set_ext_level = icom_set_ext_level, +.get_ext_level = icom_get_ext_level, +.set_func = ic7300_set_func, +.get_func = ic7300_get_func, +.set_parm = icom_set_parm, +.get_parm = icom_get_parm, +.set_mem = icom_set_mem, +.vfo_op = icom_vfo_op, +.scan = icom_scan, +.set_ptt = icom_set_ptt, +.get_ptt = icom_get_ptt, +.get_dcd = icom_get_dcd, +.set_ts = icom_set_ts, +.get_ts = icom_get_ts, +.set_rptr_shift = NULL, +.get_rptr_shift = NULL, +.set_rptr_offs = NULL, +.get_rptr_offs = NULL, +.set_ctcss_tone = icom_set_ctcss_tone, +.get_ctcss_tone = icom_get_ctcss_tone, +.set_ctcss_sql = icom_set_ctcss_sql, +.get_ctcss_sql = icom_get_ctcss_sql, +.set_split_freq = icom_set_split_freq, +.get_split_freq = icom_get_split_freq, +.set_split_mode = icom_set_split_mode, +.get_split_mode = icom_get_split_mode, +.set_split_vfo = icom_set_split_vfo, +.get_split_vfo = icom_get_split_vfo, +.set_powerstat = icom_set_powerstat, +.power2mW = icom_power2mW, +.mW2power = icom_mW2power, +.send_morse = icom_send_morse + +}; + int ic7300_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *ts) { unsigned char tsbuf[MAXFRAMELEN]; diff --git a/icom/icom.c b/icom/icom.c index 98895a9e8..9418d2095 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -4015,6 +4015,7 @@ DECLARE_INITRIG_BACKEND(icom) rig_register(&ic910_caps); rig_register(&ic9100_caps); rig_register(&ic970_caps); + rig_register(&ic9700_caps); rig_register(&icrx7_caps); rig_register(&icr6_caps); diff --git a/icom/icom.h b/icom/icom.h index 3e4ad38fe..d3ff87d9e 100644 --- a/icom/icom.h +++ b/icom/icom.h @@ -252,6 +252,7 @@ extern const struct rig_caps ic821h_caps; extern const struct rig_caps ic910_caps; extern const struct rig_caps ic9100_caps; extern const struct rig_caps ic970_caps; +extern const struct rig_caps ic9700_caps; extern const struct rig_caps icrx7_caps; extern const struct rig_caps icr10_caps; extern const struct rig_caps icr20_caps; diff --git a/include/bandplan.h b/include/bandplan.h index 88c022c47..969684316 100644 --- a/include/bandplan.h +++ b/include/bandplan.h @@ -241,6 +241,9 @@ #define FRQ_RNG_70cm(r,m,lp,hp,v,a) \ FRQ_RNG_70cm_REGION##r((m), (lp), (hp), (v), (a)) \ + +#define FRQ_RNG_23cm(r,m,lp,hp,v,a) \ + FRQ_RNG_23cm_REGION##r((m), (lp), (hp), (v), (a)) \ #endif /* _BANDPLAN_H */ diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index af3f060d3..7b67ac614 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -235,7 +235,8 @@ #define RIG_MODEL_IC7610 RIG_MAKE_MODEL(RIG_ICOM, 78) #define RIG_MODEL_ICR8600 RIG_MAKE_MODEL(RIG_ICOM, 79) #define RIG_MODEL_ICR30 RIG_MAKE_MODEL(RIG_ICOM, 80) -/* next one is 81 */ +#define RIG_MODEL_IC9700 RIG_MAKE_MODEL(RIG_ICOM, 81) +/* next one is 82 */ /* From f31701546b28c53d38be06b898ae57348715f435 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Sat, 6 Apr 2019 14:08:07 -0500 Subject: [PATCH 12/17] Add priv_caps for IC9700 --- icom/ic7300.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/icom/ic7300.c b/icom/ic7300.c index 44970d7bb..fb9a6bbb6 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -93,6 +93,14 @@ static const struct icom_priv_caps IC7300_priv_caps = { .civ_version = 1 /* new version of some commands, e.g. ic7200/7300 */ }; +static const struct icom_priv_caps IC9700_priv_caps = { + 0xA2, /* default address */ + 0, /* 731 mode */ + 0, /* no XCHG */ + ic7300_ts_sc_list, + .civ_version = 1 /* new version of some commands, e.g. ic7200/7300 */ +}; + /* Private IC7300 extra levels definitions * * Token definitions for .cfgparams in rig_caps @@ -400,7 +408,7 @@ const struct rig_caps ic9700_caps = { .set_conf = icom_set_conf, .get_conf = icom_get_conf, -.priv = (void*)&IC7300_priv_caps, +.priv = (void*)&IC9700_priv_caps, .rig_init = icom_init, .rig_cleanup = icom_cleanup, .rig_open = NULL, From e2f6c7d0926089dc9ec1cb5d2ecedf28b9f88c2a Mon Sep 17 00:00:00 2001 From: Michael Black Date: Sun, 7 Apr 2019 09:03:55 -0500 Subject: [PATCH 13/17] Add icom get_vfo introduced on IC-9700 Add DD mode for IC-9700 Numerous IC-9700 updates --- icom/frame.c | 3 ++- icom/ic7300.c | 52 ++++++++++++++++++++------------------------ icom/icom.c | 28 +++++++++++++++++++++++- icom/icom.h | 1 + icom/icom_defs.h | 2 ++ include/hamlib/rig.h | 2 +- 6 files changed, 57 insertions(+), 31 deletions(-) diff --git a/icom/frame.c b/icom/frame.c index b26c9009a..6d9f7ffa6 100644 --- a/icom/frame.c +++ b/icom/frame.c @@ -335,7 +335,7 @@ int rig2icom_mode(RIG *rig, rmode_t mode, pbwidth_t width, case RIG_MODE_RTTY: icmode = S_RTTY; break; case RIG_MODE_RTTYR: icmode = S_RTTYR; break; case RIG_MODE_FM: icmode = S_FM; break; - case RIG_MODE_FMN: icmode = S_FMN; break; + case RIG_MODE_FMN: icmode = S_FMN; break; case RIG_MODE_WFM: icmode = S_WFM; break; case RIG_MODE_P25: icmode = S_P25; break; case RIG_MODE_DSTAR: icmode = S_DSTAR; break; @@ -343,6 +343,7 @@ int rig2icom_mode(RIG *rig, rmode_t mode, pbwidth_t width, case RIG_MODE_NXDNVN: icmode = S_NXDNVN; break; case RIG_MODE_NXDN_N: icmode = S_NXDN_N; break; case RIG_MODE_DCR: icmode = S_DCR; break; + case RIG_MODE_DD: icmode = S_DD; break; default: rig_debug(RIG_DEBUG_ERR,"icom: Unsupported Hamlib mode %d\n",mode); return -RIG_EINVAL; diff --git a/icom/ic7300.c b/icom/ic7300.c index fb9a6bbb6..d8042a141 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -80,6 +80,8 @@ #define IC7300_AGC_MID 0x02 #define IC7300_AGC_SLOW 0x03 +#define IC9700_ALL_TX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD) +#define IC9700_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD) /* * IC-7300 rig capabilities. * @@ -347,40 +349,32 @@ const struct rig_caps ic9700_caps = { .rx_range_list1 = { {kHz(30),MHz(74.8),IC7300_ALL_RX_MODES,-1,-1,IC7300_VFOS}, RIG_FRNG_END, }, .tx_range_list1 = { - FRQ_RNG_HF(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_60m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_6m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_4m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_HF(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_60m(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_6m(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_4m(1,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_2m(1,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_2), - FRQ_RNG_70cm(1,IC7300_OTHER_TX_MODES, W(2),W(75),IC7300_VFOS,RIG_ANT_2), - FRQ_RNG_23cm(1,IC7300_OTHER_TX_MODES, W(2),W(23),IC7300_VFOS,RIG_ANT_3), + FRQ_RNG_2m(1,IC9700_ALL_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_70cm(1,IC9700_ALL_TX_MODES, W(2),W(75),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_23cm(1,IC9700_ALL_TX_MODES, W(2),W(23),IC7300_VFOS,RIG_ANT_3), RIG_FRNG_END, }, .rx_range_list2 = { {kHz(30),MHz(74.8),IC7300_ALL_RX_MODES,-1,-1,IC7300_VFOS}, RIG_FRNG_END, }, .tx_range_list2 = { - FRQ_RNG_HF(2,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_60m(2,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_6m(2,IC7300_OTHER_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_1), - FRQ_RNG_HF(2,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_60m(2,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_6m(2,IC7300_AM_TX_MODES, W(1),W(40),IC7300_VFOS,RIG_ANT_1), /* AM class */ - FRQ_RNG_70cm(1,IC7300_OTHER_TX_MODES, W(2),W(75),IC7300_VFOS,RIG_ANT_2), - FRQ_RNG_23cm(1,IC7300_OTHER_TX_MODES, W(2),W(23),IC7300_VFOS,RIG_ANT_3), + FRQ_RNG_2m(1,IC9700_ALL_TX_MODES, W(2),W(100),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_70cm(1,IC9700_ALL_TX_MODES, W(2),W(75),IC7300_VFOS,RIG_ANT_2), + FRQ_RNG_23cm(1,IC9700_ALL_TX_MODES, W(2),W(23),IC7300_VFOS,RIG_ANT_3), RIG_FRNG_END, }, .tuning_steps = { - {IC7300_ALL_RX_MODES,Hz(1)}, - {IC7300_ALL_RX_MODES,kHz(1)}, - {IC7300_ALL_RX_MODES,kHz(5)}, - {IC7300_ALL_RX_MODES,kHz(9)}, - {IC7300_ALL_RX_MODES,kHz(10)}, - {IC7300_ALL_RX_MODES,kHz(12.5)}, - {IC7300_ALL_RX_MODES,kHz(20)}, - {IC7300_ALL_RX_MODES,kHz(25)}, + {IC9700_ALL_RX_MODES,Hz(1)}, + {IC9700_ALL_RX_MODES,Hz(10)}, + {IC9700_ALL_RX_MODES,Hz(100)}, + {IC9700_ALL_RX_MODES,Hz(500)}, + {IC9700_ALL_RX_MODES,kHz(1)}, + {IC9700_ALL_RX_MODES,kHz(5)}, + {IC9700_ALL_RX_MODES,kHz(6.25)}, + {IC9700_ALL_RX_MODES,kHz(10)}, + {IC9700_ALL_RX_MODES,kHz(12.5)}, + {IC9700_ALL_RX_MODES,kHz(20)}, + {IC9700_ALL_RX_MODES,kHz(25)}, + {IC9700_ALL_RX_MODES,kHz(50)}, + {IC9700_ALL_RX_MODES,kHz(100)}, RIG_TS_END, }, @@ -418,7 +412,7 @@ const struct rig_caps ic9700_caps = { .get_freq = icom_get_freq, .set_mode = icom_set_mode_with_data, .get_mode = icom_get_mode_with_data, -//.get_vfo = icom_get_vfo, +.get_vfo = icom_get_vfo, .set_vfo = icom_set_vfo, .set_ant = NULL, .get_ant = NULL, @@ -463,6 +457,8 @@ const struct rig_caps ic9700_caps = { .set_split_vfo = icom_set_split_vfo, .get_split_vfo = icom_get_split_vfo, .set_powerstat = icom_set_powerstat, +.get_vfo = icom_get_vfo, +.set_vfo = icom_set_vfo, .power2mW = icom_power2mW, .mW2power = icom_mW2power, .send_morse = icom_send_morse diff --git a/icom/icom.c b/icom/icom.c index 9418d2095..a780b0c4f 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -951,7 +951,33 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } /* - * icom_set_vfo + * icom_get_vfo + * The IC-9700 has introduced the ability to see MAIN/SUB selection + * Maybe we'll see this in future ICOMs or firmware upgrades + * Command 0x07 0XD2 + * Assumes rig!=NULL, rig->state.priv!=NULL + */ +int icom_get_vfo(RIG *rig, vfo_t *vfo) +{ + unsigned char ackbuf[MAXFRAMELEN]; + int ack_len=sizeof(ackbuf), retval; + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + retval = icom_transaction (rig, C_SET_VFO, S_SUB_SEL, NULL, 0, + ackbuf, &ack_len); + if (retval != RIG_OK) + return retval; + + if (ack_len != 3) { + rig_debug(RIG_DEBUG_ERR,"%s wrong frame len=%d\n", ack_len); + return -RIG_ERJCTED; + } + *vfo = ackbuf[2] == 0 ? RIG_VFO_MAIN : RIG_VFO_SUB; + return RIG_OK; +} + +/* + * icom_get_vfo * Assumes rig!=NULL, rig->state.priv!=NULL */ int icom_set_vfo(RIG *rig, vfo_t vfo) diff --git a/icom/icom.h b/icom/icom.h index d3ff87d9e..c45cd1a3e 100644 --- a/icom/icom.h +++ b/icom/icom.h @@ -160,6 +160,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +int icom_get_vfo(RIG *rig, vfo_t *vfo); int icom_set_vfo(RIG *rig, vfo_t vfo); int icom_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); int icom_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift); diff --git a/icom/icom_defs.h b/icom/icom_defs.h index 63344f12e..68e8e5ad6 100644 --- a/icom/icom_defs.h +++ b/icom/icom_defs.h @@ -126,6 +126,7 @@ #define S_NXDNVN 0x19 /* Set to NXDN_VN */ #define S_NXDN_N 0x20 /* Set to NXDN-N */ #define S_DCR 0x21 /* Set to DCR */ +#define S_DD 0x22 /* Set to DD 1200Mhz only? */ #define S_R7000_SSB 0x05 /* Set to SSB on R-7000 */ @@ -151,6 +152,7 @@ #define S_DUAL_ON 0xc1 /* Dual watch on */ #define S_MAIN 0xd0 /* Select MAIN band */ #define S_SUB 0xd1 /* Select SUB band */ +#define S_SUB_SEL 0xd2 /* Read/Set Main/Sub selection */ #define S_FRONTWIN 0xe0 /* Select front window */ /* diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 36dfed399..44c2fa6c9 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -926,7 +926,7 @@ typedef uint64_t rmode_t; #define RIG_MODE_PSKR CONSTANT_64BIT_FLAG (31) /*!< \c PSKR - Kenwood PSKR and others */ #ifndef SWIGLUA /* hide the top 32 bits from the Lua binding as they will not work */ -#define RIG_MODE_BIT32 CONSTANT_64BIT_FLAG (32) /* reserved for future expansion */ +#define RIG_MODE_DD CONSTANT_64BIT_FLAG (32) /* DD Mode IC-9700 */ #define RIG_MODE_BIT33 CONSTANT_64BIT_FLAG (33) /* reserved for future expansion */ #define RIG_MODE_BIT34 CONSTANT_64BIT_FLAG (34) /* reserved for future expansion */ #define RIG_MODE_BIT35 CONSTANT_64BIT_FLAG (35) /* reserved for future expansion */ From 602a3c01b28fba8f273fa883708a84127f8e6da7 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Sun, 7 Apr 2019 23:54:02 -0500 Subject: [PATCH 14/17] Implement new get_freq for IC9700 with TARGETABLE_FREQ now --- icom/ic7300.c | 11 ++++-- icom/icom.c | 90 ++++++++++++++++++++++++++++++++++-------------- icom/icom_defs.h | 1 + 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/icom/ic7300.c b/icom/ic7300.c index d8042a141..7f838778f 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -80,8 +80,13 @@ #define IC7300_AGC_MID 0x02 #define IC7300_AGC_SLOW 0x03 +/* + * IC9700 items that differ from IC7300 + */ +#define IC9700_VFO_OPS (RIG_OP_CPY|RIG_OP_XCHG|RIG_OP_FROM_VFO|RIG_OP_TO_VFO|RIG_OP_MCL) #define IC9700_ALL_TX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD) #define IC9700_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD) + /* * IC-7300 rig capabilities. * @@ -100,7 +105,7 @@ static const struct icom_priv_caps IC9700_priv_caps = { 0, /* 731 mode */ 0, /* no XCHG */ ic7300_ts_sc_list, - .civ_version = 1 /* new version of some commands, e.g. ic7200/7300 */ + .civ_version = 2 /* new version of some commands, e.g. ic9700 */ }; /* Private IC7300 extra levels definitions @@ -334,8 +339,8 @@ const struct rig_caps ic9700_caps = { .max_rit = Hz(9999), .max_xit = Hz(9999), .max_ifshift = Hz(0), -.targetable_vfo = 0, -.vfo_ops = IC7300_VFO_OPS, +.targetable_vfo = RIG_TARGETABLE_FREQ, +.vfo_ops = IC9700_VFO_OPS, .scan_ops = IC7300_SCAN_OPS, .transceive = RIG_TRN_RIG, .bank_qty = 1, diff --git a/icom/icom.c b/icom/icom.c index a780b0c4f..73d17a500 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -351,6 +351,7 @@ static const struct icom_addr icom_addr_list[] = { { RIG_MODEL_IC821H, 0x4c }, { RIG_MODEL_IC910, 0x60 }, { RIG_MODEL_IC9100, 0x7c }, + { RIG_MODEL_IC9700, 0xa2 }, { RIG_MODEL_IC970, 0x2e }, { RIG_MODEL_IC1271, 0x24 }, { RIG_MODEL_IC1275, 0x18 }, @@ -386,7 +387,7 @@ static const struct icom_addr icom_addr_list[] = { /* * This is a generic icom_init function. * You might want to define yours, so you can customize it for your rig - * + * * Basically, it sets up *priv * REM: serial port is already open (rig->state.rigport.fd) */ @@ -464,7 +465,7 @@ int icom_rig_open(RIG *rig) struct rig_state *rs = &rig->state; struct icom_priv_data *priv = (struct icom_priv_data*)rs->priv; - struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) rig->caps->priv; + struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) rig->caps->priv; if (priv_caps->serial_USB_echo_check) { @@ -482,6 +483,30 @@ int icom_rig_open(RIG *rig) } } priv->serial_USB_echo_off = 0; + + if (priv->civ_version >= 2) { + // IC9700 introduced the ability to termine Main/Sub selection + // That means we can now do get/set VFOA/VFOB + // But we have to force Main=VFOA and Sub=VFOB + // We only force this on opening + // Maybe there should be an option to bypass this? + retval = icom_transaction (rig, C_SET_VFO, S_MAIN, NULL, 0, ackbuf, &ack_len); + if (retval != RIG_OK) + return retval; + + retval = icom_transaction (rig, C_SET_VFO, S_VFOA, NULL, 0, ackbuf, &ack_len); + if (retval != RIG_OK) + return retval; + + retval = icom_transaction (rig, C_SET_VFO, S_SUB, NULL, 0, ackbuf, &ack_len); + if (retval != RIG_OK) + return retval; + + retval = icom_transaction (rig, C_SET_VFO, S_VFOB, NULL, 0, ackbuf, &ack_len); + if (retval != RIG_OK) + return retval; + } + return retval; } @@ -508,8 +533,13 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ to_bcd(freqbuf, freq, freq_len*2); - retval = icom_transaction (rig, C_SET_FREQ, -1, freqbuf, freq_len, - ackbuf, &ack_len); + int cmd = C_RD_FREQ; + int subcmd = -1; + if (priv->civ_version >= 2) { + cmd = C_SEND_SEL_FREQ; + subcmd = vfo==RIG_VFO_A?0:1; + } + retval = icom_transaction (rig, cmd, subcmd, freqbuf, freq_len, ackbuf, &ack_len); if (retval != RIG_OK) return retval; @@ -524,7 +554,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) /* * icom_get_freq - * Assumes rig!=NULL, rig->state.priv!=NULL, freq!=NULL + * Assumes rig!=NULL, rig->state.priv!=NULL, freq!=NULL, Main=VFOA, Sub=VFOB * Note: old rig may return less than 4/5 bytes for get_freq */ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) @@ -538,8 +568,13 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rs = &rig->state; priv = (struct icom_priv_data*)rs->priv; - retval = icom_transaction (rig, C_RD_FREQ, -1, NULL, 0, - freqbuf, &freq_len); + int cmd = C_RD_FREQ; + int subcmd = -1; + if (priv->civ_version >= 2) { + cmd = C_SEND_SEL_FREQ; + subcmd = vfo==RIG_VFO_A?0:1; + } + retval = icom_transaction (rig, cmd, subcmd, NULL, 0, freqbuf, &freq_len); if (retval != RIG_OK) return retval; @@ -955,6 +990,8 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) * The IC-9700 has introduced the ability to see MAIN/SUB selection * Maybe we'll see this in future ICOMs or firmware upgrades * Command 0x07 0XD2 + * We will, by default, force Main=VFOA and Sub=VFOB, and may want + * an option to not force that behavior * Assumes rig!=NULL, rig->state.priv!=NULL */ int icom_get_vfo(RIG *rig, vfo_t *vfo) @@ -972,7 +1009,7 @@ int icom_get_vfo(RIG *rig, vfo_t *vfo) rig_debug(RIG_DEBUG_ERR,"%s wrong frame len=%d\n", ack_len); return -RIG_ERJCTED; } - *vfo = ackbuf[2] == 0 ? RIG_VFO_MAIN : RIG_VFO_SUB; + *vfo = ackbuf[2] == 0 ? RIG_VFO_A : RIG_VFO_B; return RIG_OK; } @@ -989,6 +1026,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) if (vfo == RIG_VFO_CURR) return RIG_OK; + switch(vfo) { case RIG_VFO_A: icvfo = S_VFOA; break; case RIG_VFO_B: icvfo = S_VFOB; break; @@ -1076,7 +1114,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) break; } } - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { switch (level) { case RIG_LEVEL_KEYSPD: if (val.i < 6) val.i = 6; @@ -1218,7 +1256,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } break; case RIG_LEVEL_VOXDELAY: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { lvl_cn = C_CTL_MEM; lvl_sc = 0x05; // plus 0191 and value 0-20 = 0-2 secs lvl_len = 2; @@ -1512,7 +1550,7 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; } } - else if ((priv->civ_version == 1)&&(level==RIG_LEVEL_KEYSPD)){ + else if ((priv->civ_version >= 1)&&(level==RIG_LEVEL_KEYSPD)){ switch (level) { case RIG_LEVEL_KEYSPD: val->i = val->i*(42.0/255)+6+.5; @@ -2439,7 +2477,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) fct_sc = (r8500)?(status)?S_FUNC_AGCON:S_FUNC_AGCOFF:S_FUNC_AGC; /* fct_sc = S_FUNC_AGC; */ /* note: should it be a LEVEL only, and no func? --SF */ - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { fct_len = 1; fctbuf[0] = status; } @@ -2529,7 +2567,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) fct_sc = S_MEM_SATMODE; break; case RIG_FUNC_SCOPE: - if (priv->civ_version == 1) { /* IC-7200/7300 */ + if (priv->civ_version >= 1) { /* IC-7200/7300 */ fct_cn = 0x27; fct_sc = 0x10; fctbuf[0] = status; @@ -2761,7 +2799,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) case RIG_PARM_BACKLIGHT: prm_cn = C_CTL_MEM; icom_val = val.f * 255; - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_sc = 0x05; prm_len = 4; if (rig->caps->rig_model == RIG_MODEL_ICR8600) { @@ -2784,7 +2822,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) case RIG_PARM_KEYLIGHT: prm_cn = C_CTL_MEM; icom_val = val.f * 255; - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_sc = 0x05; prm_len = 4; if (rig->caps->rig_model == RIG_MODEL_ICR8600) { @@ -2804,7 +2842,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) break; case RIG_PARM_BEEP: prm_cn = C_CTL_MEM; - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_sc = 0x05; prm_len = 3; prmbuf[0] = 0x00; @@ -2823,7 +2861,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) hr = (float)val.i/3600.0; min = (float)(val.i - (hr*3600))/60.0; sec = (val.i - (hr*3600) - (min*60)); - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_sc = 0x05; prm_len = 4; prmbuf[0] = 0x00; @@ -2887,7 +2925,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) prmbuf[0] = S_PRM_SLPTM; break; case RIG_PARM_BACKLIGHT: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2908,7 +2946,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) } break; case RIG_PARM_KEYLIGHT: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2927,7 +2965,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) } break; case RIG_PARM_BEEP: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2942,7 +2980,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) } break; case RIG_PARM_TIME: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2986,7 +3024,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) val->i = icom_val; break; case RIG_PARM_TIME: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { hr = from_bcd_be(resbuf+cmdhead+1, 2); min = from_bcd_be(resbuf+cmdhead+2, 2); sec = 0; @@ -3001,7 +3039,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) break; case RIG_PARM_BACKLIGHT: icom_val = 0; - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { icom_val = from_bcd_be(resbuf+cmdhead+1, (res_len-1)*2); } else { icom_val = from_bcd_be(resbuf+cmdhead, res_len*2); @@ -3010,7 +3048,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) break; case RIG_PARM_KEYLIGHT: icom_val = 0; - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { icom_val = from_bcd_be(resbuf+cmdhead+1, (res_len-1)*2); } else { return -RIG_EINVAL; @@ -3018,7 +3056,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) val->f = (float)icom_val/255.0; break; case RIG_PARM_BEEP: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { icom_val = from_bcd_be(resbuf+cmdhead+1, (res_len-1)*2); } else { icom_val = from_bcd_be(resbuf+cmdhead, res_len*2); @@ -3576,7 +3614,7 @@ int icom_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) mv_sc = -1; break; case RIG_OP_TUNE: - if (priv->civ_version == 1) { + if (priv->civ_version >= 1) { mvbuf[0] = 2; mv_len = 1; } diff --git a/icom/icom_defs.h b/icom/icom_defs.h index 68e8e5ad6..6f2d7ff76 100644 --- a/icom/icom_defs.h +++ b/icom/icom_defs.h @@ -93,6 +93,7 @@ #define C_SET_TONE 0x1b /* Set tone frequency */ #define C_CTL_PTT 0x1c /* Control Transmit On/Off, Sc */ #define C_CTL_DIG 0x20 /* Digital modes settings & status */ +#define C_SEND_SEL_FREQ 0x25 /* Send/Recv sel/unsel VFO frequency */ #define C_CTL_MTEXT 0x70 /* Microtelecom Extension */ #define C_CTL_MISC 0x7f /* Miscellaneous control, Sc */ From 70d7125790687e0785703e37a82ba4bbdc88dbda Mon Sep 17 00:00:00 2001 From: Michael Black Date: Mon, 8 Apr 2019 14:15:00 -0500 Subject: [PATCH 15/17] Fix ic9700 get_freq frame len --- icom/icom.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/icom/icom.c b/icom/icom.c index 73d17a500..38c10ee9d 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -592,7 +592,12 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return RIG_OK; } - if (freq_len != 4 && freq_len != 5) { + if (priv->civ_version >= 2 && freq_len != 6) { + rig_debug(RIG_DEBUG_ERR,"icom_get_freq: wrong frame len2=%d\n", + freq_len); + return -RIG_ERJCTED; + } + else if (freq_len != 4 && freq_len != 5) { rig_debug(RIG_DEBUG_ERR,"icom_get_freq: wrong frame len=%d\n", freq_len); return -RIG_ERJCTED; From 72f062f6f1b3b29e8397f50cad0383b5ec9d1fc8 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 9 Apr 2019 06:50:28 -0500 Subject: [PATCH 16/17] Fix get_freq for IC9700 --- icom/ic7300.c | 2 +- icom/icom.c | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/icom/ic7300.c b/icom/ic7300.c index 7f838778f..ee00abd6e 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -304,7 +304,7 @@ const struct rig_caps ic9700_caps = { .rig_model = RIG_MODEL_IC9700, .model_name = "IC-9700", .mfg_name = "Icom", -.version = BACKEND_VER ".1a", +.version = BACKEND_VER ".1c", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .rig_type = RIG_TYPE_TRANSCEIVER, diff --git a/icom/icom.c b/icom/icom.c index 38c10ee9d..9a12b341f 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -485,24 +485,29 @@ int icom_rig_open(RIG *rig) priv->serial_USB_echo_off = 0; if (priv->civ_version >= 2) { - // IC9700 introduced the ability to termine Main/Sub selection + // IC9700 introduced the ability to determine Main/Sub selection + // It has two independed TX/RX each with VFOA/B // That means we can now do get/set VFOA/VFOB // But we have to force Main=VFOA and Sub=VFOB // We only force this on opening // Maybe there should be an option to bypass this? - retval = icom_transaction (rig, C_SET_VFO, S_MAIN, NULL, 0, ackbuf, &ack_len); + rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo=MAIN\n",__func__); + retval = icom_set_vfo(rig, RIG_VFO_MAIN); if (retval != RIG_OK) return retval; - retval = icom_transaction (rig, C_SET_VFO, S_VFOA, NULL, 0, ackbuf, &ack_len); + rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo=MAIN=VFOA\n",__func__); + retval = icom_set_vfo(rig, RIG_VFO_A); if (retval != RIG_OK) return retval; - retval = icom_transaction (rig, C_SET_VFO, S_SUB, NULL, 0, ackbuf, &ack_len); + rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo=SUB\n",__func__); + retval = icom_set_vfo(rig, RIG_VFO_SUB); if (retval != RIG_OK) return retval; - retval = icom_transaction (rig, C_SET_VFO, S_VFOB, NULL, 0, ackbuf, &ack_len); + rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo=SUB=VFOB\n",__func__); + retval = icom_set_vfo(rig, RIG_VFO_B); if (retval != RIG_OK) return retval; } @@ -537,7 +542,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int subcmd = -1; if (priv->civ_version >= 2) { cmd = C_SEND_SEL_FREQ; - subcmd = vfo==RIG_VFO_A?0:1; + subcmd = ((vfo==RIG_VFO_A)||(vfo==RIG_VFO_MAIN))?0:1; } retval = icom_transaction (rig, cmd, subcmd, freqbuf, freq_len, ackbuf, &ack_len); if (retval != RIG_OK) @@ -572,7 +577,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int subcmd = -1; if (priv->civ_version >= 2) { cmd = C_SEND_SEL_FREQ; - subcmd = vfo==RIG_VFO_A?0:1; + subcmd = ((vfo==RIG_VFO_A)||(vfo==RIG_VFO_MAIN))?0:1; } retval = icom_transaction (rig, cmd, subcmd, NULL, 0, freqbuf, &freq_len); if (retval != RIG_OK) @@ -582,6 +587,10 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) * freqbuf should contain Cn,Data area */ freq_len--; + if (priv->civ_version >= 2) { + memmove(freqbuf,freqbuf+1,freq_len); + freq_len--; + } /* * is it a blank mem channel ? @@ -592,12 +601,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return RIG_OK; } - if (priv->civ_version >= 2 && freq_len != 6) { - rig_debug(RIG_DEBUG_ERR,"icom_get_freq: wrong frame len2=%d\n", - freq_len); - return -RIG_ERJCTED; - } - else if (freq_len != 4 && freq_len != 5) { + if (freq_len != 4 && freq_len != 5) { rig_debug(RIG_DEBUG_ERR,"icom_get_freq: wrong frame len=%d\n", freq_len); return -RIG_ERJCTED; From b788b447aaa35484b048094c4ef9dff769028ed1 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Thu, 11 Apr 2019 07:47:35 -0500 Subject: [PATCH 17/17] Undo get_vfo attempt for ic9700 Implement icom Main/Sub get_freq -- broken for IC9700 firmware 1.05 Prototype for ic9700 set_freq to allow band change when Main band wil equal Sub band...but disabled for now until firmware is fixed --- icom/ic7300.c | 8 +-- icom/icom.c | 138 ++++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 65 deletions(-) diff --git a/icom/ic7300.c b/icom/ic7300.c index 7f838778f..693872180 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -105,7 +105,7 @@ static const struct icom_priv_caps IC9700_priv_caps = { 0, /* 731 mode */ 0, /* no XCHG */ ic7300_ts_sc_list, - .civ_version = 2 /* new version of some commands, e.g. ic9700 */ + .civ_version = 1 /* new version of some commands, e.g. ic7200/7300 */ }; /* Private IC7300 extra levels definitions @@ -304,7 +304,7 @@ const struct rig_caps ic9700_caps = { .rig_model = RIG_MODEL_IC9700, .model_name = "IC-9700", .mfg_name = "Icom", -.version = BACKEND_VER ".1a", +.version = BACKEND_VER ".1c", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -417,7 +417,7 @@ const struct rig_caps ic9700_caps = { .get_freq = icom_get_freq, .set_mode = icom_set_mode_with_data, .get_mode = icom_get_mode_with_data, -.get_vfo = icom_get_vfo, +//.get_vfo = icom_get_vfo, .set_vfo = icom_set_vfo, .set_ant = NULL, .get_ant = NULL, @@ -462,7 +462,7 @@ const struct rig_caps ic9700_caps = { .set_split_vfo = icom_set_split_vfo, .get_split_vfo = icom_get_split_vfo, .set_powerstat = icom_set_powerstat, -.get_vfo = icom_get_vfo, +//.get_vfo = icom_get_vfo, .set_vfo = icom_set_vfo, .power2mW = icom_power2mW, .mW2power = icom_mW2power, diff --git a/icom/icom.c b/icom/icom.c index 38c10ee9d..e9ce7d34e 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -483,31 +483,7 @@ int icom_rig_open(RIG *rig) } } priv->serial_USB_echo_off = 0; - - if (priv->civ_version >= 2) { - // IC9700 introduced the ability to termine Main/Sub selection - // That means we can now do get/set VFOA/VFOB - // But we have to force Main=VFOA and Sub=VFOB - // We only force this on opening - // Maybe there should be an option to bypass this? - retval = icom_transaction (rig, C_SET_VFO, S_MAIN, NULL, 0, ackbuf, &ack_len); - if (retval != RIG_OK) - return retval; - - retval = icom_transaction (rig, C_SET_VFO, S_VFOA, NULL, 0, ackbuf, &ack_len); - if (retval != RIG_OK) - return retval; - - retval = icom_transaction (rig, C_SET_VFO, S_SUB, NULL, 0, ackbuf, &ack_len); - if (retval != RIG_OK) - return retval; - - retval = icom_transaction (rig, C_SET_VFO, S_VFOB, NULL, 0, ackbuf, &ack_len); - if (retval != RIG_OK) - return retval; - } - - return retval; + return retval; } @@ -522,10 +498,39 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) unsigned char freqbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; int freq_len, ack_len=sizeof(ackbuf), retval; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called %s=%"PRIll"\n", __func__, rig_strvfo(vfo),(int64_t)freq); rs = &rig->state; priv = (struct icom_priv_data*)rs->priv; + // IC-9700 cannot set freq MAIN to same band as SUB + // So we query both and ensure they won't match + // If a potential collision we just swap VFOs + // This covers setting VFOA, VFOB, Main or Sub +#if 0 + if (rig->caps->rig_model == RIG_MODEL_IC9700) { + // the 0x07 0xd2 is not working as of IC-9700 firmwave 1.05 + // When it does work this can be unblocked + freq_t freqMain,freqSub; + retval = rig_get_freq(rig, RIG_VFO_MAIN, &freqMain); + if (retval != RIG_OK) + return retval; + retval = rig_get_freq(rig, RIG_VFO_SUB, &freqSub); + if (retval != RIG_OK) + return retval; + // Make our 2M = 1, 70cm = 4, and 23cm=12 + freqMain = freqMain/1e8; + freqSub = freqMain/1e8; + freq_t freq2 = freq/1e8; + // Check if changing bands on Main and it matches Sub band + int mainCollides = freq2 != freqMain && freq2 == freqSub; + if (mainCollides) { + // we'll just swap Main/Sub + retval = icom_vfo_op(rig, vfo, RIG_OP_XCHG); + if (retval != RIG_OK) + return retval; + } + } +#endif freq_len = priv->civ_731_mode ? 4:5; /* @@ -533,12 +538,8 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ to_bcd(freqbuf, freq, freq_len*2); - int cmd = C_RD_FREQ; + int cmd = C_SET_FREQ; int subcmd = -1; - if (priv->civ_version >= 2) { - cmd = C_SEND_SEL_FREQ; - subcmd = vfo==RIG_VFO_A?0:1; - } retval = icom_transaction (rig, cmd, subcmd, freqbuf, freq_len, ackbuf, &ack_len); if (retval != RIG_OK) return retval; @@ -564,20 +565,40 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) unsigned char freqbuf[MAXFRAMELEN]; int freq_len, retval; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called for %s\n", __func__,rig_strvfo(vfo)); rs = &rig->state; priv = (struct icom_priv_data*)rs->priv; + // Newer Icoms can read main/sub frequency + // It appears int cmd = C_RD_FREQ; int subcmd = -1; - if (priv->civ_version >= 2) { - cmd = C_SEND_SEL_FREQ; - subcmd = vfo==RIG_VFO_A?0:1; + unsigned char data; + int datalen = 0; + switch(vfo) { + case RIG_VFO_MAIN: + cmd = C_SET_VFO; + subcmd = S_SUB_SEL; + data = 0 ; + datalen = 1; + break; + case RIG_VFO_SUB: + cmd = C_SET_VFO; + subcmd = S_SUB_SEL; + data = 1; + datalen = 1; + break; } - retval = icom_transaction (rig, cmd, subcmd, NULL, 0, freqbuf, &freq_len); + retval = icom_transaction (rig, cmd, subcmd, datalen==0?NULL:&data, datalen, freqbuf, &freq_len); if (retval != RIG_OK) return retval; + // The command to read Main/Sub freq is 1 byte longer + // So a simple solution here is to just move left 1 byte + if (cmd == C_SEND_SEL_FREQ) { + memmove(freqbuf,freqbuf+1,freq_len-1); + freq_len--; // have to take off one more byte from the response + } /* * freqbuf should contain Cn,Data area */ @@ -592,12 +613,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return RIG_OK; } - if (priv->civ_version >= 2 && freq_len != 6) { - rig_debug(RIG_DEBUG_ERR,"icom_get_freq: wrong frame len2=%d\n", - freq_len); - return -RIG_ERJCTED; - } - else if (freq_len != 4 && freq_len != 5) { + if (freq_len != 4 && freq_len != 5) { rig_debug(RIG_DEBUG_ERR,"icom_get_freq: wrong frame len=%d\n", freq_len); return -RIG_ERJCTED; @@ -994,7 +1010,7 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) * icom_get_vfo * The IC-9700 has introduced the ability to see MAIN/SUB selection * Maybe we'll see this in future ICOMs or firmware upgrades - * Command 0x07 0XD2 + * Command 0x07 0XD2 -- but as of version 1.05 it doesn't work * We will, by default, force Main=VFOA and Sub=VFOB, and may want * an option to not force that behavior * Assumes rig!=NULL, rig->state.priv!=NULL @@ -1119,7 +1135,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) break; } } - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { switch (level) { case RIG_LEVEL_KEYSPD: if (val.i < 6) val.i = 6; @@ -1261,7 +1277,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } break; case RIG_LEVEL_VOXDELAY: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { lvl_cn = C_CTL_MEM; lvl_sc = 0x05; // plus 0191 and value 0-20 = 0-2 secs lvl_len = 2; @@ -1555,7 +1571,7 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; } } - else if ((priv->civ_version >= 1)&&(level==RIG_LEVEL_KEYSPD)){ + else if ((priv->civ_version == 1)&&(level==RIG_LEVEL_KEYSPD)){ switch (level) { case RIG_LEVEL_KEYSPD: val->i = val->i*(42.0/255)+6+.5; @@ -2482,7 +2498,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) fct_sc = (r8500)?(status)?S_FUNC_AGCON:S_FUNC_AGCOFF:S_FUNC_AGC; /* fct_sc = S_FUNC_AGC; */ /* note: should it be a LEVEL only, and no func? --SF */ - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { fct_len = 1; fctbuf[0] = status; } @@ -2572,7 +2588,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) fct_sc = S_MEM_SATMODE; break; case RIG_FUNC_SCOPE: - if (priv->civ_version >= 1) { /* IC-7200/7300 */ + if (priv->civ_version == 1) { /* IC-7200/7300 */ fct_cn = 0x27; fct_sc = 0x10; fctbuf[0] = status; @@ -2804,7 +2820,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) case RIG_PARM_BACKLIGHT: prm_cn = C_CTL_MEM; icom_val = val.f * 255; - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_sc = 0x05; prm_len = 4; if (rig->caps->rig_model == RIG_MODEL_ICR8600) { @@ -2827,7 +2843,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) case RIG_PARM_KEYLIGHT: prm_cn = C_CTL_MEM; icom_val = val.f * 255; - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_sc = 0x05; prm_len = 4; if (rig->caps->rig_model == RIG_MODEL_ICR8600) { @@ -2847,7 +2863,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) break; case RIG_PARM_BEEP: prm_cn = C_CTL_MEM; - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_sc = 0x05; prm_len = 3; prmbuf[0] = 0x00; @@ -2866,7 +2882,7 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) hr = (float)val.i/3600.0; min = (float)(val.i - (hr*3600))/60.0; sec = (val.i - (hr*3600) - (min*60)); - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_sc = 0x05; prm_len = 4; prmbuf[0] = 0x00; @@ -2930,7 +2946,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) prmbuf[0] = S_PRM_SLPTM; break; case RIG_PARM_BACKLIGHT: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2951,7 +2967,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) } break; case RIG_PARM_KEYLIGHT: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2970,7 +2986,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) } break; case RIG_PARM_BEEP: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -2985,7 +3001,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) } break; case RIG_PARM_TIME: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { prm_cn = C_CTL_MEM; prm_sc = 0x05; prm_len = 2; @@ -3029,7 +3045,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) val->i = icom_val; break; case RIG_PARM_TIME: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { hr = from_bcd_be(resbuf+cmdhead+1, 2); min = from_bcd_be(resbuf+cmdhead+2, 2); sec = 0; @@ -3044,7 +3060,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) break; case RIG_PARM_BACKLIGHT: icom_val = 0; - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { icom_val = from_bcd_be(resbuf+cmdhead+1, (res_len-1)*2); } else { icom_val = from_bcd_be(resbuf+cmdhead, res_len*2); @@ -3053,7 +3069,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) break; case RIG_PARM_KEYLIGHT: icom_val = 0; - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { icom_val = from_bcd_be(resbuf+cmdhead+1, (res_len-1)*2); } else { return -RIG_EINVAL; @@ -3061,7 +3077,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val) val->f = (float)icom_val/255.0; break; case RIG_PARM_BEEP: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { icom_val = from_bcd_be(resbuf+cmdhead+1, (res_len-1)*2); } else { icom_val = from_bcd_be(resbuf+cmdhead, res_len*2); @@ -3619,7 +3635,7 @@ int icom_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) mv_sc = -1; break; case RIG_OP_TUNE: - if (priv->civ_version >= 1) { + if (priv->civ_version == 1) { mvbuf[0] = 2; mv_len = 1; }