2 * This file is part of the libsigrok project.
4 * Copyright (C) 2013 Matthias Heidbrink <m-sigrok@heidbrink.biz>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * BBC Goerz Metrawatt M2110 ASCII protocol parser.
25 * Most probably the simplest multimeter protocol ever ;-) .
32 #include <libsigrok/libsigrok.h>
33 #include "libsigrok-internal.h"
35 #define LOG_PREFIX "m2110"
37 SR_PRIV gboolean sr_m2110_packet_valid(const uint8_t *buf)
41 if ((buf[7] != '\r') || (buf[8] != '\n'))
44 if (!strncmp((const char *)buf, "OVERRNG", 7))
47 if (sscanf((const char *)buf, "%f", &val) == 1)
53 SR_PRIV int sr_m2110_parse(const uint8_t *buf, float *floatval,
54 struct sr_datafeed_analog_old *analog, void *info)
60 /* We don't know the unit, so that's the best we can do. */
61 analog->mq = SR_MQ_GAIN;
62 analog->unit = SR_UNIT_UNITLESS;
65 if (!strncmp((const char *)buf, "OVERRNG", 7))
67 else if (sscanf((const char *)buf, "%f", &val) == 1)