kopia lustrzana https://github.com/Hamlib/Hamlib
Attempt to restore AI status on exit
Kenwood, modern Yaesu rigs and many SDRs use an auto information mechanism that broadcasts unsolicited rig state changes, Hamlib does not support this and turns off the function. Because several passive devices rely on this information to detect band changes for example this change adds code to save the AI state on start up and restores it on exit. These devices do no need the broadcasts since when an application using Hamlib is running as necessary state polling by the application provides continuous rig state updates.libusb-1-0
rodzic
6061cae8df
commit
0ab6d99ef5
|
@ -187,10 +187,13 @@ int elecraft_open(RIG *rig)
|
|||
|
||||
if (RIG_MODEL_XG3 != rig->caps->rig_model)
|
||||
{
|
||||
/* currently we cannot cope with AI mode so turn it off in case
|
||||
last client left it on */
|
||||
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's
|
||||
not supported */
|
||||
/* get current AI state so it can be restored */
|
||||
priv->trn_state = -1;
|
||||
kenwood_get_trn (rig, &priv->trn_state); /* ignore errors */
|
||||
/* Currently we cannot cope with AI mode so turn it off in
|
||||
case last client left it on */
|
||||
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case
|
||||
it's not supported */
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
|
|
|
@ -87,6 +87,7 @@ int flexradio_open(RIG *rig)
|
|||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
int err;
|
||||
char id[FLEXRADIO_MAX_BUF_LEN];
|
||||
|
||||
|
@ -105,6 +106,14 @@ int flexradio_open(RIG *rig)
|
|||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
/* get current AI state so it can be restored */
|
||||
priv->trn_state = -1;
|
||||
kenwood_get_trn (rig, &priv->trn_state); /* ignore errors */
|
||||
/* Currently we cannot cope with AI mode so turn it off in
|
||||
case last client left it on */
|
||||
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case
|
||||
it's not supported */
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ const struct rig_caps f6k_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = flexradio_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_mode = flex6k_set_mode,
|
||||
|
|
|
@ -208,6 +208,7 @@ const struct rig_caps k2_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = k2_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_mode = k2_set_mode,
|
||||
|
|
|
@ -191,6 +191,7 @@ const struct rig_caps k3_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = elecraft_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_mode = k3_set_mode,
|
||||
|
|
|
@ -525,6 +525,7 @@ int kenwood_open(RIG *rig)
|
|||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
int err, i;
|
||||
char *idptr;
|
||||
char id[KENWOOD_MAX_BUF_LEN];
|
||||
|
@ -533,7 +534,6 @@ int kenwood_open(RIG *rig)
|
|||
{
|
||||
/* we need the firmware version for these rigs to deal with f/w defects */
|
||||
static char fw_version[7];
|
||||
struct kenwood_priv_data * priv = rig->state.priv;
|
||||
|
||||
err = kenwood_transaction (rig, "FV", fw_version, sizeof (fw_version));
|
||||
if (RIG_OK != err)
|
||||
|
@ -597,6 +597,9 @@ int kenwood_open(RIG *rig)
|
|||
|
||||
if (kenwood_id_string_list[i].model == rig->caps->rig_model)
|
||||
{
|
||||
/* get current AI state so it can be restored */
|
||||
priv->trn_state = -1;
|
||||
kenwood_get_trn (rig, &priv->trn_state); /* ignore errors */
|
||||
/* Currently we cannot cope with AI mode so turn it off in
|
||||
case last client left it on */
|
||||
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case
|
||||
|
@ -621,6 +624,21 @@ int kenwood_open(RIG *rig)
|
|||
}
|
||||
|
||||
|
||||
int kenwood_close(RIG *rig)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
if (!rig) return -RIG_EINVAL;
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
if (priv->trn_state >= 0)
|
||||
{
|
||||
/* restore AI state */
|
||||
kenwood_set_trn (rig, priv->trn_state); /* ignore status in case
|
||||
it's not supported */
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/* ID
|
||||
* Reads transceiver ID number
|
||||
*
|
||||
|
|
|
@ -75,6 +75,7 @@ struct kenwood_priv_data {
|
|||
int k3_ext_lvl; /* Initial K3 extension level */
|
||||
int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */
|
||||
char *fw_rev; /* firmware revision level */
|
||||
int trn_state; /* AI state discovered at startup */
|
||||
unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */
|
||||
void * data; /* model specific data */
|
||||
};
|
||||
|
@ -98,6 +99,7 @@ char rmode2kenwood(rmode_t mode, const rmode_t mode_table[]);
|
|||
int kenwood_init(RIG *rig);
|
||||
int kenwood_cleanup(RIG *rig);
|
||||
int kenwood_open(RIG *rig);
|
||||
int kenwood_close(RIG *rig);
|
||||
|
||||
int kenwood_set_vfo(RIG *rig, vfo_t vfo);
|
||||
int kenwood_set_vfo_main_sub(RIG *rig, vfo_t vfo);
|
||||
|
|
|
@ -242,6 +242,7 @@ const struct rig_caps thf6a_caps = {
|
|||
.rig_init = thf6a_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = thf6a_open,
|
||||
.rig_close = kenwood_close,
|
||||
|
||||
.set_freq = th_set_freq,
|
||||
.get_freq = th_get_freq,
|
||||
|
|
|
@ -236,6 +236,7 @@ const struct rig_caps thf7e_caps = {
|
|||
.rig_init = thf7e_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = thf7e_open,
|
||||
.rig_close = kenwood_close,
|
||||
|
||||
.set_freq = th_set_freq,
|
||||
.get_freq = th_get_freq,
|
||||
|
|
|
@ -164,7 +164,7 @@ const struct rig_caps thg71_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = thg71_open,
|
||||
.rig_close = NULL,
|
||||
.rig_close = kenwood_close,
|
||||
|
||||
.set_freq = th_set_freq,
|
||||
.get_freq = th_get_freq,
|
||||
|
|
|
@ -191,7 +191,7 @@ const struct rig_caps tmv7_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = NULL,
|
||||
.rig_close = kenwood_close,
|
||||
|
||||
.set_freq = th_set_freq,
|
||||
.get_freq = th_get_freq,
|
||||
|
|
|
@ -278,6 +278,7 @@ const struct rig_caps ts2000_caps = {
|
|||
|
||||
.rig_init = kenwood_init,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = kenwood_close,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
|
|
|
@ -217,6 +217,7 @@ const struct rig_caps ts450s_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = ts450_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_rit = kenwood_set_rit,
|
||||
|
|
|
@ -191,6 +191,7 @@ const struct rig_caps ts590_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_rit = kenwood_set_rit, /* FIXME should this switch to rit mode or just set the frequency? */
|
||||
|
@ -357,6 +358,7 @@ const struct rig_caps ts590sg_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_rit = kenwood_set_rit, /* FIXME should this switch to rit mode or just set the frequency? */
|
||||
|
|
|
@ -165,6 +165,7 @@ const struct rig_caps ts690s_caps = {
|
|||
.rig_init = kenwood_init,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = kenwood_close,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
.set_rit = kenwood_set_rit,
|
||||
|
|
|
@ -518,6 +518,7 @@ const struct rig_caps ts870s_caps = {
|
|||
|
||||
.rig_init = kenwood_init,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = kenwood_close,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
|
|
|
@ -312,6 +312,7 @@ const struct rig_caps ts990s_caps = {
|
|||
|
||||
.rig_init = kenwood_init,
|
||||
.rig_open = kenwood_open,
|
||||
.rig_close = kenwood_close,
|
||||
.rig_cleanup = kenwood_cleanup,
|
||||
.set_freq = kenwood_set_freq,
|
||||
.get_freq = kenwood_get_freq,
|
||||
|
|
|
@ -306,24 +306,28 @@ int newcat_cleanup(RIG *rig) {
|
|||
*/
|
||||
|
||||
int newcat_open(RIG *rig) {
|
||||
struct rig_state *rig_s;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
// priv = (struct newcat_priv_data *)rig->state.priv;
|
||||
rig_s = &rig->state;
|
||||
struct newcat_priv_data * priv = rig->state.priv;
|
||||
struct rig_state * rig_s = &rig->state;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: write_delay = %i msec\n",
|
||||
__func__, rig_s->rigport.write_delay);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay = %i msec\n",
|
||||
__func__, rig_s->rigport.post_write_delay);
|
||||
|
||||
/* get current AI state so it can be restored */
|
||||
priv->trn_state = -1;
|
||||
newcat_get_trn (rig, &priv->trn_state); /* ignore errors */
|
||||
/* Currently we cannot cope with AI mode so turn it off in case
|
||||
last client left it on */
|
||||
return newcat_set_trn (rig, RIG_TRN_OFF);
|
||||
newcat_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's
|
||||
not supported */
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -338,7 +342,14 @@ int newcat_close(RIG *rig) {
|
|||
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
struct newcat_priv_data * priv = rig->state.priv;
|
||||
if (priv->trn_state >= 0)
|
||||
{
|
||||
/* restore AI state */
|
||||
newcat_set_trn (rig, priv->trn_state); /* ignore status in
|
||||
case it's not
|
||||
supported */
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ struct newcat_priv_data {
|
|||
int rig_id; /* rig id from CAT Command ID; */
|
||||
int width_frequency; /* width of FA/FB freq response */
|
||||
int offset_rit; /* offset of rit in response */
|
||||
int trn_state; /* AI state found at startup */
|
||||
};
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue