kopia lustrzana https://github.com/Hamlib/Hamlib
Add amp_set_level and amp_set_ext_level
rodzic
71f5766d57
commit
30884ae47e
|
@ -245,6 +245,7 @@ struct amp_caps
|
||||||
int (*get_level)(AMP *amp, setting_t level, value_t *val); /*!< Pointer to backend implementation of ::amp_get_level(). */
|
int (*get_level)(AMP *amp, setting_t level, value_t *val); /*!< Pointer to backend implementation of ::amp_get_level(). */
|
||||||
int (*set_level)(AMP *amp, setting_t level, value_t val); /*!< Pointer to backend implementation of ::amp_get_level(). */
|
int (*set_level)(AMP *amp, setting_t level, value_t val); /*!< Pointer to backend implementation of ::amp_get_level(). */
|
||||||
int (*get_ext_level)(AMP *amp, token_t level, value_t *val); /*!< Pointer to backend implementation of ::amp_get_ext_level(). */
|
int (*get_ext_level)(AMP *amp, token_t level, value_t *val); /*!< Pointer to backend implementation of ::amp_get_ext_level(). */
|
||||||
|
int (*set_ext_level)(AMP *amp, token_t level, value_t val); /*!< Pointer to backend implementation of ::amp_set_ext_level(). */
|
||||||
int (*set_powerstat)(AMP *amp, powerstat_t status); /*!< Pointer to backend implementation of ::amp_set_powerstat(). */
|
int (*set_powerstat)(AMP *amp, powerstat_t status); /*!< Pointer to backend implementation of ::amp_set_powerstat(). */
|
||||||
int (*get_powerstat)(AMP *amp, powerstat_t *status); /*!< Pointer to backend implementation of ::amp_get_powerstat(). */
|
int (*get_powerstat)(AMP *amp, powerstat_t *status); /*!< Pointer to backend implementation of ::amp_get_powerstat(). */
|
||||||
|
|
||||||
|
@ -290,6 +291,7 @@ struct amp_state
|
||||||
rig_ptr_t obj; /*!< Internal use by hamlib++ for event handling. */
|
rig_ptr_t obj; /*!< Internal use by hamlib++ for event handling. */
|
||||||
|
|
||||||
setting_t has_get_level; /*!< List of get levels. */
|
setting_t has_get_level; /*!< List of get levels. */
|
||||||
|
setting_t has_set_level; /*!< List of set levels. */
|
||||||
|
|
||||||
gran_t level_gran[RIG_SETTING_MAX]; /*!< Level granularity. */
|
gran_t level_gran[RIG_SETTING_MAX]; /*!< Level granularity. */
|
||||||
gran_t parm_gran[RIG_SETTING_MAX]; /*!< Parameter granularity. */
|
gran_t parm_gran[RIG_SETTING_MAX]; /*!< Parameter granularity. */
|
||||||
|
@ -368,6 +370,10 @@ amp_get_info HAMLIB_PARAMS((AMP *amp));
|
||||||
extern HAMLIB_EXPORT(int)
|
extern HAMLIB_EXPORT(int)
|
||||||
amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
|
amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
|
||||||
|
|
||||||
|
extern HAMLIB_EXPORT(int)
|
||||||
|
amp_set_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t val));
|
||||||
|
|
||||||
|
|
||||||
extern HAMLIB_EXPORT(int)
|
extern HAMLIB_EXPORT(int)
|
||||||
amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
|
amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
|
||||||
|
|
||||||
|
@ -412,6 +418,10 @@ extern HAMLIB_EXPORT(setting_t)
|
||||||
amp_has_get_level HAMLIB_PARAMS((AMP *amp,
|
amp_has_get_level HAMLIB_PARAMS((AMP *amp,
|
||||||
setting_t level));
|
setting_t level));
|
||||||
|
|
||||||
|
extern HAMLIB_EXPORT(setting_t)
|
||||||
|
amp_has_set_level HAMLIB_PARAMS((AMP *amp,
|
||||||
|
setting_t level));
|
||||||
|
|
||||||
extern HAMLIB_EXPORT(const struct confparams *)
|
extern HAMLIB_EXPORT(const struct confparams *)
|
||||||
amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
|
amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
|
||||||
const char *name));
|
const char *name));
|
||||||
|
@ -421,6 +431,11 @@ amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
|
||||||
token_t token,
|
token_t token,
|
||||||
value_t *val));
|
value_t *val));
|
||||||
|
|
||||||
|
extern HAMLIB_EXPORT(int)
|
||||||
|
amp_set_ext_level HAMLIB_PARAMS((AMP *amp,
|
||||||
|
token_t token,
|
||||||
|
value_t val));
|
||||||
|
|
||||||
extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
|
extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
|
||||||
|
|
||||||
extern HAMLIB_EXPORT(const struct confparams *)
|
extern HAMLIB_EXPORT(const struct confparams *)
|
||||||
|
|
|
@ -343,7 +343,7 @@ const struct rig_caps fdm_duo_caps =
|
||||||
.ptt_type = RIG_PTT_RIG_MICDATA,
|
.ptt_type = RIG_PTT_RIG_MICDATA,
|
||||||
.dcd_type = RIG_DCD_RIG,
|
.dcd_type = RIG_DCD_RIG,
|
||||||
.port_type = RIG_PORT_SERIAL,
|
.port_type = RIG_PORT_SERIAL,
|
||||||
.serial_rate_min = 4800,
|
.serial_rate_min = 9600,
|
||||||
.serial_rate_max = 115200,
|
.serial_rate_max = 115200,
|
||||||
.serial_data_bits = 8,
|
.serial_data_bits = 8,
|
||||||
.serial_stop_bits = 1,
|
.serial_stop_bits = 1,
|
||||||
|
|
|
@ -47,6 +47,39 @@
|
||||||
#include <hamlib/amplifier.h>
|
#include <hamlib/amplifier.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Check which level settings can be set.
|
||||||
|
*
|
||||||
|
* \param amp The #AMP handle.
|
||||||
|
* \param level The level settings bitmap.
|
||||||
|
*
|
||||||
|
* Checks if an amplifier is capable of *setting* a level setting. Since the
|
||||||
|
* \a level is an OR'ed bitwise argument, more than one level can be checked
|
||||||
|
* at the same time.
|
||||||
|
*
|
||||||
|
* EXAMPLE:
|
||||||
|
* \code
|
||||||
|
* if (amp_has_set_level(my_amp, AMP_LVL_PWR))
|
||||||
|
* my_disp_PWR();
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* \return A bit map of supported level settings that can be retrieved,
|
||||||
|
* otherwise 0 if none supported or \a amp is NULL or inconsistent.
|
||||||
|
*
|
||||||
|
* \sa amp_has_set_level(), amp_set_level()
|
||||||
|
*/
|
||||||
|
setting_t HAMLIB_API amp_has_set_level(AMP *amp, setting_t level)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
if (!amp || !amp->caps)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (amp->state.has_set_level & level);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Check which level settings can be queried.
|
* \brief Check which level settings can be queried.
|
||||||
*
|
*
|
||||||
|
|
|
@ -706,6 +706,43 @@ const char *HAMLIB_API amp_get_info(AMP *amp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the value of a requested level.
|
||||||
|
*
|
||||||
|
* \param amp The #AMP handle.
|
||||||
|
* \param level The requested level.
|
||||||
|
* \param val The variable to store the \a level value.
|
||||||
|
*
|
||||||
|
* Set the \a val corresponding to the \a level.
|
||||||
|
*
|
||||||
|
* \note \a val can be any type defined by #value_t.
|
||||||
|
*
|
||||||
|
* \return RIG_OK if the operation was successful, otherwise a **negative
|
||||||
|
* value** if an error occurred (in which case, cause is set appropriately).
|
||||||
|
*
|
||||||
|
* \retval RIG_OK The query was successful.
|
||||||
|
* \retval RIG_EINVAL \a amp is NULL or inconsistent.
|
||||||
|
* \retval RIG_ENAVAIL amp_caps#get_level() capability is not available.
|
||||||
|
*
|
||||||
|
* \sa amp_set_ext_level()
|
||||||
|
*/
|
||||||
|
int HAMLIB_API amp_set_level(AMP *amp, setting_t level, value_t val)
|
||||||
|
{
|
||||||
|
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
if (CHECK_AMP_ARG(amp))
|
||||||
|
{
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amp->caps->set_level == NULL)
|
||||||
|
{
|
||||||
|
return -RIG_ENAVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return amp->caps->set_level(amp, level, val);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Query the value of a requested level.
|
* \brief Query the value of a requested level.
|
||||||
*
|
*
|
||||||
|
@ -744,6 +781,41 @@ int HAMLIB_API amp_get_level(AMP *amp, setting_t level, value_t *val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the value of a requested extension levels token.
|
||||||
|
*
|
||||||
|
* \param amp The #AMP handle.
|
||||||
|
* \param level The requested extension levels token.
|
||||||
|
* \param val The variable to set the extension \a level token value.
|
||||||
|
*
|
||||||
|
* Query the \a val corresponding to the extension \a level token.
|
||||||
|
*
|
||||||
|
* \return RIG_OK if the operation was successful, otherwise a **negative
|
||||||
|
* value** if an error occurred (in which case, cause is set appropriately).
|
||||||
|
*
|
||||||
|
* \retval RIG_OK The query was successful.
|
||||||
|
* \retval RIG_EINVAL \a amp is NULL or inconsistent.
|
||||||
|
* \retval RIG_ENAVAIL amp_caps#set_ext_level() capability is not available.
|
||||||
|
*
|
||||||
|
* \sa amp_set_level()
|
||||||
|
*/
|
||||||
|
int HAMLIB_API amp_set_ext_level(AMP *amp, token_t level, value_t val)
|
||||||
|
{
|
||||||
|
amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
if (CHECK_AMP_ARG(amp))
|
||||||
|
{
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amp->caps->set_ext_level == NULL)
|
||||||
|
{
|
||||||
|
return -RIG_ENAVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return amp->caps->set_ext_level(amp, level, val);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Query the value of a requested extension levels token.
|
* \brief Query the value of a requested extension levels token.
|
||||||
*
|
*
|
||||||
|
|
|
@ -155,6 +155,7 @@ declare_proto_amp(dump_state);
|
||||||
declare_proto_amp(dump_caps);
|
declare_proto_amp(dump_caps);
|
||||||
declare_proto_amp(get_info);
|
declare_proto_amp(get_info);
|
||||||
declare_proto_amp(reset);
|
declare_proto_amp(reset);
|
||||||
|
declare_proto_amp(set_level);
|
||||||
declare_proto_amp(get_level);
|
declare_proto_amp(get_level);
|
||||||
declare_proto_amp(set_powerstat);
|
declare_proto_amp(set_powerstat);
|
||||||
declare_proto_amp(get_powerstat);
|
declare_proto_amp(get_powerstat);
|
||||||
|
@ -170,6 +171,7 @@ struct test_table test_list[] =
|
||||||
{ 'F', "set_freq", ACTION(set_freq), ARG_IN, "Frequency(Hz)" },
|
{ 'F', "set_freq", ACTION(set_freq), ARG_IN, "Frequency(Hz)" },
|
||||||
{ 'f', "get_freq", ACTION(get_freq), ARG_OUT, "Frequency(Hz)" },
|
{ 'f', "get_freq", ACTION(get_freq), ARG_OUT, "Frequency(Hz)" },
|
||||||
{ 'l', "get_level", ACTION(get_level), ARG_IN1 | ARG_OUT2, "Level", "Level Value" },
|
{ 'l', "get_level", ACTION(get_level), ARG_IN1 | ARG_OUT2, "Level", "Level Value" },
|
||||||
|
{ 'L', "set_level", ACTION(set_level), ARG_IN, "Level", "Level Value" },
|
||||||
{ 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2, "Cmd", "Reply" },
|
{ 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2, "Cmd", "Reply" },
|
||||||
{ 0x8f, "dump_state", ACTION(dump_state), ARG_OUT },
|
{ 0x8f, "dump_state", ACTION(dump_state), ARG_OUT },
|
||||||
{ '1', "dump_caps", ACTION(dump_caps), },
|
{ '1', "dump_caps", ACTION(dump_caps), },
|
||||||
|
@ -1662,6 +1664,94 @@ declare_proto_amp(set_freq)
|
||||||
return amp_set_freq(amp, freq);
|
return amp_set_freq(amp, freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RIG_CONF_ extparm's type:
|
||||||
|
* NUMERIC: val.f
|
||||||
|
* COMBO: val.i, starting from 0
|
||||||
|
* STRING: val.s
|
||||||
|
* CHECKBUTTON: val.i 0/1
|
||||||
|
*
|
||||||
|
* 'L'
|
||||||
|
*/
|
||||||
|
declare_proto_amp(set_level)
|
||||||
|
{
|
||||||
|
setting_t level;
|
||||||
|
value_t val;
|
||||||
|
|
||||||
|
if (!strcmp(arg1, "?"))
|
||||||
|
{
|
||||||
|
char s[SPRINTF_MAX_SIZE];
|
||||||
|
rig_sprintf_level(s, sizeof(s), amp->state.has_set_level);
|
||||||
|
fputs(s, fout);
|
||||||
|
|
||||||
|
if (amp->caps->set_ext_level)
|
||||||
|
{
|
||||||
|
sprintf_level_ext(s, sizeof(s), amp->caps->extlevels);
|
||||||
|
fputs(s, fout);
|
||||||
|
}
|
||||||
|
|
||||||
|
fputc('\n', fout);
|
||||||
|
return(RIG_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
level = rig_parse_level(arg1);
|
||||||
|
|
||||||
|
// some Java apps send comma in international setups so substitute period
|
||||||
|
char *p = strchr(arg2, ',');
|
||||||
|
|
||||||
|
if (p) { *p = '.'; }
|
||||||
|
|
||||||
|
if (!amp_has_set_level(amp, level))
|
||||||
|
{
|
||||||
|
const struct confparams *cfp;
|
||||||
|
|
||||||
|
cfp = amp_ext_lookup(amp, arg1);
|
||||||
|
|
||||||
|
if (!cfp)
|
||||||
|
{
|
||||||
|
return(-RIG_ENAVAIL); /* no such parameter */
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (cfp->type)
|
||||||
|
{
|
||||||
|
case RIG_CONF_BUTTON:
|
||||||
|
/* arg is ignored */
|
||||||
|
val.i = 0; // avoid passing uninitialized data
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_CONF_CHECKBUTTON:
|
||||||
|
case RIG_CONF_COMBO:
|
||||||
|
CHKSCN1ARG(sscanf(arg2, "%d", &val.i));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_CONF_NUMERIC:
|
||||||
|
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIG_CONF_STRING:
|
||||||
|
val.cs = arg2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return(-RIG_ECONF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(amp_set_ext_level(amp, cfp->token, val));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RIG_LEVEL_IS_FLOAT(level))
|
||||||
|
{
|
||||||
|
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CHKSCN1ARG(sscanf(arg2, "%d", &val.i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return(amp_set_level(amp, level, val));
|
||||||
|
}
|
||||||
|
|
||||||
/* 'l' */
|
/* 'l' */
|
||||||
declare_proto_amp(get_level)
|
declare_proto_amp(get_level)
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue