Fix issues with Icom extcmds definitions, some ext_tokens missing. Refactor custom level implementations to use extcmds definitions. Print out extfuncs in caps dump.

pull/381/head
Mikael Nousiainen 2020-09-16 18:10:35 +03:00
rodzic b97d05369c
commit 23971f8e75
11 zmienionych plików z 253 dodań i 290 usunięć

Wyświetl plik

@ -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 *,

Wyświetl plik

@ -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,
@ -966,35 +970,6 @@ 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;
@ -1058,4 +1033,3 @@ int ic7300_get_parm(RIG *rig, setting_t parm, value_t *val)
return RIG_OK;
}

Wyświetl plik

@ -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);
}
}

Wyświetl plik

@ -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 */

Wyświetl plik

@ -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);
}
}

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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, {} },
@ -2219,7 +2218,7 @@ int icom_set_cmd(RIG *rig, vfo_t vfo, struct cmdparams *par, value_t val)
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:

Wyświetl plik

@ -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);

Wyświetl plik

@ -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)
{

Wyświetl plik

@ -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);