[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 281febec6221ba8eeaff8
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2020-07-04 22:30:15
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 281febec6221ba8eeaff8da4cc5740c3baecdb2d (commit) via 3f4002972039459e0f39f6d68d739161d7bb50ed (commit) from 5007765d102694ebaf79a964056bb04ec4d88cbf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 281febec6221ba8eeaff8da4cc5740c3baecdb2d Author: Bill Somerville <bi...@cl...> Date: Sat Jul 4 23:23:39 2020 +0100 New power on option rather than power on/off Also fixes incorrect token name usage in token definition diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 2a7adc02..b6d1a8d8 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2028,8 +2028,8 @@ 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_power_on; /*!< Allow Hamlib to power rig + automatically if supported */ int auto_disable_screensaver; /*!< Allow Hamlib to disable the rig's screen saver automatically if supported */ diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 5f8b39a1..5f3ec087 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -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 && rs->auto_pwr_on_off) + if (retval != RIG_OK && priv->poweron == 0 && rs->auto_power_on) { // maybe we need power on? rig_debug(RIG_DEBUG_VERBOSE, "%s trying power on\n", __func__); diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 40669d86..c5fbc473 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -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 && rig->state.auto_pwr_on_off) + if (err == RIG_OK && powerstat == 0 && priv->poweron == 0 && rig->state.auto_power_on) { rig_debug(RIG_DEBUG_TRACE, "%s: got PS0 so powerup\n", __func__); rig_set_powerstat(rig, 1); @@ -735,7 +735,7 @@ int kenwood_open(RIG *rig) err = RIG_OK; // reset our err back to OK for later checks } - if (err == -RIG_ETIMEOUT && rig->state.auto_pwr_on_off) + if (err == -RIG_ETIMEOUT && rig->state.auto_power_on) { // Ensure rig is on rig_set_powerstat(rig, 1); diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 08a00f42..cd133703 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -366,7 +366,7 @@ int newcat_open(RIG *rig) __func__, rig_s->rigport.post_write_delay); /* Ensure rig is powered on */ - if (priv->poweron == 0 && rig_s->auto_pwr_on_off) + if (priv->poweron == 0 && rig_s->auto_power_on) { rig_set_powerstat(rig, 1); priv->poweron = 1; diff --git a/src/conf.c b/src/conf.c index c650ba2a..dd7a9572 100644 --- a/src/conf.c +++ b/src/conf.c @@ -129,12 +129,12 @@ static const struct confparams frontend_cfg_params[] = "500", RIG_CONF_NUMERIC, { .n = {0, 5000, 1}} }, { - TOK_AUTO_PWR_ON_OFF, "auto_pwr_on_off", "Auto power on/off", + TOK_AUTO_POWER_ON, "auto_power_on", "Auto power on", "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", + TOK_AUTO_DISABLE_SCREENSAVER, "auto_disable_screensaver", "Auto disable screen saver", "True enables compatible rigs to have their screen saver disabled on open", "0", RIG_CONF_CHECKBUTTON, { } }, @@ -562,12 +562,12 @@ 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: + case TOK_AUTO_POWER_ON: if (1 != sscanf(val, "%d", &val_i)) { return -RIG_EINVAL; //value format error } - rs->auto_pwr_on_off = val_i ? 1 : 0; + rs->auto_power_on = val_i ? 1 : 0; break; case TOK_AUTO_DISABLE_SCREENSAVER: @@ -890,8 +890,8 @@ 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); + case TOK_AUTO_POWER_ON: + sprintf(val, "%d", rs->auto_power_on); break; case TOK_AUTO_DISABLE_SCREENSAVER: diff --git a/src/token.h b/src/token.h index cfcc5ae1..8e5fdd9b 100644 --- a/src/token.h +++ b/src/token.h @@ -104,8 +104,8 @@ #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 power on rig_open when supported */ +#define TOK_AUTO_POWER_ON TOKEN_FRONTEND(124) /** \brief rig: Auto disable screensaver */ #define TOK_AUTO_DISABLE_SCREENSAVER TOKEN_FRONTEND(125) /* commit 3f4002972039459e0f39f6d68d739161d7bb50ed Author: Bill Somerville <bi...@cl...> Date: Sat Jul 4 17:26:54 2020 +0100 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. diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index ef9c4627..2a7adc02 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -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 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 5b7c4117..5f8b39a1 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -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__); diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 001c5f3b..40669d86 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -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 diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 550dc55a..08a00f42 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -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 */ diff --git a/src/conf.c b/src/conf.c index 43c8bed7..c650ba2a 100644 --- a/src/conf.c +++ b/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; } diff --git a/src/rig.c b/src/rig.c index 46d524a1..274d1a65 100644 --- a/src/rig.c +++ b/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 diff --git a/src/token.h b/src/token.h index 0ffa13b0..cfcc5ae1 100644 --- a/src/token.h +++ b/src/token.h @@ -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) ----------------------------------------------------------------------- Summary of changes: include/hamlib/rig.h | 5 +++++ rigs/icom/icom.c | 2 +- rigs/kenwood/kenwood.c | 16 +++++++--------- rigs/yaesu/newcat.c | 4 ++-- src/conf.c | 34 ++++++++++++++++++++++++++++++++++ src/rig.c | 11 +++++++---- src/token.h | 4 ++++ 7 files changed, 60 insertions(+), 16 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |