]> sigrok.org Git - libsigrok.git/blobdiff - src/dmm/vc870.c
dmm: vc870: drop unused variable
[libsigrok.git] / src / dmm / vc870.c
index ee61483b6aec61114477066c89dd990ded6d8955..2663260bc48ca9464d0fe23928446156d33214e3 100644 (file)
@@ -59,7 +59,7 @@ static const float factors[][8] = {
        /* TODO: Verify factor for ACA */
        {1e-3,  0,     0,     0,    0,    0,    0,    0},    /* ACA */
        {1e-1,  0,     0,     0,    0,    0,    0,    0},    /* Act+apparent power */
-       {1e-1,  0,     0,     0,    0,    0,    0,    0},    /* Power factor / freq */
+       {1e-3,  0,     0,     0,    0,    0,    0,    0},    /* Power factor / freq */
        {1e-1,  0,     0,     0,    0,    0,    0,    0},    /* V eff + A eff */
 };
 
@@ -150,7 +150,7 @@ static int parse_range(uint8_t b, float *floatval,
                mode = 16; /* Act+apparent power */
        else if (info->is_power_factor_freq)
                mode = 17; /* Power factor / freq */
-       else if (info->is_v_a_eff_value)
+       else if (info->is_v_a_rms_value)
                mode = 18; /* V eff + A eff */
        else {
                sr_dbg("Invalid mode, range byte was: 0x%02x.", b);
@@ -225,7 +225,7 @@ static void parse_flags(const uint8_t *buf, struct vc870_info *info)
                        info->is_power_factor_freq = TRUE;
                else if (buf[1] == 0x32)
                        /* Voltage effective value + current effective value */
-                       info->is_v_a_eff_value = TRUE;
+                       info->is_v_a_rms_value = TRUE;
                break;
        default:
                sr_dbg("Invalid function bytes: %02x %02x.", buf[0], buf[1]);
@@ -280,7 +280,6 @@ static void parse_flags(const uint8_t *buf, struct vc870_info *info)
        /* Byte 22: Always '\n' (newline, 0x0a, 10) */
 
        info->is_auto = !info->is_manu;
-       info->is_rms = TRUE;
 }
 
 static void handle_flags(struct sr_datafeed_analog_old *analog,
@@ -337,13 +336,6 @@ static void handle_flags(struct sr_datafeed_analog_old *analog,
                analog->mq = SR_MQ_POWER;
                analog->unit = SR_UNIT_WATT;
        }
-       if (info->is_power_factor_freq) {
-               /* TODO: Handle power factor. */
-               // analog->mq = SR_MQ_POWER_FACTOR;
-               // analog->unit = SR_UNIT_UNITLESS;
-               analog->mq = SR_MQ_FREQUENCY;
-               analog->unit = SR_UNIT_HERTZ;
-       }
        if (info->is_power_apparent_power) {
                analog->mq = SR_MQ_POWER;
                analog->unit = SR_UNIT_WATT;
@@ -351,6 +343,21 @@ static void handle_flags(struct sr_datafeed_analog_old *analog,
                // analog->mq = SR_MQ_APPARENT_POWER;
                // analog->unit = SR_UNIT_VOLT_AMPERE;
        }
+       if (info->is_power_factor_freq) {
+               analog->mq = SR_MQ_POWER_FACTOR;
+               analog->unit = SR_UNIT_UNITLESS;
+               /* TODO: Handle frequency. */
+               // analog->mq = SR_MQ_FREQUENCY;
+               // analog->unit = SR_UNIT_HERTZ;
+       }
+       if (info->is_v_a_rms_value) {
+               analog->mqflags |= SR_MQFLAG_RMS;
+               analog->mq = SR_MQ_VOLTAGE;
+               analog->unit = SR_UNIT_VOLT;
+               /* TODO: Handle effective current value */
+               // analog->mq = SR_MQ_CURRENT;
+               // analog->unit = SR_UNIT_AMPERE;
+       }
 
        /* Measurement related flags */
        if (info->is_ac)