]> sigrok.org Git - libsigrok.git/commitdiff
arachnid-labs-re-load-pro: Make SR_CONF_REGULATION listable
authorFrank Stettner <redacted>
Thu, 7 Dec 2017 09:41:32 +0000 (10:41 +0100)
committerUwe Hermann <redacted>
Sat, 3 Mar 2018 18:22:59 +0000 (19:22 +0100)
src/hardware/arachnid-labs-re-load-pro/api.c
src/libsigrok-internal.h
src/std.c

index 1b7b8698681aff4d865d9de6e34b266bdbee7949..a0e99dee6d11394c41ec9b0110f9bc8e91423b30 100644 (file)
@@ -44,7 +44,7 @@ static const uint32_t devopts[] = {
 
 static const uint32_t devopts_cg[] = {
        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_CURRENT | SR_CONF_GET,
        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,
 };
 
+static const char *regulation[] = {
+       /* CC mode only. */
+       "CC",
+};
+
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
@@ -172,6 +177,9 @@ static int config_list(uint32_t key, GVariant **data,
                case SR_CONF_DEVICE_OPTIONS:
                        *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg));
                        break;
+               case SR_CONF_REGULATION:
+                       *data = std_gvar_array_str(ARRAY_AND_SIZE(regulation));
+                       break;
                case SR_CONF_CURRENT_LIMIT:
                        *data = std_gvar_min_max_step(0.0, 6.0, 0.001);
                        break;
index fa4237f19c0bb28d0a896ad6dd134489be6a183e..0a8032b3d5999828f5081f2d2e5fa39660f3300f 100644 (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_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_str(const char *a[], unsigned int n);
 
 SR_PRIV GVariant *std_gvar_thresholds(const double a[][2], unsigned int n);
 
index b778679b38b30e6c7ac040721fa41cef841d65d6..6403d01a5d5603fb0222788b27a9f18e05138389 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -767,6 +767,23 @@ SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n)
                                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)
 {
        unsigned int i;