Allow IC-7300 and many other Icom rigs to find current vfo on startup

Icom rigs that do not have 0x25 or XCHG cannot do this yet which are older Icom rigs
XCHG rigs cannot get_vfo while transmitting but 0x25 rigs can
https://github.com/Hamlib/Hamlib/issues/806
pull/816/head
Mike Black W9MDB 2021-09-26 17:03:47 -05:00
rodzic 7bd407beda
commit aae3ec4996
21 zmienionych plików z 239 dodań i 66 usunięć

2
NEWS
Wyświetl plik

@ -10,6 +10,8 @@ Version 4.4
* 2021-??-??
* Icom rigs now default filter 2 when setting PKTUSB but user can override
* Fix FTDX9000 meter readings
* Add Android sensor as a rotator
* Added rig_get_vfo to some Icom rigs that have XCHG or 0x25 command capability
Version 4.3.1
* 2021-09-14

Wyświetl plik

@ -197,7 +197,7 @@ const struct rig_caps ic7000_caps =
RIG_MODEL(RIG_MODEL_IC7000),
.model_name = "IC-7000",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -336,6 +336,7 @@ const struct rig_caps ic7000_caps =
.get_freq = icom_get_freq,
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.get_vfo = icom_get_vfo,
.set_vfo = icom_set_vfo,
.set_ant = NULL, /*automatically set by rig depending band */
.get_ant = NULL,

Wyświetl plik

@ -89,7 +89,7 @@ const struct rig_caps ic703_caps =
RIG_MODEL(RIG_MODEL_IC703),
.model_name = "IC-703",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_MOBILE,
@ -202,6 +202,7 @@ const struct rig_caps ic703_caps =
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.decode_event = icom_decode_event,
.set_level = icom_set_level,

Wyświetl plik

@ -153,7 +153,7 @@ const struct rig_caps ic706_caps =
RIG_MODEL(RIG_MODEL_IC706),
.model_name = "IC-706",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_MOBILE,
@ -257,6 +257,7 @@ const struct rig_caps ic706_caps =
.get_freq = icom_get_freq,
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.get_vfo = icom_get_vfo,
.set_vfo = icom_set_vfo,
.decode_event = icom_decode_event,
@ -291,7 +292,7 @@ const struct rig_caps ic706mkii_caps =
RIG_MODEL(RIG_MODEL_IC706MKII),
.model_name = "IC-706MkII",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_MOBILE,
@ -399,6 +400,7 @@ const struct rig_caps ic706mkii_caps =
.get_freq = icom_get_freq,
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.get_vfo = icom_get_vfo,
.set_vfo = icom_set_vfo,
.decode_event = icom_decode_event,
@ -453,7 +455,7 @@ const struct rig_caps ic706mkiig_caps =
RIG_MODEL(RIG_MODEL_IC706MKIIG),
.model_name = "IC-706MkIIG",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_MOBILE,
@ -590,6 +592,7 @@ const struct rig_caps ic706mkiig_caps =
.get_freq = icom_get_freq,
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.get_vfo = icom_get_vfo,
.set_vfo = icom_set_vfo,
.decode_event = icom_decode_event,

Wyświetl plik

@ -207,7 +207,7 @@ const struct rig_caps ic7100_caps =
RIG_MODEL(RIG_MODEL_IC7100),
.model_name = "IC-7100",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -360,7 +360,7 @@ const struct rig_caps ic7100_caps =
.get_mode = icom_get_mode_with_data,
.set_mode = icom_set_mode_with_data,
.get_vfo = NULL,
.get_vfo = icom_get_vfo,
.set_vfo = icom_set_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -81,7 +81,7 @@ const struct rig_caps ic718_caps =
RIG_MODEL(RIG_MODEL_IC718),
.model_name = "IC-718",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -186,6 +186,7 @@ const struct rig_caps ic718_caps =
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.decode_event = icom_decode_event,
.set_level = icom_set_level,

Wyświetl plik

@ -130,7 +130,7 @@ const struct rig_caps ic7200_caps =
RIG_MODEL(RIG_MODEL_IC7200),
.model_name = "IC-7200",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -247,6 +247,7 @@ const struct rig_caps ic7200_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = NULL, /*automatically set by rig depending band */
.get_ant = NULL,

Wyświetl plik

