From: Bert Vermeulen Date: Wed, 31 Jul 2013 09:24:36 +0000 (+0200) Subject: Use value types according to sigrok measured quantity X-Git-Tag: collectd-5.4.0~14^2~7 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4058f2aec4638dc5cbfeb67fa683cd9cf1631ef2;p=collectd.git Use value types according to sigrok measured quantity --- diff --git a/src/sigrok.c b/src/sigrok.c index 28adfbd1..7e2fa6c1 100644 --- a/src/sigrok.c +++ b/src/sigrok.c @@ -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();