X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdmm%2Fut372.c;h=74f8757555c15abbe5a2d55ba2886950d7a419b6;hb=b89462e45706e9b4f65eced96c7d76347f4b5569;hp=2de8eec9996d4a0531d69d31072352d4cd83bd4c;hpb=12318aab968eb27954d4b1497eecc31f9f3c3c1d;p=libsigrok.git diff --git a/src/dmm/ut372.c b/src/dmm/ut372.c index 2de8eec9..74f87575 100644 --- a/src/dmm/ut372.c +++ b/src/dmm/ut372.c @@ -22,15 +22,16 @@ * UNI-T UT372 protocol parser. */ +#include #include #include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #define LOG_PREFIX "ut372" -uint8_t lookup[] = { +static const uint8_t lookup[] = { 0x7B, 0x60, 0x5E, @@ -40,7 +41,7 @@ uint8_t lookup[] = { 0x3F, 0x70, 0x7F, - 0x7D + 0x7D, }; #define DECIMAL_POINT_MASK 0x80 @@ -51,7 +52,7 @@ uint8_t lookup[] = { #define FLAGS2_COUNT_MASK (1 << 1) #define FLAGS2_MAX_MASK (1 << 4) #define FLAGS2_MIN_MASK (1 << 5) -#define FLAGS2_AVE_MASK (1 << 6) +#define FLAGS2_AVG_MASK (1 << 6) /* Decode a pair of characters into a byte. */ static uint8_t decode_pair(const uint8_t *buf) @@ -87,7 +88,7 @@ SR_PRIV gboolean sr_ut372_packet_valid(const uint8_t *buf) } SR_PRIV int sr_ut372_parse(const uint8_t *buf, float *floatval, - struct sr_datafeed_analog *analog, void *info) + struct sr_datafeed_analog_old *analog, void *info) { unsigned int i, j, value, divisor; uint8_t segments, flags1, flags2; @@ -111,14 +112,14 @@ SR_PRIV int sr_ut372_parse(const uint8_t *buf, float *floatval, analog->mqflags |= SR_MQFLAG_MIN; if (flags2 & FLAGS2_MAX_MASK) analog->mqflags |= SR_MQFLAG_MAX; - if (flags2 & FLAGS2_AVE_MASK) + if (flags2 & FLAGS2_AVG_MASK) analog->mqflags |= SR_MQFLAG_AVG; value = 0; divisor = 1; for (i = 0; i < 5; i++) { - segments = decode_pair(buf + 1 + 2*i); + segments = decode_pair(buf + 1 + (2 * i)); for (j = 0; j < ARRAY_SIZE(lookup); j++) { if (lookup[j] == (segments & ~DECIMAL_POINT_MASK)) { value += j * pow(10, i);