From add666f8919b0584d68a7fd3e603b9c0193f73ca Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 12 Dec 2021 13:18:24 -0600 Subject: [PATCH 01/22] Fix Icom echo off not working https://github.com/Hamlib/Hamlib/issues/885 --- rigs/icom/icom.c | 14 +++++++++----- rigs/icom/icom.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7e021af2b..e69e9092a 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -928,7 +928,7 @@ static vfo_t icom_current_vfo(RIG *rig) int icom_rig_open(RIG *rig) { - int retval = RIG_OK; + int retval, retval_echo; int satmode = 0; struct rig_state *rs = &rig->state; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; @@ -941,9 +941,9 @@ icom_rig_open(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: %s v%s\n", __func__, rig->caps->model_name, rig->caps->version); retry_open: - retval = icom_get_usb_echo_off(rig); + retval_echo = icom_get_usb_echo_off(rig); - if (retval == RIG_OK) // then echo is on so let's try freq now + if (retval_echo == 0 || retval_echo == 1) // then we know our echo status { rig->state.current_vfo = icom_current_vfo(rig); // some rigs like the IC7100 still echo when in standby @@ -951,6 +951,10 @@ retry_open: freq_t tfreq; retval = rig_get_freq(rig, RIG_VFO_CURR, &tfreq); } + else + { + retval = -RIG_EPROTO; + } if (retval != RIG_OK && priv->poweron == 0 && rs->auto_power_on) { @@ -971,9 +975,9 @@ retry_open: } // Now that we're powered up let's try again - retval = icom_get_usb_echo_off(rig); + retval_echo = icom_get_usb_echo_off(rig); - if (retval < 0) + if (retval_echo != 0 && retval_echo != 1) { rig_debug(RIG_DEBUG_ERR, "%s: Unable to determine USB echo status\n", __func__); RETURNFUNC(retval); diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 19f2750cb..cdf9c97ca 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20211120" +#define BACKEND_VER "20211212" #define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B)) #define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00) From e257116689fbee21a54d12215bf562b0591942f1 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 12 Dec 2021 23:29:42 -0600 Subject: [PATCH 02/22] Add JRS JTS-145 rig --- rigs/jrc/Makefile.am | 2 +- rigs/jrc/jrc.c | 3 +- rigs/jrc/jrc.h | 2 + rigs/jrc/jst145.c | 306 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 rigs/jrc/jst145.c diff --git a/rigs/jrc/Makefile.am b/rigs/jrc/Makefile.am index 746d23d02..c23bc254e 100644 --- a/rigs/jrc/Makefile.am +++ b/rigs/jrc/Makefile.am @@ -1,4 +1,4 @@ -JRCSRC = nrd535.c nrd545.c nrd525.c jrc.c jrc.h +JRCSRC = nrd535.c nrd545.c nrd525.c jrc.c jrc.h jst145.c noinst_LTLIBRARIES = libhamlib-jrc.la libhamlib_jrc_la_SOURCES = $(JRCSRC) diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c index a02aa9c56..5e0f4f5cf 100644 --- a/rigs/jrc/jrc.c +++ b/rigs/jrc/jrc.c @@ -67,7 +67,7 @@ * Otherwise, you'll get a nice seg fault. You've been warned! * TODO: error case handling */ -static int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, +int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len) { int retval; @@ -1683,6 +1683,7 @@ DECLARE_INITRIG_BACKEND(jrc) rig_register(&nrd535_caps); rig_register(&nrd545_caps); rig_register(&nrd525_caps); + rig_register(&jst145_caps); return RIG_OK; } diff --git a/rigs/jrc/jrc.h b/rigs/jrc/jrc.h index d3a4049d4..890903986 100644 --- a/rigs/jrc/jrc.h +++ b/rigs/jrc/jrc.h @@ -37,6 +37,7 @@ struct jrc_priv_caps { const char * cw_pitch; }; +int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len); int jrc_open(RIG *rig); int jrc_close(RIG *rig); int jrc_set_freq(RIG *rig, vfo_t vfo, freq_t freq); @@ -66,6 +67,7 @@ int jrc_decode_event(RIG *rig); extern const struct rig_caps nrd535_caps; extern const struct rig_caps nrd545_caps; extern const struct rig_caps nrd525_caps; +extern const struct rig_caps jst145_caps; #endif /* _JRC_H */ diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c new file mode 100644 index 000000000..1efc5ebc6 --- /dev/null +++ b/rigs/jrc/jst145.c @@ -0,0 +1,306 @@ +/* + * Hamlib JRC backend - JST-145 description + * Copyright (c) 2001-2009 by Stephane Fillod + * Copyright (c) 2021 by Michael Black W9MDB + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "hamlib/rig.h" +#include "iofunc.h" +#include "jrc.h" + + +static int jst145_open(RIG *rig); +static int jst145_close(RIG *rig); +static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq); +static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); +static int jst145_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); +static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); +static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); +static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch); + +#define JST145_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_FAX) + +#define JST145_LEVEL (RIG_LEVEL_AGC) + +#define JST145_VFO (RIG_VFO_VFO) + +#define JST145_MEM_CAP { \ + .freq = 1, \ + .mode = 1, \ + .width = 1, \ + .levels = RIG_LEVEL_AGC, \ +} + +/* + * JST-145 rig capabilities. + * + */ +const struct rig_caps jst145_caps = +{ + RIG_MODEL(RIG_MODEL_JST145), + .model_name = "JST-145", + .mfg_name = "JRC", + .version = BACKEND_VER ".0", + .copyright = "LGPL", + .status = RIG_STATUS_ALPHA, + .rig_type = RIG_TYPE_RECEIVER, + .ptt_type = RIG_PTT_NONE, + .dcd_type = RIG_DCD_NONE, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 4800, + .serial_rate_max = 4800, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 20, + .timeout = 1000, + .retry = 0, + + .has_get_func = RIG_FUNC_NONE, + .has_set_func = RIG_FUNC_NONE, + .has_get_level = RIG_LEVEL_NONE, + .has_set_level = JST145_LEVEL, + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + .level_gran = {}, + .parm_gran = {}, + .ctcss_list = NULL, + .dcs_list = NULL, + .preamp = { RIG_DBLST_END }, + .attenuator = { 20, RIG_DBLST_END }, + .max_rit = Hz(0), + .max_xit = Hz(0), + .max_ifshift = Hz(0), + .targetable_vfo = RIG_TARGETABLE_FREQ, + .transceive = RIG_TRN_OFF, + .vfo_ops = RIG_OP_FROM_VFO, + .scan_ops = RIG_SCAN_NONE, + .bank_qty = 0, + .chan_desc_sz = 0, + + .chan_list = { + { 0, 199, RIG_MTYPE_MEM, JST145_MEM_CAP }, + RIG_CHAN_END + }, + + .rx_range_list1 = { + {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + RIG_FRNG_END, + }, + .tx_range_list1 = { RIG_FRNG_END, }, + .rx_range_list2 = { + {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + RIG_FRNG_END, + }, + .tx_range_list2 = { RIG_FRNG_END, }, + + .tuning_steps = { + {JST145_MODES, 10}, + RIG_TS_END, + }, + /* mode/filter list, .remember = order matters! */ + .filters = { + {RIG_MODE_FM, kHz(12)}, + {RIG_MODE_FM, kHz(6)}, + {RIG_MODE_AM, kHz(6)}, + {RIG_MODE_AM, kHz(2)}, + {RIG_MODE_AM, kHz(12)}, + {RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(2)}, + {RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(1)}, + {RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(6)}, + {RIG_MODE_CW, kHz(1)}, + {RIG_MODE_CW, kHz(2)}, + RIG_FLT_END, + }, + + .rig_open = jst145_open, + .rig_close = jst145_close, + .set_freq = jst145_set_freq, + .get_freq = jst145_get_freq, + .set_mode = jst145_set_mode, + .get_mode = jst145_get_mode, + .set_func = jst145_set_func, + .set_level = jst145_set_level, + .set_mem = jst145_set_mem, + .vfo_op = jst145_vfo_op +}; + +/* + * Function definitions below + */ + +static int jst145_open(RIG *rig) +{ + return write_block(&rig->state.rigport, "H1\r", 2); +} + +static int jst145_close(RIG *rig) +{ + return write_block(&rig->state.rigport, "H0\r", 2); +} + +static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ + char freqbuf[12]; + + snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq / 10), + vfo == RIG_VFO_A ? 'A' : 'B'); + + return write_block(&rig->state.rigport, freqbuf, strlen(freqbuf)); +} +static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ + char freqbuf[12]; + char cmd[12]; + int freqbuf_size = 12; + int retval; + int n; + + snprintf(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B'); + retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__, + rigerror(retval)); + return retval; + } + + n = sscanf(freqbuf, "F%lf", freq); + + if (n != 1) { retval = -RIG_EPROTO; } + + return retval; +} + +static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) +{ + int retval; + char *modestr; + + switch (mode) + { + case RIG_MODE_RTTY: modestr = "D0\r"; break; + + case RIG_MODE_CW: modestr = "D1\r"; break; + + case RIG_MODE_USB: modestr = "D2\r"; break; + + case RIG_MODE_LSB: modestr = "D3\r"; break; + + case RIG_MODE_AM: modestr = "D4\r"; break; + + case RIG_MODE_FM: modestr = "D5\r"; break; + + default: + return -RIG_EINVAL; + } + + retval = write_block(&rig->state.rigport, modestr, strlen(modestr)); + + if (retval != RIG_OK) + { + return retval; + } + + if (RIG_PASSBAND_NOCHANGE == width) { return retval; } + + + // TODO: width -- could use B command but let user handle it for now + + return retval; +} + +static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +{ + char cmd[12]; + char modebuf[12]; + int modebuf_len = sizeof(modebuf); + int retval; + + snprintf(cmd, sizeof(cmd), "I\r"); + + retval = jrc_transaction(rig, cmd, strlen(cmd), modebuf, &modebuf_len); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: jrc_transcation failed: %s\n", __func__, + rigerror(retval)); + } + + return retval; +} + +static int jst145_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) +{ + return -RIG_ENIMPL; +} + +static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +{ + switch (level) + { + + case RIG_LEVEL_AGC: + return write_block(&rig->state.rigport, + val.i == RIG_AGC_SLOW ? "G0" : + (val.i == RIG_AGC_FAST ? "G1" : "G2"), 2); + + default: + return -RIG_EINVAL; + } + + return -RIG_EINVAL; +} + +static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch) +{ + char membuf[12]; + + sprintf(membuf, "C%03d", ch); + + return write_block(&rig->state.rigport, membuf, strlen(membuf)); +} + +static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) +{ + switch (op) + { + case RIG_OP_FROM_VFO: + return write_block(&rig->state.rigport, "E1", 2); + + default: + return -RIG_EINVAL; + } + + return -RIG_EINVAL; +} + From 32ce1bae50706daf6d8e3bba5d135f69fa23ff70 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 12 Dec 2021 23:42:00 -0600 Subject: [PATCH 03/22] Fix no-autopower and echo off for Icom https://github.com/Hamlib/Hamlib/issues/885 --- rigs/icom/icom.c | 5 ++++- rigs/icom/icom.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index e69e9092a..7d5675368 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -943,7 +943,10 @@ icom_rig_open(RIG *rig) retry_open: retval_echo = icom_get_usb_echo_off(rig); - if (retval_echo == 0 || retval_echo == 1) // then we know our echo status + if (retval_echo == 0 || retval_echo == 1) { retval = RIG_OK; } + else { retval = retval_echo; } + + if (retval == RIG_OK) // then we know our echo status { rig->state.current_vfo = icom_current_vfo(rig); // some rigs like the IC7100 still echo when in standby diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index cdf9c97ca..71ec89185 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20211212" +#define BACKEND_VER "20211213" #define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B)) #define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00) From baa70cdca11d9f2a61985b240558cb8890b1a844 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 00:00:42 -0600 Subject: [PATCH 04/22] Add JRC JST-245 --- rigs/jrc/jrc.c | 1 + rigs/jrc/jrc.h | 1 + rigs/jrc/jst145.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c index 5e0f4f5cf..93667bd97 100644 --- a/rigs/jrc/jrc.c +++ b/rigs/jrc/jrc.c @@ -1684,6 +1684,7 @@ DECLARE_INITRIG_BACKEND(jrc) rig_register(&nrd545_caps); rig_register(&nrd525_caps); rig_register(&jst145_caps); + rig_register(&jst245_caps); return RIG_OK; } diff --git a/rigs/jrc/jrc.h b/rigs/jrc/jrc.h index 890903986..ef8d80a4d 100644 --- a/rigs/jrc/jrc.h +++ b/rigs/jrc/jrc.h @@ -68,6 +68,7 @@ extern const struct rig_caps nrd535_caps; extern const struct rig_caps nrd545_caps; extern const struct rig_caps nrd525_caps; extern const struct rig_caps jst145_caps; +extern const struct rig_caps jst245_caps; #endif /* _JRC_H */ diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 1efc5ebc6..4b8b3792d 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -153,6 +153,102 @@ const struct rig_caps jst145_caps = .vfo_op = jst145_vfo_op }; +/* + * JST-245 rig capabilities. + * + */ +const struct rig_caps jst245_caps = +{ + RIG_MODEL(RIG_MODEL_JST245), + .model_name = "JST-245", + .mfg_name = "JRC", + .version = BACKEND_VER ".0", + .copyright = "LGPL", + .status = RIG_STATUS_ALPHA, + .rig_type = RIG_TYPE_RECEIVER, + .ptt_type = RIG_PTT_NONE, + .dcd_type = RIG_DCD_NONE, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 4800, + .serial_rate_max = 4800, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 20, + .timeout = 1000, + .retry = 0, + + .has_get_func = RIG_FUNC_NONE, + .has_set_func = RIG_FUNC_NONE, + .has_get_level = RIG_LEVEL_NONE, + .has_set_level = JST145_LEVEL, + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + .level_gran = {}, + .parm_gran = {}, + .ctcss_list = NULL, + .dcs_list = NULL, + .preamp = { RIG_DBLST_END }, + .attenuator = { 20, RIG_DBLST_END }, + .max_rit = Hz(0), + .max_xit = Hz(0), + .max_ifshift = Hz(0), + .targetable_vfo = RIG_TARGETABLE_FREQ, + .transceive = RIG_TRN_OFF, + .vfo_ops = RIG_OP_FROM_VFO, + .scan_ops = RIG_SCAN_NONE, + .bank_qty = 0, + .chan_desc_sz = 0, + + .chan_list = { + { 0, 199, RIG_MTYPE_MEM, JST145_MEM_CAP }, + RIG_CHAN_END + }, + + .rx_range_list1 = { + {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + RIG_FRNG_END, + }, + .tx_range_list1 = { RIG_FRNG_END, }, + .rx_range_list2 = { + {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + RIG_FRNG_END, + }, + .tx_range_list2 = { RIG_FRNG_END, }, + + .tuning_steps = { + {JST145_MODES, 10}, + RIG_TS_END, + }, + /* mode/filter list, .remember = order matters! */ + .filters = { + {RIG_MODE_FM, kHz(12)}, + {RIG_MODE_FM, kHz(6)}, + {RIG_MODE_AM, kHz(6)}, + {RIG_MODE_AM, kHz(2)}, + {RIG_MODE_AM, kHz(12)}, + {RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(2)}, + {RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(1)}, + {RIG_MODE_SSB | RIG_MODE_RTTY | RIG_MODE_FAX, kHz(6)}, + {RIG_MODE_CW, kHz(1)}, + {RIG_MODE_CW, kHz(2)}, + RIG_FLT_END, + }, + + .rig_open = jst145_open, + .rig_close = jst145_close, + .set_freq = jst145_set_freq, + .get_freq = jst145_get_freq, + .set_mode = jst145_set_mode, + .get_mode = jst145_get_mode, + .set_func = jst145_set_func, + .set_level = jst145_set_level, + .set_mem = jst145_set_mem, + .vfo_op = jst145_vfo_op +}; + /* * Function definitions below */ From 465d14ff3039539c95220ff3e68f6dd51408a51a Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 09:07:40 -0600 Subject: [PATCH 05/22] Change dummy ptt_type to None https://github.com/Hamlib/Hamlib/issues/888 --- rigs/dummy/dummy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index df01574d7..f4517f0f2 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -2244,12 +2244,12 @@ struct rig_caps dummy_caps = RIG_MODEL(RIG_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20211130.0", + .version = "20211213.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, .targetable_vfo = RIG_TARGETABLE_PTT | RIG_TARGETABLE_RITXIT | RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE | RIG_TARGETABLE_SPECTRUM, - .ptt_type = RIG_PTT_RIG, + .ptt_type = RIG_PTT_NONE, .dcd_type = RIG_DCD_RIG, .port_type = RIG_PORT_NONE, .has_get_func = DUMMY_FUNC, From 4c0af35163504501514fe598e57e7bf2705a2e4e Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 09:15:51 -0600 Subject: [PATCH 06/22] Update testcache to not use PTT for dummy device --- tests/testcache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testcache.c b/tests/testcache.c index f0485c242..a8301c728 100644 --- a/tests/testcache.c +++ b/tests/testcache.c @@ -130,6 +130,7 @@ int main(int argc, char *argv[]) if (widthC != 3000) { printf("widthC = %d\n", (int)widthC); exit(1); } +#if 0 // PTT does not work for dummy device printf("PTT ON\n"); rig_set_ptt(my_rig, RIG_VFO_CURR, RIG_PTT_ON); ptt_t ptt; @@ -151,6 +152,7 @@ int main(int argc, char *argv[]) rig_get_ptt(my_rig, RIG_VFO_CURR, &ptt); printf("PTT get ptt OFF\n"); +#endif vfo_t tx_vfo; split_t split; From 09aae91d37ef9f7f06b284f79cba8ef308a6c2c9 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 12:52:03 -0600 Subject: [PATCH 07/22] Add some debug to icom.c chasing down bug https://github.com/Hamlib/Hamlib/issues/885 --- rigs/icom/icom.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7d5675368..894d5f376 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -943,11 +943,14 @@ icom_rig_open(RIG *rig) retry_open: retval_echo = icom_get_usb_echo_off(rig); + rig_debug(RIG_DEBUG_TRACE, "%s: retval_echo=%d\n", __func__, retval_echo); + if (retval_echo == 0 || retval_echo == 1) { retval = RIG_OK; } else { retval = retval_echo; } if (retval == RIG_OK) // then we know our echo status { + rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting freq\n", __func__); rig->state.current_vfo = icom_current_vfo(rig); // some rigs like the IC7100 still echo when in standby // so asking for freq now should timeout if such a rig @@ -956,6 +959,7 @@ retry_open: } else { + rig_debug(RIG_DEBUG_TRACE, "%s: echo status unknown\n", __func__); retval = -RIG_EPROTO; } From 6aa7f9e9bc169eb71b428d59262da999caa78a65 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 13:18:48 -0600 Subject: [PATCH 08/22] Remove read_update_delay from Yaesue files -- not used --- NEWS | 3 ++- cppcheck.sh | 2 +- rigs/yaesu/ft1000d.c | 4 ---- rigs/yaesu/ft1000mp.c | 3 --- rigs/yaesu/ft757gx.c | 3 --- rigs/yaesu/ft767gx.c | 3 --- rigs/yaesu/ft840.c | 3 --- rigs/yaesu/ft890.c | 3 --- rigs/yaesu/ft900.c | 3 --- rigs/yaesu/ft920.c | 3 --- rigs/yaesu/ft990.c | 4 ---- rigs/yaesu/newcat.c | 5 ----- rigs/yaesu/newcat.h | 5 +---- 13 files changed, 4 insertions(+), 40 deletions(-) diff --git a/NEWS b/NEWS index 262862a19..a4b995662 100644 --- a/NEWS +++ b/NEWS @@ -6,8 +6,9 @@ Copyright (C) 2000-2021 Michael Black W9MDB, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net -Version 4.5 +Version 4.x * 202?-??-?? + * Added JRC JST-145 and JST-245 Version 4.4 * 2021-12-02 diff --git a/cppcheck.sh b/cppcheck.sh index 8389b07c2..d71b45ba9 100755 --- a/cppcheck.sh +++ b/cppcheck.sh @@ -80,7 +80,7 @@ CHECK="\ if test $# -eq 0 ; then echo "See cppcheck.log when done" echo "This takes a while to run" - strace -f cppcheck --inline-suppr \ + cppcheck --inline-suppr \ -I src \ -I include \ --include=include/config.h \ diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 62b5106fb..d328b0f6c 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -247,7 +247,6 @@ static const yaesu_cmd_set_t ncmd[] = struct ft1000d_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ vfo_t split_vfo; /* TX VFO in split mode Added on 16 Dec 2016 to include FT1000D function */ split_t split; /* split active or not Added on 16 Dec 2016 to include FT1000D function */ @@ -444,9 +443,6 @@ static int ft1000d_init(RIG *rig) // Set default pacing value priv->pacing = FT1000D_PACING_DEFAULT_VALUE; - // Set update timeout - priv->read_update_delay = FT1000D_DEFAULT_READ_TIMEOUT; - // Set operating vfo mode to current VFO changed from RIG_VFO_MAIN to RIG_VFO_A December 2016 priv->current_vfo = RIG_VFO_A; diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 0868c89d0..174370d94 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -296,7 +296,6 @@ static tone_t ft1000mp_ctcss_list[] = struct ft1000mp_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ unsigned char update_data[2 * @@ -740,8 +739,6 @@ static int ft1000mp_init(RIG *rig) /* TODO: read pacing from preferences */ priv->pacing = FT1000MP_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT1000MP_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ RETURNFUNC(RIG_OK); } diff --git a/rigs/yaesu/ft757gx.c b/rigs/yaesu/ft757gx.c index 81efbcd96..05270daa0 100644 --- a/rigs/yaesu/ft757gx.c +++ b/rigs/yaesu/ft757gx.c @@ -88,7 +88,6 @@ static int rig2mode(RIG *rig, int md, rmode_t *mode, pbwidth_t *width); struct ft757_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ unsigned char current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */ unsigned char @@ -375,8 +374,6 @@ static int ft757_init(RIG *rig) priv->pacing = FT757GX_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT757GX_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_A; /* default to VFO_A ? */ return RIG_OK; diff --git a/rigs/yaesu/ft767gx.c b/rigs/yaesu/ft767gx.c index 290f4a6de..e4b4f0ce8 100644 --- a/rigs/yaesu/ft767gx.c +++ b/rigs/yaesu/ft767gx.c @@ -240,7 +240,6 @@ static int rig2ctcss(RIG *rig, unsigned char tn, tone_t *tone); struct ft767_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ unsigned char current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */ unsigned char @@ -413,8 +412,6 @@ int ft767_init(RIG *rig) /* TODO: read pacing from preferences */ priv->pacing = FT767GX_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT767GX_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_A; /* default to VFO_A ? */ priv->ack_cmd[0] = 00; priv->ack_cmd[1] = 00; diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index 6e37955be..7122de90d 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -230,7 +230,6 @@ static const yaesu_cmd_set_t ncmd[] = struct ft840_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ @@ -400,8 +399,6 @@ static int ft840_init(RIG *rig) /* TODO: read pacing from preferences */ priv->pacing = FT840_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT840_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */ return RIG_OK; diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index 3f890d7ab..7245c5d07 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -382,7 +382,6 @@ static const yaesu_cmd_set_t ncmd[] = struct ft890_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ @@ -550,8 +549,6 @@ static int ft890_init(RIG *rig) /* TODO: read pacing from preferences */ priv->pacing = FT890_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT890_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */ return RIG_OK; diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index 58bf96bd9..ba88266d5 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -403,7 +403,6 @@ static const yaesu_cmd_set_t ncmd[] = struct ft900_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ @@ -572,8 +571,6 @@ static int ft900_init(RIG *rig) /* TODO: read pacing from preferences */ priv->pacing = FT900_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT900_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */ return RIG_OK; diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index 15812bebd..ffcc1a3de 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -392,7 +392,6 @@ static const yaesu_cmd_set_t ncmd[] = struct ft920_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ vfo_t split_vfo; /* TX VFO in split mode */ split_t split; /* split active or not */ @@ -647,8 +646,6 @@ static int ft920_init(RIG *rig) /* TODO: read pacing from preferences */ priv->pacing = FT920_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - FT920_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_A; /* default to VFO_A */ return RIG_OK; diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index 4ad1e559a..f993d6aee 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -218,7 +218,6 @@ static const yaesu_cmd_set_t ncmd[] = struct ft990_priv_data { unsigned char pacing; /* pacing value */ - unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of CAT cmd */ ft990_update_data_t update_data; /* returned data */ @@ -408,9 +407,6 @@ int ft990_init(RIG *rig) // Set default pacing value priv->pacing = FT990_PACING_DEFAULT_VALUE; - // Set update timeout - priv->read_update_delay = FT990_DEFAULT_READ_TIMEOUT; - // Set operating vfo mode to current VFO priv->current_vfo = RIG_VFO_MAIN; diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 85d6ad2cc..2fb296c8d 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -469,11 +469,6 @@ int newcat_init(RIG *rig) priv = rig->state.priv; - /* TODO: read pacing from preferences */ - // priv->pacing = NEWCAT_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ - priv->read_update_delay = - NEWCAT_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ - // priv->current_vfo = RIG_VFO_MAIN; /* default to whatever */ // priv->current_vfo = RIG_VFO_A; diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 89108f4bd..aa03e93ef 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20211202" +#define NEWCAT_VER "20211213" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 @@ -102,9 +102,6 @@ struct newcat_priv_caps */ struct newcat_priv_data { - unsigned int - read_update_delay; /* depends on pacing value */ -// vfo_t current_vfo; /* active VFO from last cmd */ char cmd_str[NEWCAT_DATA_LEN]; /* command string buffer */ char ret_data[NEWCAT_DATA_LEN]; /* returned data--max value, most are less */ From 41eb23bb26a27f8af8badadba45c8edbbcb6a0c8 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 16:15:26 -0600 Subject: [PATCH 09/22] Update jst145 Add and fix agclevel calls --- include/hamlib/rig.h | 1 + rigs/jrc/jst145.c | 16 ++++++++-------- src/misc.c | 24 ++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 1486f4cb6..64ed2afc1 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -3156,6 +3156,7 @@ extern HAMLIB_EXPORT(const char *) rig_strparm(setting_t); extern HAMLIB_EXPORT(const char *) rig_stragclevel(enum agc_level_e level); extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcstr (char *agcString); extern HAMLIB_EXPORT(enum agc_level_e) rig_levelagcvalue (int agcValue); +extern HAMLIB_EXPORT(value_t) rig_valueagclevel (enum agc_level_e agcLevel); extern HAMLIB_EXPORT(const char *) rig_strptrshift(rptr_shift_t); extern HAMLIB_EXPORT(const char *) rig_strvfop(vfo_op_t op); extern HAMLIB_EXPORT(const char *) rig_strscan(scan_t scan); diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 4b8b3792d..295d5f2c5 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -66,7 +66,7 @@ const struct rig_caps jst145_caps = RIG_MODEL(RIG_MODEL_JST145), .model_name = "JST-145", .mfg_name = "JRC", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .rig_type = RIG_TYPE_RECEIVER, @@ -162,7 +162,7 @@ const struct rig_caps jst245_caps = RIG_MODEL(RIG_MODEL_JST245), .model_name = "JST-245", .mfg_name = "JRC", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .rig_type = RIG_TYPE_RECEIVER, @@ -255,12 +255,12 @@ const struct rig_caps jst245_caps = static int jst145_open(RIG *rig) { - return write_block(&rig->state.rigport, "H1\r", 2); + return write_block(&rig->state.rigport, "H1\r", 3); } static int jst145_close(RIG *rig) { - return write_block(&rig->state.rigport, "H0\r", 2); + return write_block(&rig->state.rigport, "H0\r", 3); } static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) @@ -367,8 +367,8 @@ static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) case RIG_LEVEL_AGC: return write_block(&rig->state.rigport, - val.i == RIG_AGC_SLOW ? "G0" : - (val.i == RIG_AGC_FAST ? "G1" : "G2"), 2); + val.i == RIG_AGC_SLOW ? "G0\r" : + (val.i == RIG_AGC_FAST ? "G1\r" : "G2\r"), 3); default: return -RIG_EINVAL; @@ -381,7 +381,7 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch) { char membuf[12]; - sprintf(membuf, "C%03d", ch); + sprintf(membuf, "C%03d\r", ch); return write_block(&rig->state.rigport, membuf, strlen(membuf)); } @@ -391,7 +391,7 @@ static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) switch (op) { case RIG_OP_FROM_VFO: - return write_block(&rig->state.rigport, "E1", 2); + return write_block(&rig->state.rigport, "E1\r", 3); default: return -RIG_EINVAL; diff --git a/src/misc.c b/src/misc.c index 45e49f7f7..e8fd9eb27 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1266,12 +1266,32 @@ const char *HAMLIB_API rig_stragclevel(enum agc_level_e level) return ""; } +/** + * \brief Convert a enum agc_level_e to value + * \param integer... + * \return agc_level_e value + */ +value_t rig_valueagclevel (enum agc_level_e agcLevel) +{ + value_t value; + + if (agcLevel == RIG_AGC_OFF) value.i = 0; + else if (agcLevel == RIG_AGC_SUPERFAST) value.i = 1; + else if (agcLevel == RIG_AGC_FAST) value.i = 2; + else if (agcLevel == RIG_AGC_SLOW) value.i = 3; + else if (agcLevel == RIG_AGC_USER) value.i = 4; + else if (agcLevel == RIG_AGC_MEDIUM) value.i = 5; + else value.i = 6; //RIG_AGC_AUTO + + return value; +} + /** * \brief Convert a value to agc_level_e -- constrains the range * \param integer... * \return agc_level_e */ -enum agc_level_e levelagcvalue(int agcValue) +enum agc_level_e rig_levelagcvalue(int agcValue) { enum agc_level_e agcLevel; @@ -1302,7 +1322,7 @@ enum agc_level_e levelagcvalue(int agcValue) * \param mode AGC string... * \return agc_level_e */ -enum agc_level_e levelagcstr(char *agcString) +enum agc_level_e rig_levelagcstr(char *agcString) { enum agc_level_e agcLevel; From e9b732d6fde5e7affe388129d13f54068775b6da Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 17:06:17 -0600 Subject: [PATCH 10/22] More jst145 changes --- rigs/jrc/jst145.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 295d5f2c5..3434a88c2 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -34,6 +34,8 @@ static int jst145_open(RIG *rig); static int jst145_close(RIG *rig); +static int jst145_set_vfo(RIG *rig, vfo_t vfo); +static int jst145_get_vfo(RIG *rig, vfo_t *vfo); static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); @@ -143,6 +145,8 @@ const struct rig_caps jst145_caps = .rig_open = jst145_open, .rig_close = jst145_close, + .set_vfo = jst145_set_vfo, + .get_vfo = jst145_get_vfo, .set_freq = jst145_set_freq, .get_freq = jst145_get_freq, .set_mode = jst145_set_mode, @@ -239,6 +243,8 @@ const struct rig_caps jst245_caps = .rig_open = jst145_open, .rig_close = jst145_close, + .set_vfo = jst145_set_vfo, + .get_vfo = jst145_get_vfo, .set_freq = jst145_set_freq, .get_freq = jst145_get_freq, .set_mode = jst145_set_mode, @@ -263,6 +269,37 @@ static int jst145_close(RIG *rig) return write_block(&rig->state.rigport, "H0\r", 3); } +static int jst145_set_vfo(RIG *rig, vfo_t vfo) +{ + char cmd[12]; + snprintf(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B'); + + return write_block(&rig->state.rigport, cmd, strlen(cmd)); +} + +static int jst145_get_vfo(RIG *rig, vfo_t *vfo) +{ + char cmd[12]; + char channel[12]; + int channel_size = sizeof(channel); + int retval; + + snprintf(cmd, sizeof(cmd), "L\r"); + + retval = jrc_transaction(rig, cmd, strlen(cmd), channel, &channel_size); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__, + rigerror(retval)); + return retval; + } + + *vfo = channel[1] == 'A' ? RIG_VFO_A : RIG_VFO_B; + + return RIG_OK; +} + static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { char freqbuf[12]; @@ -279,8 +316,10 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int freqbuf_size = 12; int retval; int n; + char vfoc; - snprintf(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B'); + rig_set_vfo(rig, vfo); + snprintf(cmd, sizeof(cmd), "L\r"); retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size); if (retval != RIG_OK) @@ -290,9 +329,11 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return retval; } - n = sscanf(freqbuf, "F%lf", freq); + n = sscanf(freqbuf, "L%c%lf", &vfoc, freq); - if (n != 1) { retval = -RIG_EPROTO; } + if (n != 2) { retval = -RIG_EPROTO; } + + if (vfoc == 'B') { rig_set_vfo(rig, RIG_VFO_A); } return retval; } @@ -352,6 +393,21 @@ static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) rigerror(retval)); } + switch (modebuf[3]) + { + case '0': *mode = RIG_MODE_RTTY; break; + + case '1': *mode = RIG_MODE_CW; break; + + case '2': *mode = RIG_MODE_USB; break; + + case '3': *mode = RIG_MODE_LSB; break; + + case '4': *mode = RIG_MODE_AM; break; + + case '5': *mode = RIG_MODE_FM; break; + } + return retval; } From dda13b91c66fc4118f2e7db9c068338ad61f9e34 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 17:13:10 -0600 Subject: [PATCH 11/22] More jst145 changes --- rigs/jrc/jst145.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 3434a88c2..10459156f 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -271,7 +271,7 @@ static int jst145_close(RIG *rig) static int jst145_set_vfo(RIG *rig, vfo_t vfo) { - char cmd[12]; + char cmd[24]; snprintf(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B'); return write_block(&rig->state.rigport, cmd, strlen(cmd)); @@ -279,8 +279,8 @@ static int jst145_set_vfo(RIG *rig, vfo_t vfo) static int jst145_get_vfo(RIG *rig, vfo_t *vfo) { - char cmd[12]; - char channel[12]; + char cmd[24]; + char channel[24]; int channel_size = sizeof(channel); int retval; @@ -302,7 +302,7 @@ static int jst145_get_vfo(RIG *rig, vfo_t *vfo) static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - char freqbuf[12]; + char freqbuf[24]; snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq / 10), vfo == RIG_VFO_A ? 'A' : 'B'); @@ -311,9 +311,9 @@ static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - char freqbuf[12]; - char cmd[12]; - int freqbuf_size = 12; + char freqbuf[24]; + char cmd[24]; + int freqbuf_size = sizeof(freqbuf); int retval; int n; char vfoc; @@ -378,8 +378,8 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - char cmd[12]; - char modebuf[12]; + char cmd[24]; + char modebuf[24]; int modebuf_len = sizeof(modebuf); int retval; @@ -435,7 +435,7 @@ static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch) { - char membuf[12]; + char membuf[24]; sprintf(membuf, "C%03d\r", ch); From 16cf1990155faaf547b2bb6a8349d0349557f965 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 13 Dec 2021 23:12:29 -0600 Subject: [PATCH 12/22] JST-145 is now working with WSJT-X --- rigs/jrc/jst145.c | 138 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 123 insertions(+), 15 deletions(-) diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 10459156f..5cf8dfc3d 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -32,6 +32,7 @@ #include "jrc.h" +static int jst145_init(RIG *rig); static int jst145_open(RIG *rig); static int jst145_close(RIG *rig); static int jst145_set_vfo(RIG *rig, vfo_t vfo); @@ -45,6 +46,8 @@ static int jst145_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch); +static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); #define JST145_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_FAX) @@ -59,6 +62,14 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch); .levels = RIG_LEVEL_AGC, \ } +struct jst145_priv_data +{ + ptt_t ptt; + freq_t freqA, freqB; + mode_t mode; +}; + + /* * JST-145 rig capabilities. * @@ -70,9 +81,9 @@ const struct rig_caps jst145_caps = .mfg_name = "JRC", .version = BACKEND_VER ".1", .copyright = "LGPL", - .status = RIG_STATUS_ALPHA, - .rig_type = RIG_TYPE_RECEIVER, - .ptt_type = RIG_PTT_NONE, + .status = RIG_STATUS_STABLE, + .rig_type = RIG_TYPE_TRANSCEIVER, + .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_NONE, .port_type = RIG_PORT_SERIAL, .serial_rate_min = 4800, @@ -82,9 +93,9 @@ const struct rig_caps jst145_caps = .serial_parity = RIG_PARITY_NONE, .serial_handshake = RIG_HANDSHAKE_NONE, .write_delay = 0, - .post_write_delay = 20, + .post_write_delay = 0, .timeout = 1000, - .retry = 0, + .retry = 1, .has_get_func = RIG_FUNC_NONE, .has_set_func = RIG_FUNC_NONE, @@ -154,7 +165,9 @@ const struct rig_caps jst145_caps = .set_func = jst145_set_func, .set_level = jst145_set_level, .set_mem = jst145_set_mem, - .vfo_op = jst145_vfo_op + .vfo_op = jst145_vfo_op, + .set_ptt = jst145_set_ptt, + .get_ptt = jst145_get_ptt }; /* @@ -168,9 +181,9 @@ const struct rig_caps jst245_caps = .mfg_name = "JRC", .version = BACKEND_VER ".1", .copyright = "LGPL", - .status = RIG_STATUS_ALPHA, - .rig_type = RIG_TYPE_RECEIVER, - .ptt_type = RIG_PTT_NONE, + .status = RIG_STATUS_STABLE, + .rig_type = RIG_TYPE_TRANSCEIVER, + .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_NONE, .port_type = RIG_PORT_SERIAL, .serial_rate_min = 4800, @@ -241,6 +254,7 @@ const struct rig_caps jst245_caps = RIG_FLT_END, }, + .rig_init = jst145_init, .rig_open = jst145_open, .rig_close = jst145_close, .set_vfo = jst145_set_vfo, @@ -252,16 +266,53 @@ const struct rig_caps jst245_caps = .set_func = jst145_set_func, .set_level = jst145_set_level, .set_mem = jst145_set_mem, - .vfo_op = jst145_vfo_op + .vfo_op = jst145_vfo_op, + .set_ptt = jst145_set_ptt, + .get_ptt = jst145_get_ptt }; /* * Function definitions below */ + +static int jst145_init(RIG *rig) +{ + struct jst145_priv_data *priv; + priv = (struct jst145_priv_data *)malloc(sizeof(struct jst145_priv_data)); + + if (!priv) + { + return -RIG_ENOMEM; + } + + rig->state.priv = (void *)priv; + return RIG_OK; +} + static int jst145_open(RIG *rig) { - return write_block(&rig->state.rigport, "H1\r", 3); + int retval; + freq_t freq; + rmode_t mode; + pbwidth_t width; + struct jst145_priv_data *priv = rig->state.priv; + + retval = write_block(&rig->state.rigport, "H1\r", 3); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: H1 failed: %s\n", __func__, rigerror(retval)); + return retval; + } + + jst145_get_freq(rig, RIG_VFO_A, &freq); + priv->freqA = freq; + jst145_get_freq(rig, RIG_VFO_B, &freq); + priv->freqB = freq; + jst145_get_mode(rig, RIG_VFO_A, &mode, &width); + priv->mode = mode; + return retval; } static int jst145_close(RIG *rig) @@ -303,12 +354,24 @@ static int jst145_get_vfo(RIG *rig, vfo_t *vfo) static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { char freqbuf[24]; + struct jst145_priv_data *priv = rig->state.priv; - snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq / 10), + snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq), vfo == RIG_VFO_A ? 'A' : 'B'); + if (vfo == RIG_VFO_B) + { + priv->freqB = freq; + } + else + { + priv->freqA = freq; + } + return write_block(&rig->state.rigport, freqbuf, strlen(freqbuf)); } + + static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { char freqbuf[24]; @@ -318,7 +381,15 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int n; char vfoc; - rig_set_vfo(rig, vfo); + struct jst145_priv_data *priv = rig->state.priv; + + if (priv->ptt) // can't get freq while transmitting + { + *freq = vfo == RIG_VFO_B ? priv->freqB : priv->freqA; + return RIG_OK; + } + + jst145_set_vfo(rig, vfo); snprintf(cmd, sizeof(cmd), "L\r"); retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size); @@ -329,11 +400,11 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return retval; } - n = sscanf(freqbuf, "L%c%lf", &vfoc, freq); + n = sscanf(freqbuf, "L%c%*c%*c%*c%8lf", &vfoc, freq); if (n != 2) { retval = -RIG_EPROTO; } - if (vfoc == 'B') { rig_set_vfo(rig, RIG_VFO_A); } + if (vfoc == 'B') { jst145_set_vfo(rig, RIG_VFO_A); } return retval; } @@ -342,6 +413,7 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { int retval; char *modestr; + struct jst145_priv_data *priv = rig->state.priv; switch (mode) { @@ -368,6 +440,8 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return retval; } + priv->mode = mode; + if (RIG_PASSBAND_NOCHANGE == width) { return retval; } @@ -456,3 +530,37 @@ static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) return -RIG_EINVAL; } +static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +{ + char cmd[24]; + struct jst145_priv_data *priv = rig->state.priv; + rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__); + snprintf(cmd, sizeof(cmd), "X%c\r", ptt ? '1' : '0'); + priv->ptt = ptt; + return write_block(&rig->state.rigport, cmd, strlen(cmd)); +} + +static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) +{ + char cmd[24]; + char pttstatus[24]; + int pttstatus_size = sizeof(pttstatus); + int retval; + + rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__); + + snprintf(cmd, sizeof(cmd), "X\r"); + retval = jrc_transaction(rig, cmd, strlen(cmd), pttstatus, &pttstatus_size); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: jrc_transaction error: %s\n", __func__, + rigerror(retval)); + return retval; + } + + if (pttstatus[1] == '1') { *ptt = RIG_PTT_ON; } + else { *ptt = RIG_PTT_OFF; } + + return RIG_OK; +} From 7ea9eb3f13f0358285e4900522870de6edaa6be4 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 14 Dec 2021 09:06:29 -0600 Subject: [PATCH 13/22] Add power table to FTDX5000 since it's a 200W rig --- rigs/yaesu/ft5000.c | 3 ++- rigs/yaesu/ft5000.h | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/rigs/yaesu/ft5000.c b/rigs/yaesu/ft5000.c index 3faa0805d..b02b5d775 100644 --- a/rigs/yaesu/ft5000.c +++ b/rigs/yaesu/ft5000.c @@ -142,7 +142,7 @@ const struct rig_caps ftdx5000_caps = RIG_MODEL(RIG_MODEL_FTDX5000), .model_name = "FTDX-5000", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".1", + .version = NEWCAT_VER ".2", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -184,6 +184,7 @@ const struct rig_caps ftdx5000_caps = .transceive = RIG_TRN_OFF, /* May enable later as the 5000 has an Auto Info command */ .bank_qty = 0, .chan_desc_sz = 0, + .rfpower_meter_cal = FT5000_RFPOWER_METER_CAL, .str_cal = FTDX5000_STR_CAL, .chan_list = { { 1, 99, RIG_MTYPE_MEM, NEWCAT_MEM_CAP }, diff --git a/rigs/yaesu/ft5000.h b/rigs/yaesu/ft5000.h index b7524447d..0a1809931 100644 --- a/rigs/yaesu/ft5000.h +++ b/rigs/yaesu/ft5000.h @@ -92,7 +92,30 @@ { 220, 40 }, /* +40 */ \ { 240, 50 }, /* +50 */ \ { 255, 60 }, /* +60 */ \ - } } + }\ + } + +// Values stolen from FLRig -- thanks to Dave W1HKJ +#define FT5000_RFPOWER_METER_CAL \ + { \ + 14, \ + { \ + {55, 10.0f}, \ + {75, 20.0f}, \ + {101, 40.0f}, \ + {125, 60.0f}, \ + {144, 80.0f}, \ + {161, 100.0f}, \ + {177, 120.0f}, \ + {190, 140.0f}, \ + {202, 160.0f}, \ + {215, 180.0f}, \ + {225, 200.0f}, \ + {237, 220.0f}, \ + {242, 240.0f}, \ + {255, 250.0f}, \ + } \ + } /* From 2f95f7a8f4028153e42b602980efe9321bd96886 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 14 Dec 2021 14:44:24 -0600 Subject: [PATCH 14/22] Adjust power conversion for FTDX101MP --- rigs/yaesu/ftdx101.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/rigs/yaesu/ftdx101.h b/rigs/yaesu/ftdx101.h index ce4c5971d..5ba0a3c02 100644 --- a/rigs/yaesu/ftdx101.h +++ b/rigs/yaesu/ftdx101.h @@ -116,19 +116,23 @@ } #define FTDX101MP_RFPOWER_METER_WATTS_CAL \ { \ - 11, \ + 15, \ { \ - {0, 0.0f}, \ - {69, 10.0f}, \ - {111, 20.0f}, \ - {129, 30.0f}, \ - {143, 40.0f}, \ - {158, 50.0f}, \ - {184, 70.0f}, \ - {200, 80.0f}, \ - {211, 90.0f}, \ - {222, 100.0f}, \ - {255, 200.0f}, \ + {0, 0.0f}, \ + {32, 10.0f}, \ + {53, 20.0f}, \ + {80, 40.0f}, \ + {97, 60.0f}, \ + {119, 80.0f}, \ + {137, 100.0f}, \ + {154, 120.0f}, \ + {167, 140.0f}, \ + {177, 160.0f}, \ + {188, 180.0f}, \ + {197, 200.0f}, \ + {207, 220.0f}, \ + {227, 240.0f}, \ + {247, 260.0f}, \ } \ } From db38378412543307df572ee4469e9b49af9e2098 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 14 Dec 2021 16:54:46 -0600 Subject: [PATCH 15/22] Update FTDX101MP power levels --- rigs/yaesu/ftdx101.h | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/rigs/yaesu/ftdx101.h b/rigs/yaesu/ftdx101.h index 5ba0a3c02..5cbbdd485 100644 --- a/rigs/yaesu/ftdx101.h +++ b/rigs/yaesu/ftdx101.h @@ -119,20 +119,17 @@ 15, \ { \ {0, 0.0f}, \ - {32, 10.0f}, \ - {53, 20.0f}, \ - {80, 40.0f}, \ - {97, 60.0f}, \ - {119, 80.0f}, \ - {137, 100.0f}, \ - {154, 120.0f}, \ - {167, 140.0f}, \ - {177, 160.0f}, \ - {188, 180.0f}, \ - {197, 200.0f}, \ - {207, 220.0f}, \ - {227, 240.0f}, \ - {247, 260.0f}, \ + {32, 20.0f}, \ + {97, 40.0f}, \ + {119, 60.0f}, \ + {137, 80.0f}, \ + {154, 100.0f}, \ + {170, 120.0f}, \ + {180, 140.0f}, \ + {209, 160.0f}, \ + {227, 180.0f}, \ + {240, 200.0f}, \ + {255, 210.0f}, \ } \ } From 1a88ae350b5fa259ea5c2a997354f9bc5e9298c0 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 15 Dec 2021 16:26:22 -0600 Subject: [PATCH 16/22] Fix FTDX3000 and FTDX5000 RF_POWER_METER reading --- rigs/yaesu/newcat.c | 4 ++++ rigs/yaesu/newcat.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 2fb296c8d..30294f924 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4608,6 +4608,10 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM08%c", cat_term); } + else if (is_ftdx3000 || is_ftdx5000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); + } else { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM5%c", cat_term); diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index aa03e93ef..3f5ec558d 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20211213" +#define NEWCAT_VER "20211215" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 From c6c18c0903850fb962dad9041d48647989a6c067 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 15 Dec 2021 16:36:34 -0600 Subject: [PATCH 17/22] Reduced timeout on Icom startup Reduce time to start up when powering up Icom --- rigs/icom/icom.c | 34 ++++++++++++++++++++++------------ rigs/icom/icom.h | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 894d5f376..502bd7b1a 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -732,20 +732,14 @@ int icom_get_usb_echo_off(RIG *rig) unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf); struct rig_state *rs = &rig->state; - int retry_save = rs->rigport.retry; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - // reduce the retry here so it's quicker - rs->rigport.retry = 0; // Check for echo on first by assuming echo is off and checking the answer priv->serial_USB_echo_off = 1; - rig_debug(RIG_DEBUG_VERBOSE, "%s: retry temp set to %d\n", __func__, - rs->rigport.retry); - retval = icom_transaction(rig, C_RD_FREQ, -1, NULL, 0, ackbuf, &ack_len); // if rig is not powered on we get no data and TIMEOUT @@ -757,17 +751,17 @@ int icom_get_usb_echo_off(RIG *rig) { unsigned char buf[16]; priv->serial_USB_echo_off = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected\n", __func__); // we should have a freq response so we'll read it and don't really care // flushing doesn't always work as it depends on timing - read_icom_frame(&rs->rigport, buf, sizeof(buf)); + retval = read_icom_frame(&rs->rigport, buf, sizeof(buf)); + rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected, get freq retval=%d\n", __func__, retval); + if (retval <= 0) RETURNFUNC(-RIG_ETIMEOUT); } else { rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo off detected\n", __func__); } - rs->rigport.retry = retry_save; RETURNFUNC(priv->serial_USB_echo_off); } @@ -933,9 +927,12 @@ icom_rig_open(RIG *rig) struct rig_state *rs = &rig->state; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; int retry_flag = 1; + int retry_save = rs->rigport.retry; ENTERFUNC; + rs->rigport.retry = 0; + priv->no_1a_03_cmd = ENUM_1A_03_UNK; rig_debug(RIG_DEBUG_VERBOSE, "%s: %s v%s\n", __func__, rig->caps->model_name, @@ -951,6 +948,7 @@ retry_open: if (retval == RIG_OK) // then we know our echo status { rig_debug(RIG_DEBUG_TRACE, "%s: echo status known, getting freq\n", __func__); + rs->rigport.retry = 0; rig->state.current_vfo = icom_current_vfo(rig); // some rigs like the IC7100 still echo when in standby // so asking for freq now should timeout if such a rig @@ -960,7 +958,6 @@ retry_open: else { rig_debug(RIG_DEBUG_TRACE, "%s: echo status unknown\n", __func__); - retval = -RIG_EPROTO; } if (retval != RIG_OK && priv->poweron == 0 && rs->auto_power_on) @@ -978,6 +975,7 @@ retry_open: rig_debug(RIG_DEBUG_WARN, "%s: rig_set_powerstat failed: =%s\n", __func__, rigerror(retval)); + rs->rigport.retry = retry_save; RETURNFUNC(retval); } @@ -987,6 +985,7 @@ retry_open: if (retval_echo != 0 && retval_echo != 1) { rig_debug(RIG_DEBUG_ERR, "%s: Unable to determine USB echo status\n", __func__); + rs->rigport.retry = retry_save; RETURNFUNC(retval); } } @@ -1003,6 +1002,7 @@ retry_open: goto retry_open; } + rs->rigport.retry = retry_save; RETURNFUNC(retval); } @@ -1034,6 +1034,7 @@ retry_open: icom_get_freq_range(rig); // try get to get rig range capability dyamically #endif + rs->rigport.retry = retry_save; RETURNFUNC(RIG_OK); } @@ -2164,10 +2165,19 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n", __func__, __LINE__, mode_icom, datamode[0], datamode[1]); - retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]); + + if (!priv->x26cmdfails) + { + retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]); + } + else + { + retval = -RIG_EPROTO; + } if (retval != RIG_OK) { + TRACE; retval = icom_transaction(rig, C_CTL_MEM, dm_sub_cmd, datamode, 2, ackbuf, &ack_len); } @@ -2325,7 +2335,7 @@ int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode, struct rig_state *rs; struct icom_priv_data *priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); rs = &rig->state; priv = (struct icom_priv_data *) rs->priv; diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 71ec89185..442a3d57d 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20211213" +#define BACKEND_VER "20211214" #define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B)) #define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00) From 3cf36a7877be815ddd77b64f2ae52ef599ba0b58 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 15 Dec 2021 16:56:42 -0600 Subject: [PATCH 18/22] Fix SWR meter for FTDX9000 --- rigs/yaesu/newcat.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 30294f924..0110086ca 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4585,7 +4585,14 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) RETURNFUNC(-RIG_ENAVAIL); } - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); + if (is_ftdx9000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM09%c", cat_term); + } + else + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); + } break; case RIG_LEVEL_ALC: From 4d33abeaae869925eb6aab165aaa05283354207c Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 15 Dec 2021 17:01:35 -0600 Subject: [PATCH 19/22] Fix FTDX9000 ALC Meter --- rigs/yaesu/newcat.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 0110086ca..316f643f2 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4601,7 +4601,14 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) RETURNFUNC(-RIG_ENAVAIL); } - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM4%c", cat_term); + if (is_ftdx9000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM07%c", cat_term); + } + else + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM4%c", cat_term); + } break; case RIG_LEVEL_RFPOWER_METER: @@ -9874,8 +9881,7 @@ int newcat_get_cmd(RIG *rig) || strcmp(priv->cmd_str, "RF1;") == 0 || strcmp(priv->cmd_str, "RL0;") == 0 || strcmp(priv->cmd_str, "RL1;") == 0 - || strcmp(priv->cmd_str, "RM0;") == 0 - || strcmp(priv->cmd_str, "RM1;") == 0 + || strncmp(priv->cmd_str, "RM", 2) == 0 || strcmp(priv->cmd_str, "SM0;") == 0 || strcmp(priv->cmd_str, "SM1;") == 0 || strcmp(priv->cmd_str, "SQ0;") == 0 From dc0c5ddcf6625e79389bf093523bcf73608568fa Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 16 Dec 2021 15:21:36 -0600 Subject: [PATCH 20/22] Allow the FTDX3000/5000 to read the meter for SWR when tuner is on --- rigs/yaesu/newcat.c | 22 +++++++++++++++++++--- rigs/yaesu/newcat.h | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 316f643f2..801b730b6 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4593,6 +4593,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); } + break; case RIG_LEVEL_ALC: @@ -4609,6 +4610,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM4%c", cat_term); } + break; case RIG_LEVEL_RFPOWER_METER: @@ -4624,7 +4626,19 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } else if (is_ftdx3000 || is_ftdx5000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); + // The 3000 has to use the meter read for SWR when the tuner is on + // We'll assume the 5000 is the same way for now + int tuner; + newcat_get_func(rig, RIG_VFO_A, RIG_FUNC_TUNER, &tuner); + + if (tuner) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM2%c", cat_term); + } + else + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); + } } else { @@ -11061,7 +11075,8 @@ int newcat_set_clock(RIG *rig, int year, int month, int day, int hour, int min, RETURNFUNC(err); } - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT1%02d%02d%02d%c", hour, min, sec, cat_term); + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT1%02d%02d%02d%c", hour, min, + sec, cat_term); if (RIG_OK != (err = newcat_set_cmd(rig))) { @@ -11070,7 +11085,8 @@ int newcat_set_clock(RIG *rig, int year, int month, int day, int hour, int min, RETURNFUNC(err); } - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT2%c%04d%c", utc_offset>=0?'+':'-', utc_offset, cat_term); + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT2%c%04d%c", + utc_offset >= 0 ? '+' : '-', utc_offset, cat_term); if (RIG_OK != (err = newcat_set_cmd(rig))) { diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 3f5ec558d..bf8193485 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20211215" +#define NEWCAT_VER "20211216" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 From 39d9577c1c1de02a23cac044ef5a5aa9f0192893 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 16 Dec 2021 15:40:44 -0600 Subject: [PATCH 21/22] Ensure FTDX3000/5000 meter is on SWR when reading SWR and tuner is on --- rigs/jrc/jst145.c | 67 ++++++++++++++++++++++++++------------------ rigs/yaesu/newcat.c | 31 ++++++++++---------- simulators/simicom.c | 9 +++++- 3 files changed, 62 insertions(+), 45 deletions(-) diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index 5cf8dfc3d..6c1b158d4 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -49,10 +49,13 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch); static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); +#define MAX_LEN 24 + #define JST145_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_FAX) #define JST145_LEVEL (RIG_LEVEL_AGC) +// Rig has VFOB but for now we won't do much with it except set freq #define JST145_VFO (RIG_VFO_VFO) #define JST145_MEM_CAP { \ @@ -79,7 +82,7 @@ const struct rig_caps jst145_caps = RIG_MODEL(RIG_MODEL_JST145), .model_name = "JST-145", .mfg_name = "JRC", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".2", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -125,12 +128,12 @@ const struct rig_caps jst145_caps = }, .rx_range_list1 = { - {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + {kHz(100), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, RIG_FRNG_END, }, .tx_range_list1 = { RIG_FRNG_END, }, .rx_range_list2 = { - {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + {kHz(100), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, RIG_FRNG_END, }, .tx_range_list2 = { RIG_FRNG_END, }, @@ -179,7 +182,7 @@ const struct rig_caps jst245_caps = RIG_MODEL(RIG_MODEL_JST245), .model_name = "JST-245", .mfg_name = "JRC", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".2", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -225,12 +228,12 @@ const struct rig_caps jst245_caps = }, .rx_range_list1 = { - {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + {kHz(100), MHz(54), JST145_MODES, -1, -1, JST145_VFO}, RIG_FRNG_END, }, .tx_range_list1 = { RIG_FRNG_END, }, .rx_range_list2 = { - {kHz(10), MHz(30), JST145_MODES, -1, -1, JST145_VFO}, + {kHz(100), MHz(54), JST145_MODES, -1, -1, JST145_VFO}, RIG_FRNG_END, }, .tx_range_list2 = { RIG_FRNG_END, }, @@ -322,7 +325,7 @@ static int jst145_close(RIG *rig) static int jst145_set_vfo(RIG *rig, vfo_t vfo) { - char cmd[24]; + char cmd[MAX_LEN]; snprintf(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B'); return write_block(&rig->state.rigport, cmd, strlen(cmd)); @@ -330,10 +333,19 @@ static int jst145_set_vfo(RIG *rig, vfo_t vfo) static int jst145_get_vfo(RIG *rig, vfo_t *vfo) { - char cmd[24]; - char channel[24]; + char cmd[MAX_LEN]; + char channel[MAX_LEN]; int channel_size = sizeof(channel); int retval; + ptt_t ptt; + + jst145_get_ptt(rig, RIG_VFO_A, &ptt); // set priv->ptt to current transmit status + + if (ptt) // can't get vfo while transmitting + { + *vfo = RIG_VFO_A; + return RIG_OK; + } snprintf(cmd, sizeof(cmd), "L\r"); @@ -353,7 +365,7 @@ static int jst145_get_vfo(RIG *rig, vfo_t *vfo) static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - char freqbuf[24]; + char freqbuf[MAX_LEN]; struct jst145_priv_data *priv = rig->state.priv; snprintf(freqbuf, sizeof(freqbuf), "F%08u%c\r", (unsigned)(freq), @@ -374,23 +386,22 @@ static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq) static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - char freqbuf[24]; - char cmd[24]; + char freqbuf[MAX_LEN]; + char cmd[MAX_LEN]; int freqbuf_size = sizeof(freqbuf); int retval; int n; - char vfoc; struct jst145_priv_data *priv = rig->state.priv; - if (priv->ptt) // can't get freq while transmitting + if (!priv->ptt) // can't get freq while transmitting { - *freq = vfo == RIG_VFO_B ? priv->freqB : priv->freqA; - return RIG_OK; + jst145_set_vfo(rig, vfo); + //*freq = vfo == RIG_VFO_B ? priv->freqB : priv->freqA; + //return RIG_OK; } - jst145_set_vfo(rig, vfo); - snprintf(cmd, sizeof(cmd), "L\r"); + snprintf(cmd, sizeof(cmd), "I\r"); retval = jrc_transaction(rig, cmd, strlen(cmd), freqbuf, &freqbuf_size); if (retval != RIG_OK) @@ -400,11 +411,9 @@ static int jst145_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return retval; } - n = sscanf(freqbuf, "L%c%*c%*c%*c%8lf", &vfoc, freq); + n = sscanf(freqbuf, "I%*c%*c%*c%8lf", freq); - if (n != 2) { retval = -RIG_EPROTO; } - - if (vfoc == 'B') { jst145_set_vfo(rig, RIG_VFO_A); } + if (n != 1) { retval = -RIG_EPROTO; } return retval; } @@ -452,8 +461,8 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) static int jst145_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - char cmd[24]; - char modebuf[24]; + char cmd[MAX_LEN]; + char modebuf[MAX_LEN]; int modebuf_len = sizeof(modebuf); int retval; @@ -509,7 +518,7 @@ static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch) { - char membuf[24]; + char membuf[MAX_LEN]; sprintf(membuf, "C%03d\r", ch); @@ -532,7 +541,7 @@ static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { - char cmd[24]; + char cmd[MAX_LEN]; struct jst145_priv_data *priv = rig->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__); snprintf(cmd, sizeof(cmd), "X%c\r", ptt ? '1' : '0'); @@ -542,10 +551,11 @@ static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { - char cmd[24]; - char pttstatus[24]; + char cmd[MAX_LEN]; + char pttstatus[MAX_LEN]; int pttstatus_size = sizeof(pttstatus); int retval; + struct jst145_priv_data *priv = rig->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__); @@ -561,6 +571,7 @@ static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) if (pttstatus[1] == '1') { *ptt = RIG_PTT_ON; } else { *ptt = RIG_PTT_OFF; } + priv->ptt = *ptt; return RIG_OK; } diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 801b730b6..85331fc00 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4589,6 +4589,21 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM09%c", cat_term); } + else if (is_ftdx3000 || is_ftdx5000) + { + // The 3000 has to use the meter read for SWR when the tuner is on + // We'll assume the 5000 is the same way for now + // Also need to ensure SWR is selected for the meter + int tuner; + value_t meter; + newcat_get_func(rig, RIG_VFO_A, RIG_FUNC_TUNER, &tuner); + newcat_get_level(rig, RIG_VFO_A, RIG_LEVEL_METER, &meter); + + if (meter.i == RIG_METER_SWR) + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM%c%c", (tuner + && meter.i == RIG_METER_SWR) ? '2' : '6', + cat_term); + } else { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); @@ -4624,22 +4639,6 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM08%c", cat_term); } - else if (is_ftdx3000 || is_ftdx5000) - { - // The 3000 has to use the meter read for SWR when the tuner is on - // We'll assume the 5000 is the same way for now - int tuner; - newcat_get_func(rig, RIG_VFO_A, RIG_FUNC_TUNER, &tuner); - - if (tuner) - { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM2%c", cat_term); - } - else - { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM6%c", cat_term); - } - } else { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM5%c", cat_term); diff --git a/simulators/simicom.c b/simulators/simicom.c index a134c9b69..49cc2546c 100644 --- a/simulators/simicom.c +++ b/simulators/simicom.c @@ -195,6 +195,13 @@ void frameParse(int fd, unsigned char *frame, int len) write(fd, frame, 8); break; + case 0x04: // IC7200 data mode + frame[6] = 0; + frame[7] = 0; + frame[8] = 0xfd; + write(fd, frame, 9); + break; + case 0x07: // satmode frame[6] = 0; frame[7] = 0xfd; @@ -205,7 +212,7 @@ void frameParse(int fd, unsigned char *frame, int len) break; -#if 0 +#if 1 case 0x25: if (frame[6] == 0xfd) From c901126bf61888967e65a093abfd31c57fba65cf Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 16 Dec 2021 15:50:25 -0600 Subject: [PATCH 22/22] Ensure FTDX3000/5000 return ENAVAIL if tuner is on and meter is not SWR --- rigs/yaesu/newcat.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 85331fc00..c2f3272fe 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4599,10 +4599,14 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) newcat_get_func(rig, RIG_VFO_A, RIG_FUNC_TUNER, &tuner); newcat_get_level(rig, RIG_VFO_A, RIG_LEVEL_METER, &meter); - if (meter.i == RIG_METER_SWR) - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM%c%c", (tuner - && meter.i == RIG_METER_SWR) ? '2' : '6', - cat_term); + if (tuner && meter.i != RIG_METER_SWR) + { + RETURNFUNC(-RIG_ENAVAIL); // if meter not SWR can't read SWR + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM%c%c", (tuner + && meter.i == RIG_METER_SWR) ? '2' : '6', + cat_term); } else {