@ -535,7 +535,7 @@ const struct rig_caps ic7300_caps =
RIG_MODEL(RIG_MODEL_IC7300),
.model_name = "IC-7300",
.mfg_name = "Icom",
.version = BACKEND_VER ".4",
.version = BACKEND_VER ".5",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -706,6 +706,7 @@ const struct rig_caps ic7300_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,
.set_vfo = icom_set_vfo,
.set_ant = NULL,
.get_ant = NULL,
@ -761,7 +762,7 @@ const struct rig_caps ic9700_caps =
RIG_MODEL(RIG_MODEL_IC9700),
.model_name = "IC-9700",
.mfg_name = "Icom",
.version = BACKEND_VER ".3",
.version = BACKEND_VER ".4",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1013,6 +1014,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,
.set_vfo = icom_set_vfo,
.set_ant = NULL,
.get_ant = NULL,
@ -1065,7 +1067,7 @@ const struct rig_caps ic705_caps =
RIG_MODEL(RIG_MODEL_IC705),
.model_name = "IC-705",
.mfg_name = "Icom",
.version = BACKEND_VER ".2",
.version = BACKEND_VER ".3",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1268,6 +1270,7 @@ const struct rig_caps ic705_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,
.set_vfo = icom_set_vfo,
.set_ant = NULL,
.get_ant = NULL,

Wyświetl plik

@ -129,7 +129,7 @@ const struct rig_caps ic7410_caps =
RIG_MODEL(RIG_MODEL_IC7410),
.model_name = "IC-7410",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_UNTESTED,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -253,6 +253,7 @@ const struct rig_caps ic7410_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -185,7 +185,7 @@ const struct rig_caps ic746_caps =
RIG_MODEL(RIG_MODEL_IC746),
.model_name = "IC-746",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -303,6 +303,7 @@ const struct rig_caps ic746_caps =
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,
@ -413,7 +414,7 @@ const struct rig_caps ic746pro_caps =
RIG_MODEL(RIG_MODEL_IC746PRO),
.model_name = "IC-746PRO",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -545,6 +546,7 @@ const struct rig_caps ic746pro_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -142,7 +142,7 @@ const struct rig_caps ic756_caps =
RIG_MODEL(RIG_MODEL_IC756),
.model_name = "IC-756",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -252,6 +252,7 @@ const struct rig_caps ic756_caps =
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,
@ -305,7 +306,7 @@ const struct rig_caps ic756pro_caps =
RIG_MODEL(RIG_MODEL_IC756PRO),
.model_name = "IC-756PRO",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -414,6 +415,7 @@ const struct rig_caps ic756pro_caps =
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,
@ -542,7 +544,7 @@ const struct rig_caps ic756pro2_caps =
RIG_MODEL(RIG_MODEL_IC756PROII),
.model_name = "IC-756PROII",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -652,6 +654,7 @@ const struct rig_caps ic756pro2_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,
@ -974,7 +977,7 @@ const struct rig_caps ic756pro3_caps =
RIG_MODEL(RIG_MODEL_IC756PROIII),
.model_name = "IC-756PROIII",
.mfg_name = "Icom",
.version = BACKEND_VER ".1",
.version = BACKEND_VER ".2",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1095,6 +1098,7 @@ const struct rig_caps ic756pro3_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -168,7 +168,7 @@ const struct rig_caps ic7600_caps =
RIG_MODEL(RIG_MODEL_IC7600),
.model_name = "IC-7600",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -305,6 +305,7 @@ const struct rig_caps ic7600_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -248,7 +248,7 @@ const struct rig_caps ic7610_caps =
RIG_MODEL(RIG_MODEL_IC7610),
.model_name = "IC-7610",
.mfg_name = "Icom",
.version = BACKEND_VER ".2",
.version = BACKEND_VER ".3",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -437,6 +437,7 @@ const struct rig_caps ic7610_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -151,7 +151,7 @@ const struct rig_caps ic7700_caps =
RIG_MODEL(RIG_MODEL_IC7700),
.model_name = "IC-7700",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -285,6 +285,7 @@ const struct rig_caps ic7700_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -154,7 +154,7 @@ const struct rig_caps ic7800_caps =
RIG_MODEL(RIG_MODEL_IC7800),
.model_name = "IC-7800",
.mfg_name = "Icom",
.version = BACKEND_VER ".2",
.version = BACKEND_VER ".3",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -288,6 +288,7 @@ const struct rig_caps ic7800_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -64,7 +64,7 @@ const struct rig_caps ic781_caps =
RIG_MODEL(RIG_MODEL_IC781),
.model_name = "IC-781",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -176,6 +176,7 @@ const struct rig_caps ic781_caps =
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_split_vfo = icom_set_split_vfo,
.set_split_freq = icom_set_split_freq,
.get_split_freq = icom_get_split_freq,

Wyświetl plik

