Code

Use value types according to sigrok measured quantity
authorBert Vermeulen <bert@biot.com>
Wed, 31 Jul 2013 09:24:36 +0000 (11:24 +0200)
committerBert Vermeulen <bert@biot.com>
Wed, 31 Jul 2013 09:24:36 +0000 (11:24 +0200)
src/sigrok.c

index 28adfbd11b73a08ca9d2de733697b195aab32f05..7e2fa6c1b29ca2990dd5362d4164b69db67bc1df 100644 (file)
@@ -126,6 +126,28 @@ static int sigrok_config(oconfig_item_t *ci)
        return 0;
 }
 
+static char *sigrok_value_type(const struct sr_datafeed_analog *analog)
+{
+       char *s;
+
+       if (analog->mq == SR_MQ_VOLTAGE)
+               s = "voltage";
+       else if (analog->mq == SR_MQ_CURRENT)
+               s = "current";
+       else if (analog->mq == SR_MQ_FREQUENCY)
+               s = "frequency";
+       else if (analog->mq == SR_MQ_POWER)
+               s = "power";
+       else if (analog->mq == SR_MQ_TEMPERATURE)
+               s = "temperature";
+       else if (analog->mq == SR_MQ_RELATIVE_HUMIDITY)
+               s = "humidity";
+       else
+               s = "gauge";
+
+       return s;
+}
+
 static void sigrok_feed_callback(const struct sr_dev_inst *sdi,
                const struct sr_datafeed_packet *packet, void *cb_data)
 {
@@ -171,7 +193,7 @@ static void sigrok_feed_callback(const struct sr_dev_inst *sdi,
        sstrncpy(vl.plugin, "sigrok", sizeof(vl.plugin));
        ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance),
                        "%s", cfdev->name);
-       sstrncpy(vl.type, "gauge", sizeof(vl.type));
+       sstrncpy(vl.type, sigrok_value_type(analog), sizeof(vl.type));
        plugin_dispatch_values(&vl);
 
        cfdev->last_dispatch = cdtime();