arachnid-labs-re-load-pro: Make SR_CONF_REGULATION listable

This commit is contained in:
Frank Stettner 2017-12-07 10:41:32 +01:00 committed by Uwe Hermann
parent 3d70d77709
commit 706350360a
3 changed files with 27 additions and 1 deletions

View File

@ -44,7 +44,7 @@ static const uint32_t devopts[] = {
static const uint32_t devopts_cg[] = { static const uint32_t devopts_cg[] = {
SR_CONF_ENABLED | SR_CONF_SET, SR_CONF_ENABLED | SR_CONF_SET,
SR_CONF_REGULATION | SR_CONF_GET, SR_CONF_REGULATION | SR_CONF_GET | SR_CONF_LIST,
SR_CONF_VOLTAGE | SR_CONF_GET, SR_CONF_VOLTAGE | SR_CONF_GET,
SR_CONF_CURRENT | SR_CONF_GET, SR_CONF_CURRENT | SR_CONF_GET,
SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
@ -57,6 +57,11 @@ static const uint32_t devopts_cg[] = {
SR_CONF_UNDER_VOLTAGE_CONDITION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_UNDER_VOLTAGE_CONDITION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
}; };
static const char *regulation[] = {
/* CC mode only. */
"CC",
};
static GSList *scan(struct sr_dev_driver *di, GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
@ -172,6 +177,9 @@ static int config_list(uint32_t key, GVariant **data,
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
break; break;
case SR_CONF_REGULATION:
*data = std_gvar_array_str(ARRAY_AND_SIZE(regulation));
break;
case SR_CONF_CURRENT_LIMIT: case SR_CONF_CURRENT_LIMIT:
*data = std_gvar_min_max_step(0.0, 6.0, 0.001); *data = std_gvar_min_max_step(0.0, 6.0, 0.001);
break; break;

View File

@ -972,6 +972,7 @@ SR_PRIV GVariant *std_gvar_tuple_double(double low, double high);
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n); SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n);
SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n); SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n);
SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n); SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n);
SR_PRIV GVariant *std_gvar_array_str(const char *a[], unsigned int n);
SR_PRIV GVariant *std_gvar_thresholds(const double a[][2], unsigned int n); SR_PRIV GVariant *std_gvar_thresholds(const double a[][2], unsigned int n);

View File

@ -767,6 +767,23 @@ SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n)
a, n, sizeof(uint64_t)); a, n, sizeof(uint64_t));
} }
SR_PRIV GVariant *std_gvar_array_str(const char *a[], unsigned int n)
{
GVariant *gvar;
GVariantBuilder *builder;
unsigned int i;
builder = g_variant_builder_new(G_VARIANT_TYPE ("as"));
for (i = 0; i < n; i++)
g_variant_builder_add(builder, "s", a[i]);
gvar = g_variant_new("as", builder);
g_variant_builder_unref(builder);
return gvar;
}
SR_PRIV GVariant *std_gvar_thresholds(const double a[][2], unsigned int n) SR_PRIV GVariant *std_gvar_thresholds(const double a[][2], unsigned int n)
{ {
unsigned int i; unsigned int i;