10000 Icom extcmds fixes by mikaelnousiainen · Pull Request #381 · Hamlib/Hamlib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Icom extcmds fixes #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions dummy/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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[] =
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down
11 changes: 6 additions & 5 deletions dummy/dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions include/hamlib/rig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *,
Expand Down
48 changes: 8 additions & 40 deletions rigs/icom/ic7000.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 =
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
Loading
0