]> sigrok.org Git - libsigrok.git/commitdiff
es519xx: fix continuity mode handling
authorAurelien Jacobs <redacted>
Sun, 29 Dec 2013 15:59:30 +0000 (16:59 +0100)
committerUwe Hermann <redacted>
Sun, 29 Dec 2013 17:46:03 +0000 (18:46 +0100)
Depending on the chip, the limit value for the buzzer is between 25 and 35 Ω,
so this code set the limit for continuity to 25 Ω to be on the safe side.

hardware/common/dmm/es519xx.c

index 999422955095ad4d84857c8df75879fca542694e..3340be98c48ac20c13700f333e161c0eece9b302 100644 (file)
@@ -156,7 +156,7 @@ static int parse_range(uint8_t b, float *floatval,
        else if (info->is_rpm)
                /* Not a typo, it's really index 4 in factors_2400_11b[][]. */
                mode = 4; /* RPM */
-       else if (info->is_resistance)
+       else if (info->is_resistance || info->is_continuity)
                mode = 5; /* Resistance */
        else if (info->is_frequency)
                mode = 6; /* Frequency */
@@ -455,7 +455,7 @@ static void handle_flags(struct sr_datafeed_analog *analog,
        if (info->is_continuity) {
                analog->mq = SR_MQ_CONTINUITY;
                analog->unit = SR_UNIT_BOOLEAN;
-               *floatval = (*floatval < 0.0) ? 0.0 : 1.0;
+               *floatval = (*floatval < 0.0 || *floatval > 25.0) ? 0.0 : 1.0;
        }
        if (info->is_diode) {
                analog->mq = SR_MQ_VOLTAGE;
@@ -588,9 +588,11 @@ static int sr_es519xx_parse(const uint8_t *buf, float *floatval,
                return ret;
        }
 
-       handle_flags(analog, floatval, info);
+       if ((ret = parse_range(buf[0], floatval, info)) != SR_OK)
+               return ret;
 
-       return parse_range(buf[0], floatval, info);
+       handle_flags(analog, floatval, info);
+       return SR_OK;
 }
 
 /*