]> sigrok.org Git - libsigrok.git/commitdiff
mic-985xx: Adjust to GVariant-based sr_config_* functions
authorBert Vermeulen <redacted>
Sun, 31 Mar 2013 19:25:51 +0000 (21:25 +0200)
committerBert Vermeulen <redacted>
Thu, 11 Apr 2013 16:32:07 +0000 (18:32 +0200)
hardware/mic-985xx/api.c

index 4b184e7cbdd6f3b0a43c98980f71d03f71c98c1e..f96d128f9c7c3e697d2bfc3bff0cb0d7ef7ab075 100644 (file)
 
 #include "protocol.h"
 
-static const int hwopts[] = {
+static const int32_t hwopts[] = {
        SR_CONF_CONN,
        SR_CONF_SERIALCOMM,
-       0,
 };
 
-static const int hwcaps[] = {
+static const int32_t hwcaps[] = {
        SR_CONF_THERMOMETER,
        SR_CONF_HYGROMETER,
        SR_CONF_LIMIT_SAMPLES,
        SR_CONF_LIMIT_MSEC,
        SR_CONF_CONTINUOUS,
-       0,
 };
 
 SR_PRIV struct sr_dev_driver mic_98581_driver_info;
@@ -155,10 +153,10 @@ static GSList *hw_scan(GSList *options, int idx)
                src = l->data;
                switch (src->key) {
                case SR_CONF_CONN:
-                       conn = src->value;
+                       conn = g_variant_get_string(src->data, NULL);
                        break;
                case SR_CONF_SERIALCOMM:
-                       serialcomm = src->value;
+                       serialcomm  = g_variant_get_string(src->data, NULL);
                        break;
                }
        }
@@ -216,7 +214,7 @@ static int hw_cleanup(int idx)
        return SR_OK;
 }
 
-static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
+static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
@@ -227,12 +225,12 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
 
        switch (id) {
        case SR_CONF_LIMIT_SAMPLES:
-               devc->limit_samples = *(const uint64_t *)value;
+               devc->limit_samples = g_variant_get_uint64(data);
                sr_dbg("Setting sample limit to %" PRIu64 ".",
                       devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
-               devc->limit_msec = *(const uint64_t *)value;
+               devc->limit_msec = g_variant_get_uint64(data);
                sr_dbg("Setting time limit to %" PRIu64 "ms.",
                       devc->limit_msec);
                break;
@@ -244,16 +242,18 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_list(int key, const void **data, const struct sr_dev_inst *sdi)
+static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
 {
        (void)sdi;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
-               *data = hwopts;
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+                               hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
                break;
        case SR_CONF_DEVICE_OPTIONS:
-               *data = hwcaps;
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+                               hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
                break;
        default:
                return SR_ERR_ARG;