kopia lustrzana https://github.com/Hamlib/Hamlib
Add missing config parameters for rig power on/off and screen-saver
Defaults set to by compatible with prior released versions to avoid regressive behaviour.pull/345/head
rodzic
5007765d10
commit
3f40029720
|
@ -2028,6 +2028,11 @@ struct rig_state {
|
|||
int twiddle_timeout; /*!< timeout to resume from twiddling */
|
||||
struct rig_cache cache;
|
||||
int vfo_opt; /*!< Is -o switch turned on? */
|
||||
int auto_pwr_on_off; /*!< Allow Hamlib to power rig on and
|
||||
off automatically if supported */
|
||||
int auto_disable_screensaver; /*!< Allow Hamlib to disable the
|
||||
rig's screen saver automatically if
|
||||
supported */
|
||||
};
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
|
|
@ -727,7 +727,7 @@ icom_rig_open(RIG *rig)
|
|||
rig->caps->version);
|
||||
retval = icom_get_usb_echo_off(rig);
|
||||
|
||||
if (retval != RIG_OK && priv->poweron == 0)
|
||||
if (retval != RIG_OK && priv->poweron == 0 && rs->auto_pwr_on_off)
|
||||
{
|
||||
// maybe we need power on?
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s trying power on\n", __func__);
|
||||
|
|
|
@ -725,7 +725,7 @@ int kenwood_open(RIG *rig)
|
|||
rig_debug(RIG_DEBUG_TRACE, "%s: got ID so try PS\n", __func__);
|
||||
err = rig_get_powerstat(rig, &powerstat);
|
||||
|
||||
if (err == RIG_OK && powerstat == 0 && priv->poweron == 0)
|
||||
if (err == RIG_OK && powerstat == 0 && priv->poweron == 0 && rig->state.auto_pwr_on_off)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: got PS0 so powerup\n", __func__);
|
||||
rig_set_powerstat(rig, 1);
|
||||
|
@ -735,19 +735,17 @@ int kenwood_open(RIG *rig)
|
|||
|
||||
err = RIG_OK; // reset our err back to OK for later checks
|
||||
}
|
||||
|
||||
if (err == -RIG_ETIMEOUT)
|
||||
if (err == -RIG_ETIMEOUT && rig->state.auto_pwr_on_off)
|
||||
{
|
||||
// Ensure rig is on
|
||||
rig_set_powerstat(rig, 1);
|
||||
/* Try get id again */
|
||||
err = kenwood_get_id(rig, id);
|
||||
|
||||
if (RIG_OK != err)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: no response to get_id from rig...contintuing anyways.\n", __func__);
|
||||
}
|
||||
}
|
||||
if (RIG_OK != err)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: no response to get_id from rig...contintuing anyways.\n", __func__);
|
||||
}
|
||||
|
||||
if (RIG_IS_TS2000
|
||||
|
|
|
@ -366,10 +366,10 @@ int newcat_open(RIG *rig)
|
|||
__func__, rig_s->rigport.post_write_delay);
|
||||
|
||||
/* Ensure rig is powered on */
|
||||
if (priv->poweron == 0)
|
||||
if (priv->poweron == 0 && rig_s->auto_pwr_on_off)
|
||||
{
|
||||
priv->poweron = 1;
|
||||
rig_set_powerstat(rig, 1);
|
||||
priv->poweron = 1;
|
||||
}
|
||||
|
||||
/* get current AI state so it can be restored */
|
||||
|
|
34
src/conf.c
34
src/conf.c
|
@ -128,6 +128,16 @@ static const struct confparams frontend_cfg_params[] =
|
|||
"Cache timeout, value of 0 disables caching",
|
||||
"500", RIG_CONF_NUMERIC, { .n = {0, 5000, 1}}
|
||||
},
|
||||
{
|
||||
TOK_AUTO_PWR_ON_OFF, "auto_pwr_on_off", "Auto power on/off",
|
||||
"True enables compatible rigs to be powered up on open",
|
||||
"0", RIG_CONF_CHECKBUTTON, { }
|
||||
},
|
||||
{
|
||||
TOK_AUTO_PWR_ON_OFF, "auto_disable_screensaver", "Auto disable screen saver",
|
||||
"True enables compatible rigs to have their screen saver disabled on open",
|
||||
"0", RIG_CONF_CHECKBUTTON, { }
|
||||
},
|
||||
|
||||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
@ -552,6 +562,22 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
|
|||
rig_set_cache_timeout_ms(rig, HAMLIB_CACHE_ALL, atol(val));
|
||||
break;
|
||||
|
||||
case TOK_AUTO_PWR_ON_OFF:
|
||||
if (1 != sscanf(val, "%d", &val_i))
|
||||
{
|
||||
return -RIG_EINVAL; //value format error
|
||||
}
|
||||
rs->auto_pwr_on_off = val_i ? 1 : 0;
|
||||
break;
|
||||
|
||||
case TOK_AUTO_DISABLE_SCREENSAVER:
|
||||
if (1 != sscanf(val, "%d", &val_i))
|
||||
{
|
||||
return -RIG_EINVAL; //value format error
|
||||
}
|
||||
rs->auto_disable_screensaver = val_i ? 1 : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
@ -864,6 +890,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val)
|
|||
sprintf(val, "%d", rig_get_cache_timeout_ms(rig, HAMLIB_CACHE_ALL));
|
||||
break;
|
||||
|
||||
case TOK_AUTO_PWR_ON_OFF:
|
||||
sprintf(val, "%d", rs->auto_pwr_on_off);
|
||||
break;
|
||||
|
||||
case TOK_AUTO_DISABLE_SCREENSAVER:
|
||||
sprintf(val, "%d", rs->auto_disable_screensaver);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
|
11
src/rig.c
11
src/rig.c
|
@ -925,10 +925,13 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
}
|
||||
}
|
||||
|
||||
// try to turn off the screensaver if possible
|
||||
// don't care about the return here...it's just a nice-to-have
|
||||
parm_value.i = 0;
|
||||
rig_set_parm(rig, RIG_PARM_SCREENSAVER, parm_value);
|
||||
if (rs->auto_disable_screensaver)
|
||||
{
|
||||
// try to turn off the screensaver if possible
|
||||
// don't care about the return here...it's just a nice-to-have
|
||||
parm_value.i = 0;
|
||||
rig_set_parm(rig, RIG_PARM_SCREENSAVER, parm_value);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
|
|
|
@ -104,6 +104,10 @@
|
|||
#define TOK_RANGE_NAME TOKEN_FRONTEND(122)
|
||||
/** \brief rig: Cache timeout */
|
||||
#define TOK_CACHE_TIMEOUT TOKEN_FRONTEND(123)
|
||||
/** \brief rig: Auto power on/off */
|
||||
#define TOK_AUTO_PWR_ON_OFF TOKEN_FRONTEND(124)
|
||||
/** \brief rig: Auto disable screensaver */
|
||||
#define TOK_AUTO_DISABLE_SCREENSAVER TOKEN_FRONTEND(125)
|
||||
/*
|
||||
* rotator specific tokens
|
||||
* (strictly, should be documented as rotator_internal)
|
||||
|
|
Ładowanie…
Reference in New Issue