From d88881fecda0333df7eab027bee67d85ff78eb30 Mon Sep 17 00:00:00 2001 From: Mikael Nousiainen Date: Sun, 21 Jan 2018 16:00:37 +0200 Subject: [PATCH] Add an option to output static values for RIG_LEVEL_STRENGTH and RIG_LEVEL_RAWSTR for integration testing purposes --- dummy/dummy.c | 36 +++++++++++++++++++++++------------- dummy/dummy.h | 3 ++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dummy/dummy.c b/dummy/dummy.c index f56fc96c8..d46972243 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -61,7 +61,8 @@ struct dummy_priv_data { struct ext_list *ext_parms; - char *magic_conf; + char *magic_conf; + int static_data; }; /* levels pertain to each VFO */ @@ -91,6 +92,9 @@ static const struct confparams dummy_cfg_params[] = { { TOK_CFG_MAGICCONF, "mcfg", "Magic conf", "Magic parameter, as an example", "DX", RIG_CONF_STRING, { } }, + { TOK_CFG_STATIC_DATA, "static_data", "Static data", "Output only static data, no randomization of S-meter values", + "0", RIG_CONF_CHECKBUTTON, { } + }, { RIG_CONF_END, NULL, } }; @@ -276,6 +280,9 @@ static int dummy_set_conf(RIG *rig, token_t token, const char *val) priv->magic_conf = strdup(val); } break; + case TOK_CFG_STATIC_DATA: + priv->static_data = atoi(val) ? 1 : 0; + break; default: return -RIG_EINVAL; } @@ -808,20 +815,23 @@ static int dummy_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) if (idx >= RIG_SETTING_MAX) return -RIG_EINVAL; - /* make S-Meter jiggle */ if (level == RIG_LEVEL_STRENGTH || level == RIG_LEVEL_RAWSTR) { + if (priv->static_data) { + curr->levels[idx].i = -12; + } else { + /* make S-Meter jiggle */ + int qrm = -56; + if (curr->freq < MHz(7)) + qrm = -20; + else if (curr->freq < MHz(21)) + qrm = -30; + else if (curr->freq < MHz(50)) + qrm = -50; - int qrm = -56; - if (curr->freq < MHz(7)) - qrm = -20; - else if (curr->freq < MHz(21)) - qrm = -30; - else if (curr->freq < MHz(50)) - qrm = -50; - - curr->levels[idx].i = qrm + time(NULL)%32 + rand()%4 - - curr->levels[LVL_ATT].i - + curr->levels[LVL_PREAMP].i; + curr->levels[idx].i = qrm + time(NULL)%32 + rand()%4 + - curr->levels[LVL_ATT].i + + curr->levels[LVL_PREAMP].i; + } } *val = curr->levels[idx]; diff --git a/dummy/dummy.h b/dummy/dummy.h index a5e603742..30466a589 100644 --- a/dummy/dummy.h +++ b/dummy/dummy.h @@ -26,7 +26,8 @@ #include "token.h" /* backend conf */ -#define TOK_CFG_MAGICCONF TOKEN_BACKEND(1) +#define TOK_CFG_MAGICCONF TOKEN_BACKEND(1) +#define TOK_CFG_STATIC_DATA TOKEN_BACKEND(2) /* ext_level's and ext_parm's tokens */