From 31ea63b2f3f2ba476f65e43b35a4d841179ce1bd Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 25 Mar 2024 10:23:40 -0500 Subject: [PATCH] Fix IC7300 bandwidth reading for AM/BM ....still need to fix setting bandwidth for AM/FM --- rigs/icom/ic7300.c | 4 ++-- rigs/icom/icom.c | 53 ++++++++++++++++++++++++++++++++++++++-------- rigs/icom/icom.h | 1 + 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index 98d010e60..58a45a25d 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -50,11 +50,11 @@ int ic9700_get_clock(RIG *rig, int *year, int *month, int *day, int ic9700_set_vfo(RIG *rig, vfo_t vfo); -#define IC7300_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_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PKTAM) +#define IC7300_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_PKTFM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PKTAM) #define IC7300_1HZ_TS_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PKTAM) #define IC7300_NOT_TS_MODES (IC7300_ALL_RX_MODES &~IC7300_1HZ_TS_MODES) -#define IC7300_OTHER_TX_MODES (RIG_MODE_FM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR) +#define IC7300_OTHER_TX_MODES (RIG_MODE_FM|RIG_MODE_PKTFM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR) #define IC7300_AM_TX_MODES (RIG_MODE_AM|RIG_MODE_PKTAM) #define IC7300_FUNCS (RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_ANF|RIG_FUNC_LOCK|RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_SCOPE|RIG_FUNC_TUNER|RIG_FUNC_TRANSCEIVE|RIG_FUNC_SPECTRUM|RIG_FUNC_SPECTRUM_HOLD|RIG_FUNC_SEND_MORSE|RIG_FUNC_SEND_VOICE_MEM|RIG_FUNC_OVF_STATUS) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index e6e1bb6a4..a59d456cd 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -440,6 +440,7 @@ struct icom_addr #define TOK_FILTER_USBD TOKEN_BACKEND(5) #define TOK_FILTER_USB TOKEN_BACKEND(6) #define TOK_FILTER_CW TOKEN_BACKEND(7) +#define TOK_FILTER_FM TOKEN_BACKEND(8) const struct confparams icom_cfg_params[] = { @@ -474,6 +475,10 @@ const struct confparams icom_cfg_params[] = TOK_FILTER_CW, "filter_cw", "Filter to use CW", "Filter to use for CW/CWR when setting mode", "0", RIG_CONF_NUMERIC, {.n = {0, 3, 1}} }, + { + TOK_FILTER_FM, "filter_fm", "Filter to use FM", "Filter to use for FM/PKTFM when setting mode", + "0", RIG_CONF_NUMERIC, {.n = {0, 3, 1}} + }, {RIG_CONF_END, NULL,} }; @@ -1977,9 +1982,9 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) } // TODO: Skip for Xiegu G90 too???? - if (mode == RIG_MODE_FM || mode == RIG_MODE_FMN - || RIG_MODEL_X108G == rig->caps->rig_model - || RIG_MODEL_X5105 == rig->caps->rig_model) + if (RIG_MODEL_X108G == rig->caps->rig_model + || RIG_MODEL_X5105 == rig->caps->rig_model + || RIG_MODEL_G90 == rig->caps->rig_model) { priv->no_1a_03_cmd = ENUM_1A_03_NO; } @@ -1992,7 +1997,7 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) retval = icom_transaction(rig, C_CTL_MEM, fw_sub_cmd, 0, 0, resbuf, &res_len); - if (-RIG_ERJCTED == retval) + if (-RIG_ERJCTED == retval && !RIG_IS_IC7300) { if (priv->no_1a_03_cmd == ENUM_1A_03_UNK) { @@ -2108,6 +2113,13 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) flt_idx = width <= 500 ? ((width + 49) / 50) - 1 : ((width + 99) / 100) + 4; } + else if (mode & (RIG_MODE_FM | RIG_MODE_PKTFM)) + { + if (width <= 7000) width = 7000; + else if (width <= 10000) width = 10000; + else width=15000; + RETURNFUNC(RIG_OK); + } else { rig_debug(RIG_DEBUG_VERBOSE, "%s: unknown mode=%s\n", __func__, @@ -2311,17 +2323,22 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, buf[2] = priv->filter_usbd; } - if (priv->filter_usb > 0 && (mode == RIG_MODE_USB || mode == RIG_MODE_LSB)) + else if (priv->filter_usb > 0 && (mode == RIG_MODE_USB || mode == RIG_MODE_LSB)) { rig_debug(RIG_DEBUG_TRACE, "%s: filter usb=%d\n", __func__, priv->filter_usb); buf[2] = priv->filter_usb; } - if (priv->filter_cw > 0 && (mode == RIG_MODE_CW || mode == RIG_MODE_CWR)) + else if (priv->filter_cw > 0 && (mode == RIG_MODE_CW || mode == RIG_MODE_CWR)) { rig_debug(RIG_DEBUG_TRACE, "%s: filter cw=%d\n", __func__, priv->filter_cw); buf[2] = priv->filter_cw; } + else if (priv->filter_fm > 0 && (mode == RIG_MODE_FM || mode == RIG_MODE_PKTFM)) + { + rig_debug(RIG_DEBUG_TRACE, "%s: filter fm=%d\n", __func__, priv->filter_fm); + buf[2] = priv->filter_fm; + } int vfo_number = icom_get_vfo_number_x25x26(rig, vfo); @@ -2532,7 +2549,7 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } if (((width != RIG_PASSBAND_NOCHANGE) && (width != current_width)) - || (priv->filter_usbd > 0 || priv->filter_usb > 0 || priv->filter_cw > 0)) + || (priv->filter_usbd > 0 || priv->filter_usb > 0 || priv->filter_cw > 0 || priv->filter_fm > 0)) { icom_set_dsp_flt(rig, mode, width); } @@ -2609,7 +2626,7 @@ static int icom_get_mode_without_data(RIG *rig, vfo_t vfo, rmode_t *mode, { priv_data->filter = 0; - if (mode_len == 2) { priv_data->filter = modebuf[2]; } + if (mode_len == 1) { priv_data->filter = modebuf[2]; } rig_debug(RIG_DEBUG_TRACE, "%s(%d): modebuf[0]=0x%02x, modebuf[1]=0x%02x, mode_len=%d\n", __func__, @@ -2683,7 +2700,16 @@ static int icom_get_mode_without_data(RIG *rig, vfo_t vfo, rmode_t *mode, *width = filter_width; - if (*mode == RIG_MODE_FM) { *width = 12000; } + if (*mode == RIG_MODE_FM) + { + *width = 12000; // some default to 12000 + if (RIG_IS_IC7300) + { + if (priv_data->filter == 1) *width = 15000; + else if (priv_data->filter == 2) *width = 10000; + else if (priv_data->filter == 3) *width = 7000; + } + } RETURNFUNC2(RIG_OK); } @@ -5089,6 +5115,15 @@ int icom_set_conf(RIG *rig, hamlib_token_t token, const char *val) break; + case TOK_FILTER_FM: + priv->filter_fm = atoi(val); + + if (priv->filter_fm > 3) { priv->filter_fm = 3; } + + if (priv->filter_fm < 1) { priv->filter_fm = 1; } + + break; + default: RETURNFUNC(-RIG_EINVAL); } diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 0f4c80d8e..3c5d5e81a 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -296,6 +296,7 @@ struct icom_priv_data int filter_usbd; /*!< Filter number to use for USBD/LSBD when setting mode */ int filter_usb; /*!< Filter number to use for USB/LSB when setting mode */ int filter_cw; /*!< Filter number to use for CW/CWR when setting mode */ + int filter_fm; /*!< Filter number to use for CW/CWR when setting mode */ }; extern const struct ts_sc_list r8500_ts_sc_list[];