diff --git a/dummy/dummy.c b/dummy/dummy.c index 85682c639..5bfad8945 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -73,6 +73,7 @@ struct dummy_priv_data channel_t vfo_b; channel_t mem[NB_CHAN]; + struct ext_list *ext_funcs; struct ext_list *ext_parms; char *magic_conf; @@ -104,6 +105,15 @@ static const struct confparams dummy_ext_levels[] = { RIG_CONF_END, NULL, } }; +static const struct confparams dummy_ext_funcs[] = +{ + { + TOK_EL_MAGICEXTFUNC, "MGEF", "Magic ext func", "Magic ext function, as an example", + NULL, RIG_CONF_CHECKBUTTON + }, + { RIG_CONF_END, NULL, } +}; + /* parms pertain to the whole rig */ static const struct confparams dummy_ext_parms[] = { @@ -270,6 +280,13 @@ static int dummy_init(RIG *rig) return -RIG_ENOMEM; } + priv->ext_funcs = alloc_init_ext(dummy_ext_funcs); + + if (!priv->ext_funcs) + { + return -RIG_ENOMEM; + } + priv->ext_parms = alloc_init_ext(dummy_ext_parms); if (!priv->ext_parms) @@ -309,6 +326,7 @@ static int dummy_cleanup(RIG *rig) free(priv->vfo_a.ext_levels); free(priv->vfo_b.ext_levels); + free(priv->ext_funcs); free(priv->ext_parms); free(priv->magic_conf); @@ -1240,6 +1258,93 @@ static int dummy_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) } +static int dummy_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status) +{ + struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; + const struct confparams *cfp; + struct ext_list *elp; + + cfp = rig_ext_lookup_tok(rig, token); + + if (!cfp) + { + return -RIG_EINVAL; + } + + switch (token) + { + case TOK_EL_MAGICEXTFUNC: + break; + + default: + return -RIG_EINVAL; + } + + switch (cfp->type) + { + case RIG_CONF_CHECKBUTTON: + break; + case RIG_CONF_BUTTON: + break; + default: + return -RIG_EINTERNAL; + } + + elp = find_ext(priv->ext_funcs, token); + + if (!elp) + { + return -RIG_EINTERNAL; + } + + /* store value */ + elp->val.i = status; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %d\n", __func__, + cfp->name, status); + + return RIG_OK; +} + + +static int dummy_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status) +{ + struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; + const struct confparams *cfp; + struct ext_list *elp; + + cfp = rig_ext_lookup_tok(rig, token); + + if (!cfp) + { + return -RIG_EINVAL; + } + + switch (token) + { + case TOK_EL_MAGICEXTFUNC: + break; + default: + return -RIG_EINVAL; + } + + elp = find_ext(priv->ext_funcs, token); + + if (!elp) + { + return -RIG_EINTERNAL; + } + + /* load value */ + *status = elp->val.i; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, + cfp->name); + + return RIG_OK; +} + + static int dummy_set_powerstat(RIG *rig, powerstat_t status) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; @@ -2034,6 +2139,7 @@ struct rig_caps dummy_caps = .priv = NULL, /* priv */ .extlevels = dummy_ext_levels, + .extfuncs = dummy_ext_funcs, .extparms = dummy_ext_parms, .cfgparams = dummy_cfg_params, @@ -2062,6 +2168,8 @@ struct rig_caps dummy_caps = .get_parm = dummy_get_parm, .set_ext_level = dummy_set_ext_level, .get_ext_level = dummy_get_ext_level, + .set_ext_func = dummy_set_ext_func, + .get_ext_func = dummy_get_ext_func, .set_ext_parm = dummy_set_ext_parm, .get_ext_parm = dummy_get_ext_parm, @@ -2196,6 +2304,7 @@ struct rig_caps dummy_no_vfo_caps = .priv = NULL, /* priv */ .extlevels = dummy_ext_levels, + .extfuncs = dummy_ext_funcs, .extparms = dummy_ext_parms, .cfgparams = dummy_cfg_params, @@ -2224,6 +2333,8 @@ struct rig_caps dummy_no_vfo_caps = .get_parm = dummy_get_parm, .set_ext_level = dummy_set_ext_level, .get_ext_level = dummy_get_ext_level, + .set_ext_func = dummy_set_ext_func, + .get_ext_func = dummy_get_ext_func, .set_ext_parm = dummy_set_ext_parm, .get_ext_parm = dummy_get_ext_parm, diff --git a/dummy/dummy.h b/dummy/dummy.h index 5d93d5aa9..61642549d 100644 --- a/dummy/dummy.h +++ b/dummy/dummy.h @@ -31,11 +31,12 @@ /* ext_level's and ext_parm's tokens */ -#define TOK_EL_MAGICLEVEL TOKEN_BACKEND(1) -#define TOK_EL_MAGICFUNC TOKEN_BACKEND(2) -#define TOK_EL_MAGICOP TOKEN_BACKEND(3) -#define TOK_EP_MAGICPARM TOKEN_BACKEND(4) -#define TOK_EL_MAGICCOMBO TOKEN_BACKEND(5) +#define TOK_EL_MAGICLEVEL TOKEN_BACKEND(1) +#define TOK_EL_MAGICFUNC TOKEN_BACKEND(2) +#define TOK_EL_MAGICOP TOKEN_BACKEND(3) +#define TOK_EP_MAGICPARM TOKEN_BACKEND(4) +#define TOK_EL_MAGICCOMBO TOKEN_BACKEND(5) +#define TOK_EL_MAGICEXTFUNC TOKEN_BACKEND(6) extern struct rig_caps dummy_caps; diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index b382f9d13..19b95b5a8 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2383,6 +2383,12 @@ rig_get_ext_parm HAMLIB_PARAMS((RIG *rig, value_t *val)); extern HAMLIB_EXPORT(int) +rig_ext_func_foreach HAMLIB_PARAMS((RIG *rig, + int (*cfunc)(RIG *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data)); +extern HAMLIB_EXPORT(int) rig_ext_level_foreach HAMLIB_PARAMS((RIG *rig, int (*cfunc)(RIG *, const struct confparams *, diff --git a/rigs/icom/ic7000.c b/rigs/icom/ic7000.c index 5c9551af1..874213c73 100644 --- a/rigs/icom/ic7000.c +++ b/rigs/icom/ic7000.c @@ -129,8 +129,11 @@ .levels = RIG_LEVEL_SET(IC7000_LEVELS), \ } -int ic7000_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); -int ic7000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +struct cmdparams ic7000_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x17}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } +}; /* * IC-7000 rig capabilities. @@ -148,6 +151,7 @@ static const struct icom_priv_caps IC7000_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, + .extcmds = ic7000_extcmds, }; const struct rig_caps ic7000_caps = @@ -296,8 +300,8 @@ const struct rig_caps ic7000_caps = .get_ant = NULL, .decode_event = icom_decode_event, - .set_level = ic7000_set_level, - .get_level = ic7000_get_level, + .set_level = icom_set_level, + .get_level = icom_get_level, .set_func = icom_set_func, .get_func = icom_get_func, .set_parm = NULL, @@ -329,39 +333,3 @@ const struct rig_caps ic7000_caps = .get_split_vfo = NULL, }; - -int ic7000_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x17; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, 1, val); - - default: - return icom_set_level(rig, vfo, level, val); - } -} - -int ic7000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x17; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, val); - - default: - return icom_get_level(rig, vfo, level, val); - } -} diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index a2c40c042..3602969f1 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -61,19 +61,6 @@ static int ic7300_get_parm(RIG *rig, setting_t parm, value_t *val); #define IC7300_ANTS (RIG_ANT_1) /* ant-1 is Hf-6m */ -struct cmdparams ic7300_extcmds[] = -{ - { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x23}, CMD_DAT_BOL, 1 }, - { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x81}, CMD_DAT_LVL, 2 }, - { {.s = RIG_PARM_TIME}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x95}, CMD_DAT_TIM, 2 }, - { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x59}, CMD_DAT_INT, 1 }, - { {.s = RIG_PARM_NONE} } -}; - -struct cmdparams ic7300_extlevels[] = -{ -}; - /* * IC-7300 S-meter levels measured from live signals on multiple bands. Provides a good approximation. */ @@ -153,15 +140,6 @@ struct cmdparams ic7300_extlevels[] = #define IC9700_ALL_TX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD) #define IC9700_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD) -struct cmdparams ic9700_extcmds[] = -{ - { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x29}, CMD_DAT_BOL, 1 }, - { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x52}, CMD_DAT_LVL, 2 }, - { {.s = RIG_PARM_SCREENSAVER}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, - { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x30}, CMD_DAT_INT, 1 }, - { {0} } -}; - #define IC9700_STR_CAL { 7, \ { \ { 0, -54 }, \ @@ -216,6 +194,35 @@ struct cmdparams ic9700_extcmds[] = { 241, 20.0f } \ } } +struct cmdparams ic7300_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x23}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x81}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x95}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x59}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } +}; + +struct cmdparams ic9700_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x29}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x52}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_SCREENSAVER}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_TIME}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x80}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x30}, CMD_DAT_INT, 1 }, + { {0} } +}; + +struct cmdparams ic705_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x31}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x36}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_SCREENSAVER}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x38}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_TIME}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x66}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x59}, CMD_DAT_INT, 1 }, + { {0} } +}; + /* * IC-7300 rig capabilities. */ @@ -266,7 +273,7 @@ static const struct icom_priv_caps IC705_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .extcmds = ic7300_extcmds, /* Custom parameters */ + .extcmds = ic705_extcmds, /* Custom parameters */ }; const struct rig_caps ic7300_caps = @@ -391,7 +398,6 @@ 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, @@ -640,7 +646,6 @@ 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, @@ -841,7 +846,6 @@ 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, @@ -893,7 +897,6 @@ const struct rig_caps ic705_caps = int ic7300_set_parm(RIG *rig, setting_t parm, value_t val) { unsigned char prmbuf[MAXFRAMELEN]; - int min, hr; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -966,38 +969,8 @@ int ic7300_set_parm(RIG *rig, setting_t parm, value_t val) return -RIG_EINVAL; } - case RIG_PARM_TIME: - hr = (int)((float) val.i / 3600.0); - min = (int)((float)(val.i - (hr * 3600)) / 60.0); - - switch (rig->caps->rig_model) - { - case RIG_MODEL_IC7300: - prmbuf[0] = 0x00; - prmbuf[1] = 0x95; - break; - - case RIG_MODEL_IC9700: - prmbuf[0] = 0x01; - prmbuf[1] = 0x80; - break; - - case RIG_MODEL_IC705: - prmbuf[0] = 0x01; - prmbuf[1] = 0x66; - break; - - default: - return -RIG_ENIMPL; - } - - to_bcd_be(prmbuf + 2, (long long) hr, 2); - to_bcd_be(prmbuf + 3, (long long) min, 2); - return icom_set_raw(rig, C_CTL_MEM, S_MEM_PARM, 4, prmbuf, 0, 0); - default: - rig_debug(RIG_DEBUG_ERR, "Unsupported set_parm %s\n", rig_strparm(parm)); - return -RIG_EINVAL; + return icom_set_parm(rig, parm, val); } } @@ -1058,4 +1031,3 @@ int ic7300_get_parm(RIG *rig, setting_t parm, value_t *val) return RIG_OK; } - diff --git a/rigs/icom/ic7410.c b/rigs/icom/ic7410.c index 443fbf5cd..e922ee08c 100644 --- a/rigs/icom/ic7410.c +++ b/rigs/icom/ic7410.c @@ -85,8 +85,11 @@ { 213, 1.0f } \ } } -int ic7410_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); -int ic7410_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +struct cmdparams ic7410_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 1, {0x75 }, CMD_DAT_INT, 1 }, + { {0} } +}; /* * IC-7410 rig capabilities. @@ -240,8 +243,8 @@ const struct rig_caps ic7410_caps = .get_ant = icom_get_ant, .decode_event = icom_decode_event, - .set_level = ic7410_set_level, - .get_level = ic7410_get_level, + .set_level = icom_set_level, + .get_level = icom_get_level, .set_func = icom_set_func, .get_func = icom_get_func, .set_parm = icom_set_parm, @@ -271,37 +274,3 @@ const struct rig_caps ic7410_caps = .send_morse = icom_send_morse, }; - -int ic7410_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x75; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 1, cmdbuf, 1, val); - - default: - return icom_set_level(rig, vfo, level, val); - } -} - -int ic7410_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x75; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 1, cmdbuf, val); - - default: - return icom_get_level(rig, vfo, level, val); - } -} diff --git a/rigs/icom/ic7600.c b/rigs/icom/ic7600.c index 1b7add09c..28ddd476c 100644 --- a/rigs/icom/ic7600.c +++ b/rigs/icom/ic7600.c @@ -53,15 +53,6 @@ #define IC7600_ANTS (RIG_ANT_1|RIG_ANT_2) -struct cmdparams ic7600_extcmds[] = -{ - { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x59}, CMD_DAT_BOL, 1 }, - { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_LVL, 2 }, - { {.s = RIG_PARM_TIME}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x54}, CMD_DAT_TIM, 2 }, - { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, - { {.s = RIG_PARM_NONE} } -}; - /* * Measurement by Roeland, PA3MET */ @@ -129,10 +120,21 @@ struct cmdparams ic7600_extcmds[] = { 241, 25.0f } \ } } +struct cmdparams ic7600_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x59}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, CMD_PARAM_TYPE_PARM, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x54}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, + { { 0 } } +}; + +int ic7600_ext_tokens[] = { + TOK_DRIVE_GAIN, TOK_BACKEND_NONE +}; + /* * IC-7600 rig capabilities. - * - * TODO: complete command set (esp. the $1A bunch!) and testing.. */ static const struct icom_priv_caps ic7600_priv_caps = { @@ -152,15 +154,6 @@ static const struct icom_priv_caps ic7600_priv_caps = .extcmds = ic7600_extcmds, /* Custom op parameters */ }; -const struct confparams ic7600_ext_levels[] = -{ - { - TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "Drive gain", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { RIG_CONF_END, NULL, } -}; - const struct rig_caps ic7600_caps = { RIG_MODEL(RIG_MODEL_IC7600), @@ -196,7 +189,10 @@ const struct rig_caps ic7600_caps = [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 1 } }, }, .parm_gran = {}, - .extlevels = ic7600_ext_levels, + .ext_tokens = ic7600_ext_tokens, + .extfuncs = icom_ext_funcs, + .extlevels = icom_ext_levels, + .extparms = icom_ext_parms, .ctcss_list = common_ctcss_list, .dcs_list = NULL, .preamp = { 10, 20, RIG_DBLST_END, }, /* FIXME: TBC */ diff --git a/rigs/icom/ic7610.c b/rigs/icom/ic7610.c index 013cc935b..8b0dcb1e0 100644 --- a/rigs/icom/ic7610.c +++ b/rigs/icom/ic7610.c @@ -121,13 +121,18 @@ { 241, 30.0f } \ } } -int ic7610_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); -int ic7610_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +struct cmdparams ic7610_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x02, 0x92}, CMD_DAT_INT, 1 }, + { { 0 } } +}; + +int ic7610_ext_tokens[] = { + TOK_DRIVE_GAIN, TOK_DIGI_SEL_FUNC, TOK_DIGI_SEL_LEVEL, TOK_BACKEND_NONE +}; /* * IC-7610 rig capabilities. - * - * TODO: complete command set (esp. the $1A bunch!) and testing.. */ static const struct icom_priv_caps ic7610_priv_caps = { @@ -144,23 +149,7 @@ static const struct icom_priv_caps ic7610_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, -}; - -const struct confparams ic7610_ext_levels[] = -{ - { - TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "Drive gain", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { - TOK_DIGI_SEL_FUNC, "digi_sel", "DIGI-SEL enable", "DIGI-SEL enable", - NULL, RIG_CONF_CHECKBUTTON, { }, - }, - { - TOK_DIGI_SEL_LEVEL, "digi_sel_level", "DIGI-SEL level", "DIGI-SEL level", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { RIG_CONF_END, NULL, } + .extcmds = ic7610_extcmds, }; const struct rig_caps ic7610_caps = @@ -198,7 +187,7 @@ const struct rig_caps ic7610_caps = [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 1 } }, }, .parm_gran = {}, - .extlevels = ic7610_ext_levels, + .ext_tokens = ic7610_ext_tokens, .ctcss_list = common_ctcss_list, .dcs_list = NULL, .preamp = { 10, 20, RIG_DBLST_END, }, /* FIXME: TBC */ @@ -308,8 +297,8 @@ const struct rig_caps ic7610_caps = .set_xit = icom_set_xit_new, .decode_event = icom_decode_event, - .set_level = ic7610_set_level, - .get_level = ic7610_get_level, + .set_level = icom_set_level, + .get_level = icom_get_level, .set_ext_level = icom_set_ext_level, .get_ext_level = icom_get_ext_level, .set_func = icom_set_func, @@ -338,39 +327,3 @@ const struct rig_caps ic7610_caps = .get_powerstat = icom_get_powerstat, .send_morse = icom_send_morse }; - -int ic7610_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x02; - cmdbuf[1] = 0x92; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, 1, val); - - default: - return icom_set_level(rig, vfo, level, val); - } -} - -int ic7610_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x02; - cmdbuf[1] = 0x92; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, val); - - default: - return icom_get_level(rig, vfo, level, val); - } -} diff --git a/rigs/icom/ic7700.c b/rigs/icom/ic7700.c index cd574d5d2..f8c9fa9dc 100644 --- a/rigs/icom/ic7700.c +++ b/rigs/icom/ic7700.c @@ -105,13 +105,18 @@ { 241, 15.0f } \ } } -int ic7700_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); -int ic7700_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +struct cmdparams ic7700_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x82}, CMD_DAT_INT, 1 }, + { { 0 } } +}; + +int ic7700_ext_tokens[] = { + TOK_DRIVE_GAIN, TOK_DIGI_SEL_FUNC, TOK_DIGI_SEL_LEVEL, TOK_BACKEND_NONE +}; /* * IC-7700 rig capabilities. - * - * TODO: complete command set (esp. the $1A bunch!) and testing.. */ static const struct icom_priv_caps ic7700_priv_caps = { @@ -129,23 +134,7 @@ static const struct icom_priv_caps ic7700_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, -}; - -const struct confparams ic7700_ext_levels[] = -{ - { - TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "Drive gain", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { - TOK_DIGI_SEL_FUNC, "digi_sel", "DIGI-SEL enable", "DIGI-SEL enable", - NULL, RIG_CONF_CHECKBUTTON, { }, - }, - { - TOK_DIGI_SEL_LEVEL, "digi_sel_level", "DIGI-SEL level", "DIGI-SEL level", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { RIG_CONF_END, NULL, } + .extcmds = ic7700_extcmds, }; const struct rig_caps ic7700_caps = @@ -183,7 +172,7 @@ const struct rig_caps ic7700_caps = [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 1 } }, }, .parm_gran = {}, - .extlevels = ic7700_ext_levels, + .ext_tokens = ic7700_ext_tokens, .ctcss_list = common_ctcss_list, .dcs_list = NULL, .preamp = { 10, 20, RIG_DBLST_END, }, /* FIXME: TBC */ @@ -293,8 +282,8 @@ const struct rig_caps ic7700_caps = .set_xit = icom_set_xit_new, .decode_event = icom_decode_event, - .set_level = ic7700_set_level, - .get_level = ic7700_get_level, + .set_level = icom_set_level, + .get_level = icom_get_level, .set_ext_level = icom_set_ext_level, .get_ext_level = icom_get_ext_level, .set_func = icom_set_func, @@ -323,39 +312,3 @@ const struct rig_caps ic7700_caps = .get_powerstat = icom_get_powerstat, .send_morse = icom_send_morse }; - -int ic7700_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x82; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, 1, val); - - default: - return icom_set_level(rig, vfo, level, val); - } -} - -int ic7700_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x82; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, val); - - default: - return icom_get_level(rig, vfo, level, val); - } -} diff --git a/rigs/icom/ic7800.c b/rigs/icom/ic7800.c index 046d87f21..be9d82e38 100644 --- a/rigs/icom/ic7800.c +++ b/rigs/icom/ic7800.c @@ -108,10 +108,18 @@ int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); int ic7800_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +struct cmdparams ic7800_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x83}, CMD_DAT_INT, 1 }, + { { 0 } } +}; + +int ic7800_ext_tokens[] = { + TOK_DRIVE_GAIN, TOK_DIGI_SEL_FUNC, TOK_DIGI_SEL_LEVEL, TOK_BACKEND_NONE +}; + /* * IC-7800 rig capabilities. - * - * TODO: complete command set (esp. the $1A bunch!) and testing.. */ static const struct icom_priv_caps ic7800_priv_caps = { @@ -129,23 +137,7 @@ static const struct icom_priv_caps ic7800_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, -}; - -const struct confparams ic7800_ext_levels[] = -{ - { - TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "Drive gain", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { - TOK_DIGI_SEL_FUNC, "digi_sel", "DIGI-SEL enable", "DIGI-SEL enable", - NULL, RIG_CONF_CHECKBUTTON, { }, - }, - { - TOK_DIGI_SEL_LEVEL, "digi_sel_level", "DIGI-SEL level", "DIGI-SEL level", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { RIG_CONF_END, NULL, } + .extcmds = ic7800_extcmds, }; const struct rig_caps ic7800_caps = @@ -183,7 +175,7 @@ const struct rig_caps ic7800_caps = [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 1 } }, }, .parm_gran = {}, - .extlevels = ic7800_ext_levels, + .ext_tokens = ic7800_ext_tokens, .ctcss_list = common_ctcss_list, .dcs_list = NULL, .preamp = { 10, 20, RIG_DBLST_END, }, /* FIXME: TBC */ @@ -331,8 +323,6 @@ const struct rig_caps ic7800_caps = */ int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - unsigned char cmdbuf[MAXFRAMELEN]; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); switch (level) @@ -356,12 +346,6 @@ int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } return icom_set_level(rig, vfo, level, val); - - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x83; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, 1, val); - default: return icom_set_level(rig, vfo, level, val); } @@ -372,7 +356,6 @@ int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) */ int ic7800_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - unsigned char cmdbuf[MAXFRAMELEN]; int retval; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -394,14 +377,7 @@ int ic7800_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { val->i = rig->state.attenuator[val->i - 1]; } - break; - - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x83; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, val); - default: return icom_get_level(rig, vfo, level, val); } diff --git a/rigs/icom/ic785x.c b/rigs/icom/ic785x.c index bf7988ab5..70bf71c73 100644 --- a/rigs/icom/ic785x.c +++ b/rigs/icom/ic785x.c @@ -113,10 +113,19 @@ extern int ic7800_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); int ic785x_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); int ic785x_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +struct cmdparams ic785x_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x09}, CMD_DAT_INT, 1 }, + { { 0 } } +}; + + +int ic785x_ext_tokens[] = { + TOK_DRIVE_GAIN, TOK_DIGI_SEL_FUNC, TOK_DIGI_SEL_LEVEL, TOK_BACKEND_NONE +}; + /* * IC-785x rig capabilities. - * - * TODO: complete command set (esp. the $1A bunch!) and testing.. */ static struct icom_priv_caps ic785x_priv_caps = { @@ -134,23 +143,7 @@ static struct icom_priv_caps ic785x_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, -}; - -const struct confparams ic785x_ext_levels[] = -{ - { - TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "Drive gain", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { - TOK_DIGI_SEL_FUNC, "digi_sel", "DIGI-SEL enable", "DIGI-SEL enable", - NULL, RIG_CONF_CHECKBUTTON, { }, - }, - { - TOK_DIGI_SEL_LEVEL, "digi_sel_level", "DIGI-SEL level", "DIGI-SEL level", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } }, - }, - { RIG_CONF_END, NULL, } + .extcmds = ic785x_extcmds, }; const struct rig_caps ic785x_caps = @@ -188,7 +181,7 @@ const struct rig_caps ic785x_caps = [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 1 } }, }, .parm_gran = {}, - .extlevels = ic785x_ext_levels, + .ext_tokens = ic785x_ext_tokens, .ctcss_list = common_ctcss_list, .dcs_list = NULL, .preamp = { 10, 20, RIG_DBLST_END, }, /* FIXME: TBC */ @@ -332,36 +325,10 @@ const struct rig_caps ic785x_caps = int ic785x_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x03; - cmdbuf[1] = 0x09; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, 1, val); - - default: - return ic7800_set_level(rig, vfo, level, val); - } + return ic7800_set_level(rig, vfo, level, val); } int ic785x_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x03; - cmdbuf[1] = 0x09; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, val); - - default: - return ic7800_get_level(rig, vfo, level, val); - } + return ic7800_get_level(rig, vfo, level, val); } diff --git a/rigs/icom/ic9100.c b/rigs/icom/ic9100.c index 61f36039c..3ab054611 100644 --- a/rigs/icom/ic9100.c +++ b/rigs/icom/ic9100.c @@ -92,8 +92,12 @@ #define IC9100_HF_ANTS (RIG_ANT_1|RIG_ANT_2) -/* - */ +struct cmdparams ic9100_extcmds[] = +{ + { {.s = RIG_LEVEL_VOXDELAY}, CMD_PARAM_TYPE_LEVEL, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x27}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } +}; + static const struct icom_priv_caps ic9100_priv_caps = { 0x7c, /* default address */ @@ -102,6 +106,7 @@ static const struct icom_priv_caps ic9100_priv_caps = ic910_ts_sc_list, /* FIXME */ .antack_len = 2, .ant_count = 2, + .extcmds = ic9100_extcmds, }; const struct rig_caps ic9100_caps = @@ -279,45 +284,3 @@ const struct rig_caps ic9100_caps = .get_split_mode = icom_get_split_mode, }; - -#ifdef XXREMOVEDXX -// Not referenced anywhere -int ic9100_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x27; - return icom_set_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, 1, val); - - default: - return icom_set_level(rig, vfo, level, val); - } -} -#endif - -#ifdef XXREMOVEDXX -// Not referenced anywhere -int ic9100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) -{ - unsigned char cmdbuf[MAXFRAMELEN]; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - switch (level) - { - case RIG_LEVEL_VOXDELAY: - cmdbuf[0] = 0x01; - cmdbuf[1] = 0x27; - return icom_get_level_raw(rig, level, C_CTL_MEM, 0x05, 2, cmdbuf, val); - - default: - return icom_get_level(rig, vfo, level, val); - } -} -#endif diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 0cad1438f..df5b4a590 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -422,7 +422,8 @@ const struct confparams icom_cfg_params[] = */ const struct confparams icom_ext_funcs[] = { - {} + { TOK_DIGI_SEL_FUNC, "digi_sel", "DIGI-SEL enable", "", "", RIG_CONF_CHECKBUTTON, {} }, + { RIG_CONF_END, NULL, } }; /* @@ -430,13 +431,14 @@ const struct confparams icom_ext_funcs[] = */ const struct confparams icom_ext_levels[] = { - {} + { TOK_DIGI_SEL_LEVEL, "digi_sel_level", "DIGI-SEL level", "", "", RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } } }, + { TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "", "", RIG_CONF_NUMERIC, { .n = { 0, 255, 1 } } }, + { RIG_CONF_END, NULL, } }; /* * Lookup table for icom_get_ext_parm */ - const struct confparams icom_ext_parms[] = { { TOK_DSTAR_DSQL, "dsdsql", "D-STAR CSQL Status", "", "", RIG_CONF_CHECKBUTTON, {} }, @@ -450,9 +452,6 @@ const struct confparams icom_ext_parms[] = { TOK_DSTAR_MY_CS, "dsmycs", "D-STAR MY Call Sign", "", "", RIG_CONF_STRING, {} }, { TOK_DSTAR_TX_CS, "dstxcs", "D-STAR Tx Call Sign", "", "", RIG_CONF_BINARY, {} }, { TOK_DSTAR_TX_MESS, "dstmes", "D-STAR Tx Message", "", "", RIG_CONF_STRING, {} }, - { TOK_DRIVE_GAIN, "drive_gain", "Drive gain", "", "", RIG_CONF_NUMERIC, {} }, - { TOK_DIGI_SEL_FUNC, "digi_sel", "DIGI-SEL enable", "", "", RIG_CONF_CHECKBUTTON, {} }, - { TOK_DIGI_SEL_LEVEL, "digi_sel_level", "DIGI-SEL level", "", "", RIG_CONF_NUMERIC, {} }, { TOK_SCOPE_DAT, "scpdat", "Scope data", "", "", RIG_CONF_BINARY, {} }, { TOK_SCOPE_STS, "scpsts", "Scope status", "", "", RIG_CONF_CHECKBUTTON, {} }, { TOK_SCOPE_DOP, "scpdop", "Scope data output", "", "", RIG_CONF_CHECKBUTTON, {} }, @@ -487,9 +486,9 @@ const struct cmdparams icom_ext_cmd[] = { {.t = TOK_DSTAR_MY_CS}, CMD_PARAM_TYPE_TOKEN, C_CTL_DVT, S_DVT_DSMYCS, SC_MOD_RW, 1, {0}, CMD_DAT_STR, 12 }, { {.t = TOK_DSTAR_TX_CS}, CMD_PARAM_TYPE_TOKEN, C_CTL_DVT, S_DVT_DSTXCS, SC_MOD_RW, 1, {0}, CMD_DAT_STR, 24 }, { {.t = TOK_DSTAR_TX_MESS}, CMD_PARAM_TYPE_TOKEN, C_CTL_DVT, S_DVT_DSTXMS, SC_MOD_RW, 1, {0}, CMD_DAT_STR, 20 }, - { {.t = TOK_DRIVE_GAIN}, CMD_PARAM_TYPE_TOKEN, C_CTL_LVL, S_LVL_DRIVE, SC_MOD_RW, 1, {0}, CMD_DAT_FLT, 2 }, - { {.t = TOK_DIGI_SEL_FUNC}, CMD_PARAM_TYPE_TOKEN, C_CTL_FUNC, S_FUNC_DIGISEL, SC_MOD_RW, 1, {0}, CMD_DAT_BOL, 1 }, - { {.t = TOK_DIGI_SEL_LEVEL}, CMD_PARAM_TYPE_TOKEN, C_CTL_LVL, S_LVL_DIGI, SC_MOD_RW, 1, {0}, CMD_DAT_FLT, 2 }, + { {.t = TOK_DRIVE_GAIN}, CMD_PARAM_TYPE_TOKEN, C_CTL_LVL, S_LVL_DRIVE, SC_MOD_RW, 0, {0}, CMD_DAT_FLT, 2 }, + { {.t = TOK_DIGI_SEL_FUNC}, CMD_PARAM_TYPE_TOKEN, C_CTL_FUNC, S_FUNC_DIGISEL, SC_MOD_RW, 0, {0}, CMD_DAT_BOL, 1 }, + { {.t = TOK_DIGI_SEL_LEVEL}, CMD_PARAM_TYPE_TOKEN, C_CTL_LVL, S_LVL_DIGI, SC_MOD_RW, 0, {0}, CMD_DAT_FLT, 2 }, { {.t = TOK_SCOPE_DAT}, CMD_PARAM_TYPE_TOKEN, C_CTL_SCP, S_SCP_DAT, SC_MOD_RD, 0, {0}, CMD_DAT_BUF, 481 }, { {.t = TOK_SCOPE_STS}, CMD_PARAM_TYPE_TOKEN, C_CTL_SCP, S_SCP_STS, SC_MOD_RW, 0, {0}, CMD_DAT_BOL, 1 }, { {.t = TOK_SCOPE_DOP}, CMD_PARAM_TYPE_TOKEN, C_CTL_SCP, S_SCP_DOP, SC_MOD_RW, 0, {0}, CMD_DAT_BOL, 1 }, @@ -2210,16 +2209,16 @@ int icom_set_cmd(RIG *rig, vfo_t vfo, struct cmdparams *par, value_t val) break; case CMD_DAT_FLT: - to_bcd_be(&cmdbuf[cmdlen], (int) val.f, (cmdlen * 2)); + to_bcd_be(&cmdbuf[cmdlen], (int) val.f, (par->datlen * 2)); break; case CMD_DAT_LVL: - to_bcd_be(&cmdbuf[cmdlen], (int)(val.f * 255.0), (cmdlen * 2)); + to_bcd_be(&cmdbuf[cmdlen], (int)(val.f * 255.0), (par->datlen * 2)); break; case CMD_DAT_TIM: // returned as seconds since midnight to_bcd_be(&cmdbuf[cmdlen], - ((((int)val.f / 3600) * 100) + (((int)val.f / 60) % 60)), (par->datlen * 2)); + ((((int)val.i / 3600) * 100) + (((int)val.i / 60) % 60)), (par->datlen * 2)); break; default: @@ -2340,13 +2339,13 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - const struct cmdparams *cmd = priv_caps->extcmds; + const struct cmdparams *extcmds = priv_caps->extcmds; - for (i = 0; cmd && cmd[i].id.s != 0; i++) + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) { - if (cmd[i].cmdparamtype == CMD_PARAM_TYPE_LEVEL && cmd[i].id.s == level) + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_LEVEL && extcmds[i].id.s == level) { - return icom_set_cmd(rig, vfo, (struct cmdparams *)&cmd[i], val); + return icom_set_cmd(rig, vfo, (struct cmdparams *)&extcmds[i], val); } } @@ -2696,18 +2695,16 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - const struct icom_priv_caps *priv = rig->caps->priv; - const struct cmdparams *cmd = priv->extcmds; + const struct cmdparams *extcmds = priv_caps->extcmds; int i; - - for (i = 0; cmd && cmd[i].id.s != 0; i++) + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) { rig_debug(RIG_DEBUG_TRACE, "%s: i=%d\n", __func__, i); - if (cmd[i].cmdparamtype == CMD_PARAM_TYPE_LEVEL && cmd[i].id.s == level) + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_LEVEL && extcmds[i].id.s == level) { - return icom_get_cmd(rig, vfo, (struct cmdparams *)&cmd[i], val); + return icom_get_cmd(rig, vfo, (struct cmdparams *)&extcmds[i], val); } } @@ -3191,7 +3188,7 @@ int icom_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) } else if (cfp[i].token == token) { - return icom_get_ext_cmd(rig, vfo, CMD_PARAM_TYPE_LEVEL, token, val); + return icom_get_ext_cmd(rig, vfo, token, val); } else { i++; } } @@ -3216,7 +3213,8 @@ int icom_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status) } else if (cfp[i].token == token) { - return icom_set_ext_cmd(rig, vfo, token, (value_t)status); + value_t value = { .i = status }; + return icom_set_ext_cmd(rig, vfo, token, value); } else { i++; } } @@ -3241,8 +3239,12 @@ int icom_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status) } else if (cfp[i].token == token) { - return icom_get_ext_cmd(rig, vfo, CMD_PARAM_TYPE_FUNC, token, - (value_t *)status); + value_t value; + int result = icom_get_ext_cmd(rig, vfo, token, &value); + if (result == RIG_OK) { + *status = value.i; + } + return result; } else { i++; } } @@ -3292,7 +3294,7 @@ int icom_get_ext_parm(RIG *rig, token_t token, value_t *val) } else if (cfp[i].token == token) { - return icom_get_ext_cmd(rig, RIG_VFO_NONE, CMD_PARAM_TYPE_PARM, token, val); + return icom_get_ext_cmd(rig, RIG_VFO_NONE, token, val); } else { i++; } } @@ -3300,8 +3302,7 @@ int icom_get_ext_parm(RIG *rig, token_t token, value_t *val) return -RIG_EINVAL; } -int icom_get_ext_cmd(RIG *rig, vfo_t vfo, cmd_param_t cmdparamtype, - token_t token, value_t *val) +int icom_get_ext_cmd(RIG *rig, vfo_t vfo, token_t token, value_t *val) { int i; @@ -3312,7 +3313,6 @@ int icom_get_ext_cmd(RIG *rig, vfo_t vfo, cmd_param_t cmdparamtype, { if (rig->caps->ext_tokens[i] == token) { - const struct icom_priv_caps *priv = rig->caps->priv; const struct cmdparams *cmd = priv->extcmds ? priv->extcmds : icom_ext_cmd; @@ -3323,7 +3323,7 @@ int icom_get_ext_cmd(RIG *rig, vfo_t vfo, cmd_param_t cmdparamtype, cmd = icom_ext_cmd; i = 0; } - else if (cmd[i].cmdparamtype == cmdparamtype && cmd[i].id.t == token) + else if (cmd[i].cmdparamtype == CMD_PARAM_TYPE_TOKEN && cmd[i].id.t == token) { return icom_get_cmd(rig, vfo, (struct cmdparams *)&cmd[i], val); } @@ -3348,7 +3348,6 @@ int icom_set_ext_cmd(RIG *rig, vfo_t vfo, token_t token, value_t val) { if (rig->caps->ext_tokens[i] == token) { - const struct icom_priv_caps *priv = rig->caps->priv; const struct cmdparams *cmd = priv->extcmds ? priv->extcmds : icom_ext_cmd; @@ -3359,7 +3358,7 @@ int icom_set_ext_cmd(RIG *rig, vfo_t vfo, token_t token, value_t val) cmd = icom_ext_cmd; i = 0; } - else if (cmd[i].id.t == token) + else if (cmd->cmdparamtype == CMD_PARAM_TYPE_TOKEN && cmd[i].id.t == token) { return icom_set_cmd(rig, vfo, (struct cmdparams *)&cmd[i], val); } @@ -5143,6 +5142,20 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + const struct icom_priv_caps *priv_caps = rig->caps->priv; + const struct cmdparams *extcmds = priv_caps->extcmds; + int i; + + value_t value = { .i = status }; + + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) + { + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_FUNC && extcmds[i].id.s == func) + { + return icom_set_cmd(rig, vfo, (struct cmdparams *)&extcmds[i], value); + } + } + fctbuf[0] = status ? 0x01 : 0x00; fct_len = 1; @@ -5391,8 +5404,27 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) int ack_len = sizeof(ackbuf), retval; int fct_cn, fct_sc; /* Command Number, Subcommand */ + const struct icom_priv_caps *priv_caps = rig->caps->priv; + const struct cmdparams *extcmds = priv_caps->extcmds; + int i; + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + value_t value; + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) + { + rig_debug(RIG_DEBUG_TRACE, "%s: i=%d\n", __func__, i); + + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_FUNC && extcmds[i].id.s == func) + { + int result = icom_get_cmd(rig, vfo, (struct cmdparams *)&extcmds[i], &value); + if (result == RIG_OK) { + *status = value.i; + } + return result; + } + } + switch (func) { case RIG_FUNC_NB: @@ -5566,13 +5598,13 @@ int icom_set_parm(RIG *rig, setting_t parm, value_t val) int i; const struct icom_priv_caps *priv = rig->caps->priv; - const struct cmdparams *cmd = priv->extcmds; + const struct cmdparams *extcmds = priv->extcmds; - for (i = 0; cmd && cmd[i].id.s != 0; i++) + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) { - if (cmd[i].cmdparamtype == CMD_PARAM_TYPE_PARM && cmd[i].id.s == parm) + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_PARM && extcmds[i].id.s == parm) { - return icom_set_cmd(rig, RIG_VFO_NONE, (struct cmdparams *)&cmd[i], val); + return icom_set_cmd(rig, RIG_VFO_NONE, (struct cmdparams *)&extcmds[i], val); } } diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 9c23d6512..e38c104b9 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -290,7 +290,7 @@ int icom_get_parm(RIG *rig, setting_t parm, value_t *val); int icom_set_ext_parm(RIG *rig, token_t token, value_t val); int icom_get_ext_parm(RIG *rig, token_t token, value_t *val); int icom_set_ext_cmd(RIG *rig, vfo_t vfo, token_t token, value_t val); -int icom_get_ext_cmd(RIG *rig, vfo_t vfo, cmd_param_t cmdparamtype, token_t token, value_t *val); +int icom_get_ext_cmd(RIG *rig, vfo_t vfo, token_t token, value_t *val); int icom_set_conf(RIG *rig, token_t token, const char *val); int icom_get_conf(RIG *rig, token_t token, char *val); int icom_set_powerstat(RIG *rig, powerstat_t status); diff --git a/src/ext.c b/src/ext.c index f609888c5..3c7adaefc 100644 --- a/src/ext.c +++ b/src/ext.c @@ -48,6 +48,77 @@ #include "token.h" +static int rig_has_ext_token(RIG *rig, token_t token) +{ + int *ext_tokens = rig->caps->ext_tokens; + int i; + + if (ext_tokens == NULL) + { + // Assume that all listed extfuncs/extlevels/extparms are supported if + // the ext_tokens list is not defined to preserve backwards-compatibility + return 1; + } + + for (i = 0; ext_tokens[i] != TOK_BACKEND_NONE; i++) + { + if (ext_tokens[i] == token) { + return 1; + } + } + + return 0; +} + + +/** + * \param rig The rig handle + * \param cfunc callback function of each extfunc + * \param data cookie to be passed to \a cfunc callback + * \brief Executes cfunc on all the elements stored in the extfuncs table + * + * The callback \a cfunc is called until it returns a value which is not + * strictly positive. A zero value means a normal end of iteration, and a + * negative value an abnormal end, which will be the return value of + * rig_ext_func_foreach. + */ +int HAMLIB_API rig_ext_func_foreach(RIG *rig, + int (*cfunc)(RIG *, + const struct confparams *, + rig_ptr_t), + rig_ptr_t data) +{ + const struct confparams *cfp; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !rig->caps || !cfunc) + { + return -RIG_EINVAL; + } + + for (cfp = rig->caps->extfuncs; cfp && cfp->name; cfp++) + { + if (!rig_has_ext_token(rig, cfp->token)) { + continue; + } + + int ret = (*cfunc)(rig, cfp, data); + + if (ret == 0) + { + return RIG_OK; + } + + if (ret < 0) + { + return ret; + } + } + + return RIG_OK; +} + /** * \param rig The rig handle @@ -77,6 +148,10 @@ int HAMLIB_API rig_ext_level_foreach(RIG *rig, for (cfp = rig->caps->extlevels; cfp && cfp->name; cfp++) { + if (!rig_has_ext_token(rig, cfp->token)) { + continue; + } + int ret = (*cfunc)(rig, cfp, data); if (ret == 0) @@ -122,6 +197,10 @@ int HAMLIB_API rig_ext_parm_foreach(RIG *rig, for (cfp = rig->caps->extparms; cfp && cfp->name; cfp++) { + if (!rig_has_ext_token(rig, cfp->token)) { + continue; + } + int ret = (*cfunc)(rig, cfp, data); if (ret == 0) @@ -193,7 +272,7 @@ const struct confparams *HAMLIB_API rig_ext_lookup(RIG *rig, const char *name) * \param token * \brief lookup ext token, return pointer to confparams struct. * - * lookup extlevels table first, then fall back to extparms. + * lookup extlevels table first, then extfuncs, then fall back to extparms. * * Returns NULL if nothing found */ @@ -216,6 +295,14 @@ const struct confparams *HAMLIB_API rig_ext_lookup_tok(RIG *rig, token_t token) } } + for (cfp = rig->caps->extfuncs; cfp && cfp->token; cfp++) + { + if (cfp->token == token) + { + return cfp; + } + } + for (cfp = rig->caps->extparms; cfp && cfp->token; cfp++) { if (cfp->token == token) @@ -231,7 +318,7 @@ const struct confparams *HAMLIB_API rig_ext_lookup_tok(RIG *rig, token_t token) /** * \param rig * \param name - * \brief Simple lookup returning token id assicated with name + * \brief Simple lookup returning token id associated with name */ token_t HAMLIB_API rig_ext_token_lookup(RIG *rig, const char *name) { diff --git a/src/settings.c b/src/settings.c index c0861f918..77aa4c181 100644 --- a/src/settings.c +++ b/src/settings.c @@ -787,7 +787,7 @@ int HAMLIB_API rig_set_ext_func(RIG *rig, caps = rig->caps; - if (caps->set_ext_level == NULL) + if (caps->set_ext_func == NULL) { return -RIG_ENAVAIL; } diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index b0a5ca36b..8b08bd49c 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -334,6 +334,9 @@ int dumpcaps(RIG *rig, FILE *fout) sprintf_func(prntbuf, caps->has_set_func); fprintf(fout, "Set functions: %s\n", prntbuf); + fprintf(fout, "Extra functions:\n"); + rig_ext_func_foreach(rig, print_ext, fout); + sprintf_level_gran(prntbuf, caps->has_get_level, caps->level_gran); fprintf(fout, "Get level: %s\n", prntbuf);