@ -242,7 +242,7 @@ 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_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -432,6 +432,7 @@ const struct rig_caps ic785x_caps =
.set_mode = icom_set_mode_with_data,
.get_mode = icom_get_mode_with_data,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,

Wyświetl plik

@ -328,6 +328,7 @@ const struct rig_caps ic910_caps =
.set_ptt = icom_set_ptt,
.get_ptt = icom_get_ptt,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.get_ts = icom_get_ts,
.set_ts = icom_set_ts,
.get_func = ic910_get_func,

Wyświetl plik

@ -114,7 +114,7 @@ const struct rig_caps ic9100_caps =
RIG_MODEL(RIG_MODEL_IC9100),
.model_name = "IC-9100",
.mfg_name = "Icom",
.version = BACKEND_VER ".0",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -244,8 +244,8 @@ const struct rig_caps ic9100_caps =
.get_mode = icom_get_mode_with_data,
.set_mode = icom_set_mode_with_data,
.get_vfo = NULL,
.set_vfo = icom_set_vfo,
.get_vfo = icom_get_vfo,
.set_ant = icom_set_ant,
.get_ant = icom_get_ant,
.get_ts = icom_get_ts,

Wyświetl plik

@ -43,6 +43,7 @@
#include "icom.h"
#include "icom_defs.h"
#include "frame.h"
#include "misc.h"
static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo);
static int icom_set_default_vfo(RIG *rig);
@ -767,6 +768,134 @@ int icom_get_usb_echo_off(RIG *rig)
RETURNFUNC(priv->serial_USB_echo_off);
}
// figure out what VFO is current for rigs with 0x25 command
static vfo_t icom_current_vfo_x25(RIG *rig)
{
int fOffset = 0;
freq_t fCurr, f2, f3;
vfo_t currVFO = RIG_VFO_NONE;
vfo_t chkVFO = RIG_VFO_A;
rig_get_freq(rig, RIG_VFO_CURR, &fCurr);
rig_get_freq(rig, RIG_VFO_OTHER, &f2);
if (fCurr == f2)
{
fOffset = 100;
rig_set_freq(rig, RIG_VFO_CURR, fCurr + fOffset);
}
if (rig->state.current_vfo == RIG_VFO_B) { chkVFO = RIG_VFO_B; }
rig_set_vfo(rig, chkVFO);
rig_get_freq(rig, RIG_VFO_CURR, &f3);
if (f3 == fCurr + fOffset) // then we are on the chkVFO
{
currVFO = chkVFO;
}
else // the other VFO is the current one
{
rig_set_vfo(rig, chkVFO == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A);
currVFO = chkVFO == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A;
}
if (fOffset) // then we need to change fCurr back to original freq
{
rig_set_freq(rig, RIG_VFO_CURR, fCurr);
}
rig_debug(RIG_DEBUG_TRACE, "%s: currVFO=%s\n", __func__, rig_strvfo(currVFO));
return currVFO;
}
// figure out what VFO is current
static vfo_t icom_current_vfo(RIG *rig)
{
int retval;
int fOffset = 0;
freq_t fCurr, f2, f3;
vfo_t currVFO = RIG_VFO_NONE;
vfo_t chkVFO = RIG_VFO_A;
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
if (priv->x25cmdfails == 0) // these newer rigs get special treatment
{
if (access("w9mdb.txt", F_OK) != -1)
{
return icom_current_vfo_x25(rig);
}
}
else if (rig->state.cache.ptt) // don't do this if transmitting -- XCHG would mess it up
{
return rig->state.current_vfo;
}
else if (priv->no_xchg || !rig_has_vfo_op(rig, RIG_OP_XCHG))
{
// for now we will just set vfoa and be done with it
// will take more logic for rigs without XCHG
rig_debug(RIG_DEBUG_TRACE,
"%s: defaulting to VFOA as no XCHG or x25 available\n",
__func__);
rig_set_vfo(rig, RIG_VFO_A);
return RIG_VFO_A;
}
rig_get_freq(rig, RIG_VFO_CURR, &fCurr);
if (!priv->no_xchg && rig_has_vfo_op(rig, RIG_OP_XCHG))
{
rig_debug(RIG_DEBUG_TRACE, "%s: Using XCHG to swap\n", __func__);
if (RIG_OK != (retval = icom_vfo_op(rig, currVFO, RIG_OP_XCHG)))
{
RETURNFUNC(retval);
}
}
rig_get_freq(rig, RIG_VFO_CURR, &f2);
if (!priv->no_xchg && rig_has_vfo_op(rig, RIG_OP_XCHG))
{
rig_debug(RIG_DEBUG_TRACE, "%s: Using XCHG to swap back\n", __func__);
if (RIG_OK != (retval = icom_vfo_op(rig, currVFO, RIG_OP_XCHG)))
{
RETURNFUNC(retval);
}
}
if (fCurr == f2)
{
fOffset = 100;
rig_set_freq(rig, RIG_VFO_CURR, fCurr + fOffset);
}
if (rig->state.current_vfo == RIG_VFO_B) { chkVFO = RIG_VFO_B; }
rig_set_vfo(rig, chkVFO);
rig_get_freq(rig, RIG_VFO_CURR, &f3);
if (f3 == fCurr + fOffset)
{
currVFO = chkVFO;
}
else
{
rig_set_vfo(rig, chkVFO == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A);
currVFO = chkVFO == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A;
}
if (fOffset) // then we need to change fCurr back to original freq
{
rig_set_freq(rig, RIG_VFO_CURR, fCurr);
}
rig_debug(RIG_DEBUG_TRACE, "%s: currVFO=%s\n", __func__, rig_strvfo(currVFO));
return currVFO;
}
/*
* ICOM rig open routine
@ -788,10 +917,11 @@ icom_rig_open(RIG *rig)
if (retval == RIG_OK) // then echo is on so let's try freq now
{
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
freq_t tfreq;
retval = rig_get_freq(rig, RIG_VFO_A, &tfreq);
retval = rig_get_freq(rig, RIG_VFO_CURR, &tfreq);
}
if (retval != RIG_OK && priv->poweron == 0 && rs->auto_power_on)
@ -820,9 +950,13 @@ icom_rig_open(RIG *rig)
rig_debug(RIG_DEBUG_ERR, "%s: Unable to determine USB echo status\n", __func__);
RETURNFUNC(retval);
}
// Determine active vfo again since it would have failed the 1st time
rig->state.current_vfo = icom_current_vfo(rig);
icom_current_vfo(rig);
}
icom_set_default_vfo(rig);
rig->state.current_vfo = icom_current_vfo(rig);
priv->poweron = 1;
if (rig->caps->has_get_func & RIG_FUNC_SATMODE)
@ -1021,11 +1155,18 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rs = &rig->state;
priv = (struct icom_priv_data *) rs->priv;
#if 0
if (rig->state.current_vfo == RIG_VFO_NONE)
{
TRACE;
icom_set_default_vfo(rig);
}
#endif
#if 0
if (vfo == RIG_VFO_CURR)
{
vfo = rig->state.current_vfo;
@ -1033,6 +1174,8 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_strvfo(vfo));
}
#endif
if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ))
{
TRACE;
@ -1062,13 +1205,15 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// mike
if (rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ)
{
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B;
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B
| RIG_VFO_OTHER;
// if we are on the "other" vfo already then we have to allow for that
if (rig->state.current_vfo & vfo_unselected)
{
TRACE;
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A;
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A |
RIG_VFO_OTHER;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo=%s, currvfo=%s\n", __func__, __LINE__,
@ -1179,7 +1324,9 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
case RIG_VFO_SUB: priv->sub_freq = freq; break;
case RIG_VFO_CURR: break;
case RIG_VFO_CURR: priv->curr_freq = freq; break;
case RIG_VFO_OTHER: priv->other_freq = freq; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown VFO? VFO=%s\n", __func__,
@ -1305,6 +1452,8 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_debug(RIG_DEBUG_VERBOSE, "%s: using vfo=%s\n", __func__,
rig_strvfo(vfo));
#if 0
if (rig->state.current_vfo == RIG_VFO_NONE)
{
// we default to VFOA/MAIN as appropriate
@ -1319,18 +1468,22 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
}
#endif
// we'll use 0x25 command to get unselected frequency
// we have to assume current_vfo is accurate to determine what "other" means
if (priv->x25cmdfails == 0)
{
int cmd2 = 0x25;
int subcmd2 = 0x00;
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B;
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B
| RIG_VFO_OTHER;
// if we are on the "other" vfo already then we have to allow for that
if (rig->state.current_vfo & vfo_unselected)
{
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A;
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A |
RIG_VFO_OTHER;
}
// if we ask for unselected but we're not on unselected subcmd2 changes
@ -1445,7 +1598,9 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
case RIG_VFO_SUB: priv->sub_freq = *freq; break;
case RIG_VFO_CURR: break;
case RIG_VFO_OTHER: priv->other_freq = *freq; break;
case RIG_VFO_CURR: priv->curr_freq = *freq; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown VFO? VFO=%s\n", __func__,
@ -1746,12 +1901,14 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode,
int cmd2 = 0x26;
int subcmd2 = 0x00;
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B;
vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B
| RIG_VFO_OTHER;
// if we are on the "other" vfo already then we have to allow for that
if (rig->state.current_vfo & vfo_unselected)
{
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A;
vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A |
RIG_VFO_OTHER;
}
// if we ask for unselected but we're not on unselected subcmd2 changes
@ -2180,6 +2337,7 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
unsigned char modebuf[MAXFRAMELEN];
const struct icom_priv_caps *priv_caps;
struct icom_priv_data *priv_data;
vfo_t vfocurr = vfo_fixup(rig, rig->state.current_vfo, 0);
int mode_len, retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo));
@ -2188,15 +2346,19 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
*width = 0;
TRACE;
// IC7800 can set but not read with 0x26
if ((rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)
&& rig->caps->rig_model != RIG_MODEL_IC7800)
{
int vfosel = 0x00;
vfo_t vfoask = vfo_fixup(rig, vfo, 0);
vfo_t vfocurr = vfo_fixup(rig, rig->state.current_vfo, 0);
if (vfo != RIG_VFO_CURR && vfoask != vfocurr) { vfosel = 0x01; }
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, vfoask=%s, vfocurr=%s\n", __func__,
rig_strvfo(vfo), rig_strvfo(vfoask), rig_strvfo(vfocurr));
if (vfoask != RIG_VFO_CURR && vfoask != vfocurr) { vfosel = 0x01; }
// use cache for the non-selected VFO -- can't get it by VFO
// this avoids vfo swapping but accurate answers for these rigs
@ -2350,44 +2512,21 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
RETURNFUNC(RIG_OK);
}
#ifdef XXREMOVEDXX
// not implemented yet
/*
* 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 -- 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
*/
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__);
*vfo = icom_current_vfo(rig);
retval = icom_transaction(rig, C_SET_VFO, S_SUB_SEL, NULL, 0,
ackbuf, &ack_len);
if (vfo == NULL) { RETURNFUNC(-RIG_EINTERNAL); }
if (retval != RIG_OK)
{
RETURNFUNC(retval);
}
if (ack_len != 3)
{
rig_debug(RIG_DEBUG_ERR, "%s wrong frame len=%d\n", __func__, ack_len);
RETURNFUNC(-RIG_ERJCTED);
}
*vfo = ackbuf[2] == 0 ? RIG_VFO_A : RIG_VFO_B;
RETURNFUNC(RIG_OK);
}
#endif
/*
* icom_get_vfo
* icom_set_vfo
* Assumes rig!=NULL, rig->state.priv!=NULL
*/
int icom_set_vfo(RIG *rig, vfo_t vfo)
@ -4978,6 +5117,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
if (rig->state.current_vfo == RIG_VFO_NONE)
{
TRACE;
retval = icom_set_default_vfo(rig);
if (retval != RIG_OK)
@ -5218,6 +5358,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
if (rig->state.current_vfo == RIG_VFO_NONE)
{
TRACE;
icom_set_default_vfo(rig);
}
@ -5645,6 +5786,7 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq,
if (rig->state.current_vfo == RIG_VFO_NONE)
{
TRACE;
icom_set_default_vfo(rig);
}
@ -7961,6 +8103,9 @@ int icom_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
RETURNFUNC(retval);
}
// since we're messing with VFOs our cache may be invalid
CACHE_RESET;
if ((ack_len >= 1 && ackbuf[0] != ACK) && (ack_len >= 2 && ackbuf[1] != NAK))
{
// if we don't get ACK/NAK some serial corruption occurred
@ -8841,6 +8986,7 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo)
// So if you ask for frequency or such without setting VFO first you'll get Main/VFOA
if (rig->state.current_vfo == RIG_VFO_NONE && vfo == RIG_VFO_CURR)
{
TRACE;
icom_set_default_vfo(rig);
}
// asking for vfo_curr so give it to them

Wyświetl plik

@ -30,7 +30,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20210922"
#define BACKEND_VER "20210926"
#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)
@ -265,6 +265,7 @@ struct icom_priv_data
unsigned char datamode; /*!< Current datamode */
int spectrum_scope_count; /*!< Number of spectrum scopes, calculated from caps */
struct icom_spectrum_scope_cache spectrum_scope_cache[HAMLIB_MAX_SPECTRUM_SCOPES]; /*!< Cached Icom spectrum scope data used during reception of the data. The array index must match the scope ID. */
freq_t other_freq; /*!< Our other freq depending on which vfo is selected */
};
extern const struct ts_sc_list r8500_ts_sc_list[];