* UNI-T UT372 protocol parser.
*/
+#include <config.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#define LOG_PREFIX "ut372"
-uint8_t lookup[] = {
+static const uint8_t lookup[] = {
0x7B,
0x60,
0x5E,
0x3F,
0x70,
0x7F,
- 0x7D
+ 0x7D,
};
#define DECIMAL_POINT_MASK 0x80
#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)
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);