From c8489486d73c99d9c942a991a63ad67b68989124 Mon Sep 17 00:00:00 2001 From: Malcolm Herring Date: Thu, 23 Jan 2020 17:51:45 +0000 Subject: [PATCH 1/2] correct rig_close cap --- rigs/icom/id51.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rigs/icom/id51.c b/rigs/icom/id51.c index 79346807b..3f2300498 100644 --- a/rigs/icom/id51.c +++ b/rigs/icom/id51.c @@ -183,7 +183,7 @@ const struct rig_caps id51_caps = .rig_init = icom_init, .rig_cleanup = icom_cleanup, .rig_open = icom_rig_open, - .rig_close = icom_rig_open, + .rig_close = icom_rig_close, .set_powerstat = icom_set_powerstat, .get_powerstat = icom_get_powerstat, From e3cef196f7e0bb1b6144032eb2177e9d7ebe47d1 Mon Sep 17 00:00:00 2001 From: Malcolm Herring Date: Tue, 11 Feb 2020 09:48:13 +0000 Subject: [PATCH 2/2] add g/set_ext_func to API --- include/hamlib/rig.h | 15 +++++ rigs/icom/ic7100.c | 31 ++++------ rigs/icom/ic7300.c | 22 ++------ rigs/icom/ic756.c | 14 ++--- rigs/icom/ic7600.c | 11 +--- rigs/icom/icom.c | 38 +++++++++++-- rigs/icom/icom.h | 7 ++- rigs/icom/icr30.c | 4 +- rigs/icom/icr8600.c | 18 ++---- src/ext.c | 16 ++++-- src/settings.c | 131 +++++++++++++++++++++++++++++++++++++++++++ tests/rigctl_parse.c | 42 ++++++++++++-- 12 files changed, 265 insertions(+), 84 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 71d816335..2497f7b75 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1424,6 +1424,7 @@ struct rig_caps { const struct confparams *extparms; /*!< Extension parm list, \sa ext.c */ const struct confparams *extlevels; /*!< Extension level list, \sa ext.c */ + const struct confparams *extfuncs; /*!< Extension func list, \sa ext.c */ int *ext_tokens; /*!< Extension token list */ const tone_t *ctcss_list; /*!< CTCSS tones list, zero ended */ @@ -1585,6 +1586,9 @@ struct rig_caps { int (*set_ext_level)(RIG *rig, vfo_t vfo, token_t token, value_t val); int (*get_ext_level)(RIG *rig, vfo_t vfo, token_t token, value_t *val); + int (*set_ext_func)(RIG *rig, vfo_t vfo, token_t token, int status); + int (*get_ext_func)(RIG *rig, vfo_t vfo, token_t token, int *status); + int (*set_ext_parm)(RIG *rig, token_t token, value_t val); int (*get_ext_parm)(RIG *rig, token_t token, value_t *val); @@ -2099,6 +2103,17 @@ rig_get_ext_level HAMLIB_PARAMS((RIG *rig, token_t token, value_t *val)); +extern HAMLIB_EXPORT(int) +rig_set_ext_func HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + token_t token, + int status)); +extern HAMLIB_EXPORT(int) +rig_get_ext_func HAMLIB_PARAMS((RIG *rig, + vfo_t vfo, + token_t token, + int *status)); + extern HAMLIB_EXPORT(int) rig_set_ext_parm HAMLIB_PARAMS((RIG *rig, token_t token, diff --git a/rigs/icom/ic7100.c b/rigs/icom/ic7100.c index daca1570d..33d83cce9 100644 --- a/rigs/icom/ic7100.c +++ b/rigs/icom/ic7100.c @@ -101,29 +101,17 @@ #define IC7100_PARM_ALL (RIG_PARM_ANN|RIG_PARM_BACKLIGHT|RIG_PARM_KEYLIGHT|RIG_PARM_BEEP|RIG_PARM_TIME) -struct cmdparams ic7100_rigparms[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x03}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x04}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x05}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x21}, CMD_DAT_TIM, 2 }, - { {.s=RIG_PARM_NONE} } -}; - -struct cmdparams ic7100_riglevels[] = { - { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x65}, CMD_DAT_INT, 1 }, - { {.s=RIG_LEVEL_NONE} } -}; - int ic7100_tokens[] = { TOK_DSTAR_CODE, TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, TOK_DSTAR_STATUS, TOK_DSTAR_MY_CS, TOK_DSTAR_TX_CS, TOK_DSTAR_TX_MESS, TOK_BACKEND_NONE }; -struct confparams ic7100_ext[] = { - { 0 } -}; - struct cmdparams ic7100_extcmds[] = { - { {0} } + { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x03}, CMD_DAT_BOL, 1 }, + { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x04}, CMD_DAT_LVL, 2 }, + { {.s=RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x05}, CMD_DAT_LVL, 2 }, + { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x21}, CMD_DAT_TIM, 2 }, + { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x65}, CMD_DAT_INT, 1 }, + { {.s=RIG_PARM_NONE} } }; // IC-7100 S-meter calibration data based on manual @@ -196,8 +184,6 @@ static const struct icom_priv_caps ic7100_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .rigparms = ic7100_rigparms, - .riglevels = ic7100_riglevels, .extcmds = ic7100_extcmds, .antack_len = 2, .ant_count = 2 @@ -238,7 +224,8 @@ const struct rig_caps ic7100_caps = [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 900 }, .step = { .i = 1 } }, }, .ext_tokens = ic7100_tokens, - .extlevels = ic7100_ext, + .extlevels = icom_ext_levels, + .extfuncs = icom_ext_funcs, .extparms = icom_ext_parms, .parm_gran = {}, .ctcss_list = common_ctcss_list, @@ -388,6 +375,8 @@ const struct rig_caps ic7100_caps = .get_parm = icom_get_parm, .set_ext_parm = icom_set_ext_parm, .get_ext_parm = icom_get_ext_parm, + .set_ext_func = icom_set_ext_func, + .get_ext_func = icom_get_ext_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, .scan = icom_scan, diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index e64f1d80a..40834565d 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -57,16 +57,12 @@ #define IC7300_ANTS (RIG_ANT_1) /* ant-1 is Hf-6m */ -struct cmdparams ic7300_rigparms[] = { +struct cmdparams ic7300_extcmds[] = { { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x23}, CMD_DAT_BOL, 1 }, { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x81}, CMD_DAT_LVL, 2 }, { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x95}, CMD_DAT_TIM, 2 }, - { {.s=RIG_PARM_NONE} } -}; - -struct cmdparams ic7300_riglevels[] = { { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x91}, CMD_DAT_INT, 1 }, - { {.s=RIG_LEVEL_NONE} } + { {.s=RIG_PARM_NONE} } }; /* @@ -138,15 +134,11 @@ struct cmdparams ic7300_riglevels[] = { #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_rigparms[] = { +struct cmdparams ic9700_extcmds[] = { { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x29}, CMD_DAT_BOL, 1 }, { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x52}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_NONE} } -}; - -struct cmdparams ic9700_riglevels[] = { { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x30}, CMD_DAT_INT, 1 }, - { {.s=RIG_LEVEL_NONE} } + { {.s=RIG_PARM_NONE} } }; #define IC9700_STR_CAL { 7, \ @@ -219,8 +211,7 @@ static const struct icom_priv_caps IC7300_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .rigparms = ic7300_rigparms, /* Custom parm parameters */ - .riglevels = ic7300_riglevels, /* Custom level parameters */ + .extcmds = ic7300_extcmds, /* Custom op parameters */ }; static const struct icom_priv_caps IC9700_priv_caps = @@ -237,8 +228,7 @@ static const struct icom_priv_caps IC9700_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .rigparms = ic9700_rigparms, /* Custom parm parameters */ - .riglevels = ic9700_riglevels, /* Custom level parameters */ + .extcmds = ic9700_extcmds, /* Custom op parameters */ }; const struct rig_caps ic7300_caps = diff --git a/rigs/icom/ic756.c b/rigs/icom/ic756.c index d2944cb67..dc16b26ea 100644 --- a/rigs/icom/ic756.c +++ b/rigs/icom/ic756.c @@ -62,16 +62,12 @@ #define IC756_ANTS (RIG_ANT_1|RIG_ANT_2) -struct cmdparams ic756pro_rigparms[] = { +struct cmdparams ic756pro_cmdparms[] = { { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x20}, CMD_DAT_BOL, 1 }, { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x09}, CMD_DAT_LVL, 2 }, { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x16}, CMD_DAT_TIM, 2 }, - { {.s=RIG_PARM_NONE} } -}; - -struct cmdparams ic756pro_riglevels[] = { { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x60}, CMD_DAT_INT, 1 }, - { {.s=RIG_LEVEL_NONE} } + { {.s=RIG_PARM_NONE} } }; #define IC756PRO_STR_CAL { 16, \ @@ -468,8 +464,7 @@ static const struct icom_priv_caps ic756pro2_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .rigparms = ic756pro_rigparms, /* Custom parm parameters */ - .riglevels = ic756pro_riglevels, /* Custom level parameters */ + .extcmds = ic756pro_cmdparms, /* Custom op parameters */ }; /* @@ -896,8 +891,7 @@ static const struct icom_priv_caps ic756pro3_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .rigparms = ic756pro_rigparms, /* Custom parm parameters */ - .riglevels = ic756pro_riglevels, /* Custom level parameters */ + .extcmds = ic756pro_cmdparms, /* Custom op parameters */ }; diff --git a/rigs/icom/ic7600.c b/rigs/icom/ic7600.c index 69da7cd15..62420438d 100644 --- a/rigs/icom/ic7600.c +++ b/rigs/icom/ic7600.c @@ -53,16 +53,12 @@ #define IC7600_ANTS (RIG_ANT_1|RIG_ANT_2) -struct cmdparams ic7600_rigparms[] = { +struct cmdparams ic7600_extcmds[] = { { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x59}, CMD_DAT_BOL, 1 }, { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_LVL, 2 }, { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x54}, CMD_DAT_TIM, 2 }, - { {.s=RIG_PARM_NONE} } -}; - -struct cmdparams ic7600_riglevels[] = { { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, - { {.s=RIG_LEVEL_NONE} } + { {.s=RIG_PARM_NONE} } }; /* @@ -152,8 +148,7 @@ static const struct icom_priv_caps ic7600_priv_caps = { .level = RIG_AGC_SLOW, .icom_level = 3 }, { .level = -1, .icom_level = 0 }, }, - .rigparms = ic7600_rigparms, /* Custom parm parameters */ - .riglevels = ic7600_riglevels, /* Custom level parameters */ + .extcmds = ic7600_extcmds, /* Custom op parameters */ }; const struct confparams ic7600_ext_levels[] = diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 038d09671..954566a5d 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -401,6 +401,22 @@ const struct confparams icom_cfg_params[] = {RIG_CONF_END, NULL,} }; +/* + * Lookup table for icom_get_ext_func + */ +const struct confparams icom_ext_funcs[] = +{ + {} +}; + +/* + * Lookup table for icom_get_ext_level + */ +const struct confparams icom_ext_levels[] = +{ + {} +}; + /* * Lookup table for icom_get_ext_parm */ @@ -444,12 +460,12 @@ const struct confparams icom_ext_parms[] = const struct cmdparams icom_ext_cmd[] = { + { {.t = TOK_DSTAR_DSQL}, C_CTL_DIG, S_DIG_DSCSQL, SC_MOD_RW, 1, {0}, CMD_DAT_BOL, 1 }, { {.t = TOK_DSTAR_CALL_SIGN}, C_CTL_DIG, S_DIG_DSCALS, SC_MOD_RW12, 2, {0}, CMD_DAT_BUF, 38 }, { {.t = TOK_DSTAR_MESSAGE}, C_CTL_DIG, S_DIG_DSMESS, SC_MOD_RW12, 2, {0}, CMD_DAT_STR, 32 }, { {.t = TOK_DSTAR_STATUS}, C_CTL_DIG, S_DIG_DSRSTS, SC_MOD_RW12, 2, {0}, CMD_DAT_BUF, 1 }, { {.t = TOK_DSTAR_GPS_DATA}, C_CTL_DIG, S_DIG_DSGPSD, SC_MOD_RW12, 2, {0}, CMD_DAT_BUF, 52 }, { {.t = TOK_DSTAR_GPS_MESS}, C_CTL_DIG, S_DIG_DSGPSM, SC_MOD_RW12, 2, {0}, CMD_DAT_STR, 52 }, - { {.t = TOK_DSTAR_DSQL}, C_CTL_DIG, S_DIG_DSCSQL, SC_MOD_RW, 1, {0}, CMD_DAT_BOL, 1 }, { {.t = TOK_DSTAR_CODE}, C_CTL_DIG, S_DIG_DSCSQL, SC_MOD_RW12, 2, {0}, CMD_DAT_FLT, 1 }, { {.t = TOK_DSTAR_TX_DATA}, C_CTL_DSD, S_DSD_DSTXDT, SC_MOD_RW, 1, {0}, CMD_DAT_BUF, 30 }, { {.t = TOK_DSTAR_MY_CS}, C_CTL_DVT, S_DVT_DSMYCS, SC_MOD_RW, 1, {0}, CMD_DAT_STR, 12 }, @@ -1962,7 +1978,7 @@ 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->riglevels; + const struct cmdparams *cmd = priv_caps->extcmds; for (i = 0; cmd && cmd[i].id.s != 0; i++) { @@ -2319,7 +2335,7 @@ 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->riglevels; + const struct cmdparams *cmd = priv->extcmds; int i; for (i = 0; cmd && cmd[i].id.s != 0; i++) @@ -2778,6 +2794,18 @@ int icom_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) return icom_get_ext_cmd(rig, vfo, token, val); } +int icom_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + return icom_set_ext_cmd(rig, vfo, token, (value_t)status); +} + +int icom_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + return icom_get_ext_cmd(rig, vfo, token, (value_t*)status); +} + int icom_set_ext_parm(RIG *rig, token_t token, value_t val) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -4584,7 +4612,7 @@ 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->rigparms; + const struct cmdparams *cmd = priv->extcmds; for (i = 0; cmd && cmd[i].id.s != 0; i++) { @@ -4645,7 +4673,7 @@ int icom_get_parm(RIG *rig, setting_t parm, 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->rigparms; + const struct cmdparams *cmd = priv->extcmds; int i; for (i = 0; cmd && cmd[i].id.s != 0; i++) diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index c42d7b743..5d6a5ac13 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -144,8 +144,6 @@ struct icom_priv_caps int serial_USB_echo_check; /* Flag to test USB echo state */ int agc_levels_present; /* Flag to indicate that agc_levels array is populated */ struct icom_agc_level agc_levels[RIG_AGC_LAST + 1]; /* Icom rig-specific AGC levels, the last entry should have level -1 */ - struct cmdparams *rigparms; /* Pointer to rig custom parameters array */ - struct cmdparams *riglevels;/* Pointer to rig custom levels array */ struct cmdparams *extcmds; /* Pointer to extended operations array */ }; @@ -246,6 +244,8 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val); int icom_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val); int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); +int icom_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status); +int icom_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status); int icom_set_parm(RIG *rig, setting_t parm, value_t val); 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); @@ -287,8 +287,9 @@ int icom_get_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf, int *seconds); extern const struct confparams icom_cfg_params[]; +extern const struct confparams icom_ext_levels[]; +extern const struct confparams icom_ext_funcs[]; extern const struct confparams icom_ext_parms[]; -extern const struct cmdparams icom_rig_cmds[]; extern const struct cmdparams icom_ext_cmds[]; extern const struct rig_caps ic703_caps; diff --git a/rigs/icom/icr30.c b/rigs/icom/icr30.c index 4aef337c0..6296c778c 100644 --- a/rigs/icom/icr30.c +++ b/rigs/icom/icr30.c @@ -159,7 +159,7 @@ const struct rig_caps icr30_caps = }, .parm_gran = {}, .ext_tokens = icr30_tokens, - .extlevels = icr30_ext, + .extfuncs = icr30_ext, .extparms = icom_ext_parms, .ctcss_list = common_ctcss_list, .dcs_list = common_dcs_list, @@ -266,6 +266,8 @@ const struct rig_caps icr30_caps = .get_ext_parm = icom_get_ext_parm, .set_ext_level = icom_set_ext_level, .get_ext_level = icom_get_ext_level, + .set_ext_func = icom_set_ext_func, + .get_ext_func = icom_get_ext_func, .get_dcd = icom_get_dcd, .set_ctcss_sql = icom_set_ctcss_sql, .get_ctcss_sql = icom_get_ctcss_sql, diff --git a/rigs/icom/icr8600.c b/rigs/icom/icr8600.c index b097a934a..d9b134997 100644 --- a/rigs/icom/icr8600.c +++ b/rigs/icom/icr8600.c @@ -67,7 +67,7 @@ { 255, 60 }, \ } } -struct cmdparams icr8600_rigparms[] = { +struct cmdparams icr8600_extcmds[] = { { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_BOL, 1 }, { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x15}, CMD_DAT_LVL, 2 }, { {.s=RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x16}, CMD_DAT_LVL, 2 }, @@ -81,14 +81,6 @@ int icr8600_tokens[] = { TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, TOK_SCOPE_HLD, TOK_SCOPE_REF, TOK_SCOPE_SWP, TOK_SCOPE_TYP, TOK_SCOPE_VBW, TOK_SCOPE_FEF, TOK_BACKEND_NONE }; -struct confparams icr8600_ext[] = { - { 0 } -}; - -struct cmdparams icr8600_extcmds[] = { - { {0} } -}; - /* * channel caps. */ @@ -112,8 +104,7 @@ static struct icom_priv_caps icr8600_priv_caps = .ant_count = 3, .offs_len = 4, /* Repeater offset is 4 bytes */ .serial_USB_echo_check = 1, /* USB CI-V may not echo */ - .rigparms = icr8600_rigparms, /* Custom parm parameters */ - .extcmds = icr8600_extcmds /* Custom ext_parm parameters */ + .extcmds = icr8600_extcmds /* Custom ext_cmd parameters */ }; const struct rig_caps icr8600_caps = @@ -147,7 +138,8 @@ const struct rig_caps icr8600_caps = .level_gran = { [LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } } }, .parm_gran = { [PARM_TIME] = { .min = { .i = 0 }, .max = { .i = 86399} } }, .ext_tokens = icr8600_tokens, - .extlevels = icr8600_ext, + .extlevels = icom_ext_levels, + .extfuncs = icom_ext_funcs, .extparms = icom_ext_parms, .ctcss_list = common_ctcss_list, .dcs_list = common_dcs_list, @@ -253,6 +245,8 @@ const struct rig_caps icr8600_caps = .get_parm = icom_get_parm, .set_ext_parm = icom_set_ext_parm, .get_ext_parm = icom_get_ext_parm, + .set_ext_func = icom_set_ext_func, + .get_ext_func = icom_get_ext_func, .get_dcd = icom_get_dcd, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, diff --git a/src/ext.c b/src/ext.c index 1cdb6123c..f609888c5 100644 --- a/src/ext.c +++ b/src/ext.c @@ -28,9 +28,9 @@ * \file ext.c * \brief Extension request parameter interface * - * An open-ended set of extension parameters and levels are available for each - * rig, as provided in the rigcaps extparms and extlevels lists. These - * provide a way to work with rig-specific functions that don't fit into the + * An open-ended set of extension parameters, functions and levels are available + * for each rig, as provided in the rigcaps extparms, extfuncs and extlevels lists. + * These provide a way to work with rig-specific functions that don't fit into the * basic "virtual rig" of Hamlib. See icom/ic746.c for an example. */ @@ -144,7 +144,7 @@ int HAMLIB_API rig_ext_parm_foreach(RIG *rig, * \param name * \brief lookup ext token by its name, return pointer to confparams struct. * - * Lookup extlevels table first, then fall back to extparms. + * Lookup extlevels table, then extfuncs, then extparms. * * Returns NULL if nothing found * @@ -169,6 +169,14 @@ const struct confparams *HAMLIB_API rig_ext_lookup(RIG *rig, const char *name) } } + for (cfp = rig->caps->extfuncs; cfp && cfp->name; cfp++) + { + if (!strcmp(cfp->name, name)) + { + return cfp; + } + } + for (cfp = rig->caps->extparms; cfp && cfp->name; cfp++) { if (!strcmp(cfp->name, name)) diff --git a/src/settings.c b/src/settings.c index a61da5c8d..4d69e13df 100644 --- a/src/settings.c +++ b/src/settings.c @@ -749,6 +749,137 @@ int HAMLIB_API rig_get_ext_level(RIG *rig, return retcode; } +/** + * \brief set a radio function extra parameter + * \param rig The rig handle + * \param vfo The target VFO + * \param token The parameter + * \param status The value to set the parameter to + * + * Sets a function extra parameter. + * + * \return RIG_OK if the operation has been sucessful, otherwise + * a negative value if an error occured (in which case, cause is + * set appropriately). + * + * \sa rig_get_ext_func() + */ +int HAMLIB_API rig_set_ext_func(RIG *rig, + vfo_t vfo, + token_t token, + int status) +{ + const struct rig_caps *caps; + int retcode; + vfo_t curr_vfo; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (CHECK_RIG_ARG(rig)) + { + return -RIG_EINVAL; + } + + caps = rig->caps; + + if (caps->set_ext_level == NULL) + { + return -RIG_ENAVAIL; + } + + if ((caps->targetable_vfo & RIG_TARGETABLE_PURE) + || vfo == RIG_VFO_CURR + || vfo == rig->state.current_vfo) + { + + return caps->set_ext_func(rig, vfo, token, status); + } + + if (!caps->set_vfo) + { + return -RIG_ENTARGET; + } + + curr_vfo = rig->state.current_vfo; + retcode = caps->set_vfo(rig, vfo); + + if (retcode != RIG_OK) + { + return retcode; + } + + retcode = caps->set_ext_func(rig, vfo, token, status); + caps->set_vfo(rig, curr_vfo); + + return retcode; +} + + +/** + * \brief get the value of a function extra parameter + * \param rig The rig handle + * \param vfo The target VFO + * \param token The parameter + * \param status The location where to store the value of \a token + * + * Retrieves the value of a function extra parameter associated with \a token. + * + * \return RIG_OK if the operation has been sucessful, otherwise + * a negative value if an error occured (in which case, cause is + * set appropriately). + * + * \sa rig_set_ext_func() + */ +int HAMLIB_API rig_get_ext_func(RIG *rig, + vfo_t vfo, + token_t token, + int *status) +{ + const struct rig_caps *caps; + int retcode; + vfo_t curr_vfo; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (CHECK_RIG_ARG(rig) || !status) + { + return -RIG_EINVAL; + } + + caps = rig->caps; + + if (caps->get_ext_func == NULL) + { + return -RIG_ENAVAIL; + } + + if ((caps->targetable_vfo & RIG_TARGETABLE_PURE) + || vfo == RIG_VFO_CURR + || vfo == rig->state.current_vfo) + { + + return caps->get_ext_func(rig, vfo, token, status); + } + + if (!caps->set_vfo) + { + return -RIG_ENTARGET; + } + + curr_vfo = rig->state.current_vfo; + retcode = caps->set_vfo(rig, vfo); + + if (retcode != RIG_OK) + { + return retcode; + } + + retcode = caps->get_ext_func(rig, vfo, token, status); + caps->set_vfo(rig, curr_vfo); + + return retcode; +} + /** * \brief set a radio parm extra parameter diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 75f2b0a3e..1d43160f2 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -2850,9 +2850,20 @@ declare_proto_rig(set_func) func = rig_parse_func(arg1); - if (RIG_FUNC_NONE == func) + if (!rig_has_set_func(rig, func)) { - return -RIG_EINVAL; + const struct confparams *cfp; + + cfp = rig_ext_lookup(rig, arg1); + + if (!cfp) + { + return -RIG_ENAVAIL; /* no such parameter */ + } + + CHKSCN1ARG(sscanf(arg2, "%d", &func_stat)); + + return rig_set_ext_func(rig, vfo, cfp->token, func_stat); } CHKSCN1ARG(sscanf(arg2, "%d", &func_stat)); @@ -2877,9 +2888,32 @@ declare_proto_rig(get_func) func = rig_parse_func(arg1); - if (RIG_FUNC_NONE == func) + if (!rig_has_get_func(rig, func)) { - return -RIG_EINVAL; + const struct confparams *cfp; + + cfp = rig_ext_lookup(rig, arg1); + + if (!cfp) + { + return -RIG_EINVAL; /* no such parameter */ + } + + status = rig_get_ext_func(rig, vfo, cfp->token, &func_stat); + + if (status != RIG_OK) + { + return status; + } + + if (interactive && prompt) + { + fprintf(fout, "%s: ", cmd->arg2); + } + + fprintf(fout, "%d\n", func_stat); + + return status; } status = rig_get_func(rig, vfo, func, &func_stat);