diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index b19b8d9ed..d67c22d21 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -774,6 +774,8 @@ icom_rig_open(RIG *rig) priv->tx_vfo = RIG_VFO_MAIN; } + icom_get_freq_range(rig); // try get to get rig range capability dyamically + return RIG_OK; } @@ -4303,6 +4305,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) { return rc; } + if (RIG_OK != (rc = icom_set_vfo(rig, RIG_VFO_A))) { return rc; @@ -6522,9 +6525,69 @@ int icom_send_voice_mem(RIG *rig, vfo_t vfo, int ch) * icom_get_freq_range * Assumes rig!=NULL, rig->state.priv!=NULL */ -int icom_get_freq_range(RIG *rig, vfo_t vfo, int ch) +int icom_get_freq_range(RIG *rig) { - // Automatically fill in the freq range for this rig if available + int nrange = 0; + int ack_len; + int i; + int cmd, subcmd; + int retval; + unsigned char lenbuf[1]; + unsigned char cmdbuf[MAXFRAMELEN]; + unsigned char ackbuf[MAXFRAMELEN]; + struct icom_priv_data *priv = (struct icom_priv_data *) rig->state.priv; + int freq_len = priv->civ_731_mode ? 4 : 5; + + cmd = C_CTL_EDGE; + subcmd = 0; + retval = icom_transaction(rig, cmd, subcmd, lenbuf, sizeof(lenbuf), ackbuf, + &ack_len); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_TRACE, + "%s: rig does not have 0x1e command so skipping this check\n", __func__); + return RIG_OK; + } + + nrange = from_bcd(lenbuf, 2); + rig_debug(RIG_DEBUG_TRACE, "%s: nrange=%d\n", __func__, nrange); + + for (i = 0; i < nrange; ++i) + { + cmd = C_CTL_EDGE; + subcmd = 1; + retval = icom_transaction(rig, cmd, subcmd, cmdbuf, sizeof(cmdbuf), ackbuf, + &ack_len); + + if (retval == RIG_OK) + { + freq_t freqlo, freqhi; + rig_debug(RIG_DEBUG_TRACE, "%s: cmdbuf= %02x %02x %02x %02x...\n", __func__, + cmdbuf[0], cmdbuf[1], cmdbuf[2], cmdbuf[3]); + freqlo = from_bcd(&cmdbuf[2], freq_len * 2); + freqhi = from_bcd(&cmdbuf[2 + freq_len], freq_len * 2); + rig_debug(RIG_DEBUG_TRACE, "%s: rig chan %d, low=%.0f, high=%.0f\n", __func__, + i, freqlo, freqhi); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: error from C_CTL_EDGE? err=%s\n", __func__, + rigerror(retval)); + } + } + +#if 0 + // To be implemented + // Automatically fill in the freq range for this rig if available + rig_debug(RIG_DEBUG_TRACE, "%s: \n", __func__); + + for (i = 0; i < FRQRANGESIZ && !RIG_IS_FRNG_END(caps->rx_range_list1[i]); i++) + { + } + +#endif + return RIG_OK; } // Sets rig vfo && priv->curr_vfo to default VFOA, or current vfo, or the vfo requested diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index f6416aadd..bf0bed7af 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -309,6 +309,7 @@ int icom_set_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf, int seconds); int icom_get_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf, int *seconds); +int icom_get_freq_range(RIG *rig); extern const struct confparams icom_cfg_params[]; extern const struct confparams icom_ext_levels[]; diff --git a/rigs/icom/icom_defs.h b/rigs/icom/icom_defs.h index 4a9f107bb..15ebc461d 100644 --- a/rigs/icom/icom_defs.h +++ b/rigs/icom/icom_defs.h @@ -76,22 +76,23 @@ #define C_MEM2VFO 0x0a /* Memory to VFO */ #define C_CLR_MEM 0x0b /* Memory clear */ #define C_RD_OFFS 0x0c /* Read duplex offset frequency; default changes with HF/6M/2M */ -#define C_SET_OFFS 0x0d /* Set duplex offset frequency */ -#define C_CTL_SCAN 0x0e /* Control scan, Sc */ -#define C_CTL_SPLT 0x0f /* Control split, and duplex mode Sc */ -#define C_SET_TS 0x10 /* Set tuning step, Sc */ +#define C_SET_OFFS 0x0d /* Set duplex offset frequency */ +#define C_CTL_SCAN 0x0e /* Control scan, Sc */ +#define C_CTL_SPLT 0x0f /* Control split, and duplex mode Sc */ +#define C_SET_TS 0x10 /* Set tuning step, Sc */ #define C_CTL_ATT 0x11 /* Set/get attenuator, Sc */ #define C_CTL_ANT 0x12 /* Set/get antenna, Sc */ #define C_CTL_ANN 0x13 /* Control announce (speech synth.), Sc */ #define C_CTL_LVL 0x14 /* Set AF/RF/squelch, Sc */ #define C_RD_SQSM 0x15 /* Read squelch condition/S-meter level, Sc */ -#define C_CTL_FUNC 0x16 /* Function settings (AGC,NB,etc.), Sc */ +#define C_CTL_FUNC 0x16 /* Function settings (AGC,NB,etc.), Sc */ #define C_SND_CW 0x17 /* Send CW message */ #define C_SET_PWR 0x18 /* Set Power ON/OFF, Sc */ -#define C_RD_TRXID 0x19 /* Read transceiver ID code */ +#define C_RD_TRXID 0x19 /* Read transceiver ID code */ #define C_CTL_MEM 0x1a /* Misc memory/bank/rig control functions, Sc */ -#define C_SET_TONE 0x1b /* Set tone frequency */ +#define C_SET_TONE 0x1b /* Set tone frequency */ #define C_CTL_PTT 0x1c /* Control Transmit On/Off, Sc */ +#define C_CTL_EDGE 0x1e /* Band edges */ #define C_CTL_DVT 0x1f /* Digital modes calsigns & messages */ #define C_CTL_DIG 0x20 /* Digital modes settings & status */ #define C_CTL_RIT 0x21 /* RIT/XIT control */ @@ -360,6 +361,14 @@ #define S_PTT 0x00 #define S_ANT_TUN 0x01 /* Auto tuner 0=OFF, 1 = ON, 2=Start Tuning */ +/* + * Band Edge control (C_CTL_EDGE) subcommands + */ +#define S_EDGE_RD_N 0x00 // Fixed band edge count +#define S_EDGE_RD 0x01 // Fixed band edges +#define S_EDGE_RD_NU 0x02 // User band edge count +#define S_EDGE_RD_U 0x03 // User band edges + /* * RIT/XIT control (C_CTL_RIT) subcommands */