2 * This file is part of the libsigrok project.
4 * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
5 * Copyright (C) 2013 Aurelien Jacobs <aurel@gnuage.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * Cyrustek ES519XX protocol parser.
25 * Communication parameters: Unidirectional, 2400/7o1 or 19230/7o1
32 #include "libsigrok.h"
33 #include "libsigrok-internal.h"
35 /* Message logging helpers with subsystem-specific prefix string. */
36 #define LOG_PREFIX "es519xx: "
37 #define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
38 #define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
39 #define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
40 #define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
41 #define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
42 #define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
44 /* Factors for the respective measurement mode (0 means "invalid"). */
45 static const float factors_2400_11b[8][8] = {
46 {1e-4, 1e-3, 1e-2, 1e-1, 1, 0, 0, 0 }, /* V */
47 {1e-7, 1e-6, 0, 0, 0, 0, 0, 0 }, /* uA */
48 {1e-5, 1e-4, 0, 0, 0, 0, 0, 0 }, /* mA */
49 {1e-2, 0, 0, 0, 0, 0, 0, 0 }, /* A */
50 {1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 0, 0 }, /* RPM */
51 {1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0, 0 }, /* Resistance */
52 {1, 1e1, 1e2, 1e3, 1e4, 1e5, 0, 0 }, /* Frequency */
53 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
55 static const float factors_19200_11b_5digits[8][8] = {
56 {1e-4, 1e-3, 1e-2, 1e-1, 1e-5, 0, 0, 0}, /* V */
57 {1e-8, 1e-7, 0, 0, 0, 0, 0, 0}, /* uA */
58 {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* mA */
59 {0, 1e-3, 0, 0, 0, 0, 0, 0}, /* A */
60 {1e-4, 1e-3, 1e-2, 1e-1, 1, 0, 0, 0}, /* Manual A */
61 {1e-2, 1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Resistance */
62 {1e-1, 0, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Frequency */
63 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
65 static const float factors_19200_11b_clampmeter[8][8] = {
66 {1e-3, 1e-2, 1e-1, 1, 1e-4, 0, 0, 0}, /* V */
67 {1e-7, 1e-6, 0, 0, 0, 0, 0, 0}, /* uA */
68 {1e-5, 1e-4, 0, 0, 0, 0, 0, 0}, /* mA */
69 {1e-2, 0, 0, 0, 0, 0, 0, 0}, /* A */
70 {1e-3, 1e-2, 1e-1, 1, 0, 0, 0, 0}, /* Manual A */
71 {1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0, 0}, /* Resistance */
72 {1e-1, 0, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Frequency */
73 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
75 static const float factors_19200_11b[8][8] = {
76 {1e-3, 1e-2, 1e-1, 1, 1e-4, 0, 0, 0}, /* V */
77 {1e-7, 1e-6, 0, 0, 0, 0, 0, 0}, /* uA */
78 {1e-5, 1e-4, 0, 0, 0, 0, 0, 0}, /* mA */
79 {1e-3, 1e-2, 0, 0, 0, 0, 0, 0}, /* A */
80 {0, 0, 0, 0, 0, 0, 0, 0}, /* Manual A */
81 {1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0, 0}, /* Resistance */
82 {1, 1e1, 1e2, 1e3, 1e4, 0, 0, 0}, /* Frequency */
83 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 0}, /* Capacitance */
85 static const float factors_19200_14b[8][8] = {
86 {1e-4, 1e-3, 1e-2, 1e-1, 1e-5, 0, 0, 0}, /* V */
87 {1e-8, 1e-7, 0, 0, 0, 0, 0, 0}, /* uA */
88 {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* mA */
89 {1e-3, 0, 0, 0, 0, 0, 0, 0}, /* A */
90 {1e-4, 1e-3, 1e-2, 1e-1, 1, 0, 0, 0}, /* Manual A */
91 {1e-2, 1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Resistance */
92 {1e-2, 1e-1, 0, 1, 1e1, 1e2, 1e3, 1e4}, /* Frequency */
93 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
96 static int parse_value(const uint8_t *buf, struct es519xx_info *info,
99 int i, intval, num_digits;
102 num_digits = 4 + ((info->packet_size == 14) ? 1 : 0);
104 /* Bytes 1-4 (or 5): Value (4 or 5 decimal digits) */
106 sr_spew("Over limit.");
109 } else if (info->is_ul) {
110 sr_spew("Under limit.");
113 } else if (!isdigit(buf[1]) || !isdigit(buf[2]) ||
114 !isdigit(buf[3]) || !isdigit(buf[4]) ||
115 (num_digits == 5 && !isdigit(buf[5]))) {
116 sr_err("Value contained invalid digits: %02x %02x %02x %02x "
117 "(%c %c %c %c).", buf[1], buf[2], buf[3], buf[4],
118 buf[1], buf[2], buf[3], buf[4]);
121 intval = (info->is_digit4) ? 1 : 0;
122 for (i = 0; i < num_digits; i++)
123 intval = 10 * intval + (buf[i + 1] - '0');
126 intval *= info->is_sign ? -1 : 1;
128 floatval = (float)intval;
130 /* Note: The decimal point position will be parsed later. */
132 sr_spew("The display value is %f.", floatval);
139 static int parse_range(uint8_t b, float *floatval,
140 const struct es519xx_info *info)
147 if (idx < 0 || idx > 7) {
148 sr_dbg("Invalid range byte / index: 0x%02x / 0x%02x.", b, idx);
152 /* Parse range byte (depends on the measurement mode). */
153 if (info->is_voltage)
155 else if (info->is_current && info->is_micro)
157 else if (info->is_current && info->is_milli)
159 else if (info->is_current && info->is_auto)
161 else if (info->is_current && !info->is_auto)
162 mode = 4; /* Manual A */
163 else if (info->is_rpm)
164 /* Not a typo, it's really index 4 in factors_2400_11b[][]. */
166 else if (info->is_resistance)
167 mode = 5; /* Resistance */
168 else if (info->is_frequency)
169 mode = 6; /* Frequency */
170 else if (info->is_capacitance)
171 mode = 7; /* Capacitance */
173 sr_dbg("Invalid mode, range byte was: 0x%02x.", b);
179 factor = (const float[]){1e-1, 1}[idx];
180 else if (info->is_milli)
181 factor = (const float[]){1e-2, 1e-1}[idx];
183 else if (info->baudrate == 2400)
184 factor = factors_2400_11b[mode][idx];
185 else if (info->fivedigits)
186 factor = factors_19200_11b_5digits[mode][idx];
187 else if (info->clampmeter)
188 factor = factors_19200_11b_clampmeter[mode][idx];
189 else if (info->packet_size == 11)
190 factor = factors_19200_11b[mode][idx];
191 else if (info->packet_size == 14)
192 factor = factors_19200_14b[mode][idx];
195 sr_dbg("Invalid factor for range byte: 0x%02x.", b);
199 /* Apply respective factor (mode-dependent) on the value. */
201 sr_dbg("Applying factor %f, new value is %f.", factor, *floatval);
206 static void parse_flags(const uint8_t *buf, struct es519xx_info *info)
208 int function, status;
210 function = 5 + ((info->packet_size == 14) ? 1 : 0);
211 status = function + 1;
214 if (info->alt_functions) {
215 info->is_sign = (buf[status] & (1 << 3)) != 0;
216 info->is_batt = (buf[status] & (1 << 2)) != 0; /* Bat. low */
217 info->is_ol = (buf[status] & (1 << 1)) != 0; /* Overflow */
218 info->is_ol |= (buf[status] & (1 << 0)) != 0; /* Overflow */
220 info->is_judge = (buf[status] & (1 << 3)) != 0;
221 info->is_sign = (buf[status] & (1 << 2)) != 0;
222 info->is_batt = (buf[status] & (1 << 1)) != 0; /* Bat. low */
223 info->is_ol = (buf[status] & (1 << 0)) != 0; /* Overflow */
226 if (info->packet_size == 14) {
228 info->is_max = (buf[8] & (1 << 3)) != 0;
229 info->is_min = (buf[8] & (1 << 2)) != 0;
230 info->is_rel = (buf[8] & (1 << 1)) != 0;
231 info->is_rmr = (buf[8] & (1 << 0)) != 0;
234 info->is_ul = (buf[9] & (1 << 3)) != 0; /* Underflow */
235 info->is_pmax = (buf[9] & (1 << 2)) != 0; /* Max. peak value */
236 info->is_pmin = (buf[9] & (1 << 1)) != 0; /* Min. peak value */
239 info->is_dc = (buf[10] & (1 << 3)) != 0;
240 info->is_ac = (buf[10] & (1 << 2)) != 0;
241 info->is_auto = (buf[10] & (1 << 1)) != 0;
242 info->is_vahz = (buf[10] & (1 << 0)) != 0;
244 /* LPF: Low-pass filter(s) */
245 if (info->selectable_lpf) {
247 info->is_hold = (buf[11] & (1 << 3)) != 0;
248 info->is_vbar = (buf[11] & (1 << 2)) != 0;
249 info->is_lpf1 = (buf[11] & (1 << 1)) != 0;
250 info->is_lpf0 = (buf[11] & (1 << 0)) != 0;
253 info->is_vbar = (buf[11] & (1 << 2)) != 0;
254 info->is_hold = (buf[11] & (1 << 1)) != 0;
255 info->is_lpf1 = (buf[11] & (1 << 0)) != 0;
257 } else if (info->alt_functions) {
259 info->is_dc = (buf[8] & (1 << 3)) != 0;
260 info->is_auto = (buf[8] & (1 << 2)) != 0;
261 info->is_apo = (buf[8] & (1 << 0)) != 0;
262 info->is_ac = !info->is_dc;
265 if (info->baudrate == 2400) {
266 info->is_pmax = (buf[7] & (1 << 3)) != 0;
267 info->is_pmin = (buf[7] & (1 << 2)) != 0;
268 info->is_vahz = (buf[7] & (1 << 0)) != 0;
269 } else if (info->fivedigits) {
270 info->is_ul = (buf[7] & (1 << 3)) != 0;
271 info->is_pmax = (buf[7] & (1 << 2)) != 0;
272 info->is_pmin = (buf[7] & (1 << 1)) != 0;
273 info->is_digit4 = (buf[7] & (1 << 0)) != 0;
274 } else if (info->clampmeter) {
275 info->is_ul = (buf[7] & (1 << 3)) != 0;
276 info->is_vasel = (buf[7] & (1 << 2)) != 0;
277 info->is_vbar = (buf[7] & (1 << 1)) != 0;
279 info->is_hold = (buf[7] & (1 << 3)) != 0;
280 info->is_max = (buf[7] & (1 << 2)) != 0;
281 info->is_min = (buf[7] & (1 << 1)) != 0;
285 info->is_dc = (buf[8] & (1 << 3)) != 0;
286 info->is_ac = (buf[8] & (1 << 2)) != 0;
287 info->is_auto = (buf[8] & (1 << 1)) != 0;
288 if (info->baudrate == 2400)
289 info->is_apo = (buf[8] & (1 << 0)) != 0;
291 info->is_vahz = (buf[8] & (1 << 0)) != 0;
295 if (info->alt_functions) {
296 switch (buf[function]) {
298 info->is_current = info->is_auto = TRUE;
301 info->is_current = info->is_micro = info->is_auto = TRUE;
304 info->is_current = info->is_milli = info->is_auto = TRUE;
307 info->is_voltage = TRUE;
309 case 0x37: /* Resistance */
310 info->is_resistance = TRUE;
312 case 0x36: /* Continuity */
313 info->is_continuity = TRUE;
315 case 0x3b: /* Diode */
316 info->is_diode = TRUE;
318 case 0x3a: /* Frequency */
319 info->is_frequency = TRUE;
321 case 0x34: /* ADP0 */
322 case 0x35: /* ADP0 */
323 info->is_adp0 = TRUE;
325 case 0x38: /* ADP1 */
326 case 0x39: /* ADP1 */
327 info->is_adp1 = TRUE;
329 case 0x32: /* ADP2 */
330 case 0x33: /* ADP2 */
331 info->is_adp2 = TRUE;
333 case 0x30: /* ADP3 */
334 case 0x31: /* ADP3 */
335 info->is_adp3 = TRUE;
338 sr_err("Invalid function byte: 0x%02x.", buf[function]);
342 /* Note: Some of these mappings are fixed up later. */
343 switch (buf[function]) {
345 info->is_voltage = TRUE;
348 info->is_current = info->is_micro = info->is_auto = TRUE;
351 info->is_current = info->is_milli = info->is_auto = TRUE;
354 info->is_current = info->is_auto = TRUE;
356 case 0x39: /* Manual A */
357 info->is_current = TRUE;
358 info->is_auto = FALSE; /* Manual mode */
360 case 0x33: /* Resistance */
361 info->is_resistance = TRUE;
363 case 0x35: /* Continuity */
364 info->is_continuity = TRUE;
366 case 0x31: /* Diode */
367 info->is_diode = TRUE;
369 case 0x32: /* Frequency / RPM / duty cycle */
370 if (info->packet_size == 14) {
372 info->is_frequency = TRUE;
374 info->is_duty_cycle = TRUE;
379 info->is_frequency = TRUE;
382 case 0x36: /* Capacitance */
383 info->is_capacitance = TRUE;
385 case 0x34: /* Temperature */
386 info->is_temperature = TRUE;
388 info->is_celsius = TRUE;
390 info->is_fahrenheit = TRUE;
391 /* IMPORTANT: The digits always represent Celsius! */
393 case 0x3e: /* ADP0 */
394 info->is_adp0 = TRUE;
396 case 0x3c: /* ADP1 */
397 info->is_adp1 = TRUE;
399 case 0x38: /* ADP2 */
400 info->is_adp2 = TRUE;
402 case 0x3a: /* ADP3 */
403 info->is_adp3 = TRUE;
406 sr_err("Invalid function byte: 0x%02x.", buf[function]);
411 if (info->is_current && (info->is_micro || info->is_milli) && info->is_vasel) {
412 info->is_current = info->is_auto = FALSE;
413 info->is_voltage = TRUE;
416 if (info->baudrate == 2400) {
417 /* Inverted mapping between mA and A, and no manual A. */
418 if (info->is_current && (info->is_milli || !info->is_auto)) {
419 info->is_milli = !info->is_milli;
420 info->is_auto = TRUE;
425 static void handle_flags(struct sr_datafeed_analog *analog,
426 float *floatval, const struct es519xx_info *info)
429 * Note: is_micro etc. are not used directly to multiply/divide
430 * floatval, this is handled via parse_range() and factors[][].
433 /* Measurement modes */
434 if (info->is_voltage) {
435 analog->mq = SR_MQ_VOLTAGE;
436 analog->unit = SR_UNIT_VOLT;
438 if (info->is_current) {
439 analog->mq = SR_MQ_CURRENT;
440 analog->unit = SR_UNIT_AMPERE;
442 if (info->is_resistance) {
443 analog->mq = SR_MQ_RESISTANCE;
444 analog->unit = SR_UNIT_OHM;
446 if (info->is_frequency) {
447 analog->mq = SR_MQ_FREQUENCY;
448 analog->unit = SR_UNIT_HERTZ;
450 if (info->is_capacitance) {
451 analog->mq = SR_MQ_CAPACITANCE;
452 analog->unit = SR_UNIT_FARAD;
454 if (info->is_temperature && info->is_celsius) {
455 analog->mq = SR_MQ_TEMPERATURE;
456 analog->unit = SR_UNIT_CELSIUS;
458 if (info->is_temperature && info->is_fahrenheit) {
459 analog->mq = SR_MQ_TEMPERATURE;
460 analog->unit = SR_UNIT_FAHRENHEIT;
462 if (info->is_continuity) {
463 analog->mq = SR_MQ_CONTINUITY;
464 analog->unit = SR_UNIT_BOOLEAN;
465 *floatval = (*floatval < 0.0) ? 0.0 : 1.0;
467 if (info->is_diode) {
468 analog->mq = SR_MQ_VOLTAGE;
469 analog->unit = SR_UNIT_VOLT;
472 analog->mq = SR_MQ_FREQUENCY;
473 analog->unit = SR_UNIT_REVOLUTIONS_PER_MINUTE;
475 if (info->is_duty_cycle) {
476 analog->mq = SR_MQ_DUTY_CYCLE;
477 analog->unit = SR_UNIT_PERCENTAGE;
480 /* Measurement related flags */
482 analog->mqflags |= SR_MQFLAG_AC;
484 analog->mqflags |= SR_MQFLAG_DC;
486 analog->mqflags |= SR_MQFLAG_AUTORANGE;
488 analog->mqflags |= SR_MQFLAG_DIODE;
491 * Note: HOLD only affects the number displayed on the LCD,
492 * but not the value sent via the protocol! It also does not
493 * affect the bargraph on the LCD.
495 analog->mqflags |= SR_MQFLAG_HOLD;
497 analog->mqflags |= SR_MQFLAG_MAX;
499 analog->mqflags |= SR_MQFLAG_MIN;
501 analog->mqflags |= SR_MQFLAG_RELATIVE;
505 sr_spew("Judge bit is set.");
507 sr_spew("Battery is low.");
509 sr_spew("Input overflow.");
511 sr_spew("Input underflow.");
513 sr_spew("pMAX active, LCD shows max. peak value.");
515 sr_spew("pMIN active, LCD shows min. peak value.");
517 sr_spew("VAHZ active.");
519 sr_spew("Auto-Power-Off enabled.");
521 sr_spew("VBAR active.");
522 if ((!info->selectable_lpf && info->is_lpf1) ||
523 (info->selectable_lpf && (!info->is_lpf0 || !info->is_lpf1)))
524 sr_spew("Low-pass filter feature is active.");
527 static gboolean flags_valid(const struct es519xx_info *info)
531 /* Does the packet have more than one multiplier? */
532 count = (info->is_micro) ? 1 : 0;
533 count += (info->is_milli) ? 1 : 0;
535 sr_err("More than one multiplier detected in packet.");
539 /* Does the packet "measure" more than one type of value? */
540 count = (info->is_voltage) ? 1 : 0;
541 count += (info->is_current) ? 1 : 0;
542 count += (info->is_resistance) ? 1 : 0;
543 count += (info->is_frequency) ? 1 : 0;
544 count += (info->is_capacitance) ? 1 : 0;
545 count += (info->is_temperature) ? 1 : 0;
546 count += (info->is_continuity) ? 1 : 0;
547 count += (info->is_diode) ? 1 : 0;
548 count += (info->is_rpm) ? 1 : 0;
550 sr_err("More than one measurement type detected in packet.");
554 /* Both AC and DC set? */
555 if (info->is_ac && info->is_dc) {
556 sr_err("Both AC and DC flags detected in packet.");
563 static gboolean sr_es519xx_packet_valid(const uint8_t *buf,
564 struct es519xx_info *info)
568 s = info->packet_size;
570 if (s == 11 && memcmp(buf, buf + s, s))
573 if (buf[s - 2] != '\r' || buf[s - 1] != '\n')
576 parse_flags(buf, info);
578 if (!flags_valid(info))
584 static int sr_es519xx_parse(const uint8_t *buf, float *floatval,
585 struct sr_datafeed_analog *analog,
586 struct es519xx_info *info)
590 if (!sr_es519xx_packet_valid(buf, info))
593 if ((ret = parse_value(buf, info, floatval)) != SR_OK) {
594 sr_err("Error parsing value: %d.", ret);
598 handle_flags(analog, floatval, info);
600 return parse_range(buf[0], floatval, info);
604 * Functions for 2400 baud / 11 bytes protocols.
605 * This includes ES51962, ES51971, ES51972, ES51978 and ES51989.
607 SR_PRIV gboolean sr_es519xx_2400_11b_packet_valid(const uint8_t *buf)
609 struct es519xx_info info;
611 info.baudrate = 2400;
612 info.packet_size = 11;
614 return sr_es519xx_packet_valid(buf, &info);
617 SR_PRIV int sr_es519xx_2400_11b_parse(const uint8_t *buf, float *floatval,
618 struct sr_datafeed_analog *analog, void *info)
620 struct es519xx_info *info_local;
623 info_local->baudrate = 2400;
624 info_local->packet_size = 11;
626 return sr_es519xx_parse(buf, floatval, analog, info);
630 * Functions for 2400 baud / 11 byte protocols.
631 * This includes ES51960, ES51977 and ES51988.
633 SR_PRIV gboolean sr_es519xx_2400_11b_altfn_packet_valid(const uint8_t *buf)
635 struct es519xx_info info;
637 info.baudrate = 2400;
638 info.packet_size = 11;
639 info.alt_functions = TRUE;
641 return sr_es519xx_packet_valid(buf, &info);
644 SR_PRIV int sr_es519xx_2400_11b_altfn_parse(const uint8_t *buf,
645 float *floatval, struct sr_datafeed_analog *analog, void *info)
647 struct es519xx_info *info_local;
650 info_local->baudrate = 2400;
651 info_local->packet_size = 11;
652 info_local->alt_functions = TRUE;
654 return sr_es519xx_parse(buf, floatval, analog, info);
658 * Functions for 19200 baud / 11 bytes protocols with 5 digits display.
659 * This includes ES51911, ES51916 and ES51918.
661 SR_PRIV gboolean sr_es519xx_19200_11b_5digits_packet_valid(const uint8_t *buf)
663 struct es519xx_info info;
665 info.baudrate = 19200;
666 info.packet_size = 11;
667 info.fivedigits = TRUE;
669 return sr_es519xx_packet_valid(buf, &info);
672 SR_PRIV int sr_es519xx_19200_11b_5difits_parse(const uint8_t *buf,
673 float *floatval, struct sr_datafeed_analog *analog, void *info)
675 struct es519xx_info *info_local;
678 info_local->baudrate = 19200;
679 info_local->packet_size = 11;
680 info_local->fivedigits = TRUE;
682 return sr_es519xx_parse(buf, floatval, analog, info);
686 * Functions for 19200 baud / 11 bytes protocols with clamp meter support.
687 * This includes ES51967 and ES51969.
689 SR_PRIV gboolean sr_es519xx_19200_11b_clamp_packet_valid(const uint8_t *buf)
691 struct es519xx_info info;
693 info.baudrate = 19200;
694 info.packet_size = 11;
695 info.clampmeter = TRUE;
697 return sr_es519xx_packet_valid(buf, &info);
700 SR_PRIV int sr_es519xx_19200_11b_clamp_parse(const uint8_t *buf,
701 float *floatval, struct sr_datafeed_analog *analog, void *info)
703 struct es519xx_info *info_local;
706 info_local->baudrate = 19200;
707 info_local->packet_size = 11;
708 info_local->clampmeter = TRUE;
710 return sr_es519xx_parse(buf, floatval, analog, info);
714 * Functions for 19200 baud / 11 bytes protocols.
715 * This includes ES51981, ES51982, ES51983, ES51984 and ES51986.
717 SR_PRIV gboolean sr_es519xx_19200_11b_packet_valid(const uint8_t *buf)
719 struct es519xx_info info;
721 info.baudrate = 19200;
722 info.packet_size = 11;
724 return sr_es519xx_packet_valid(buf, &info);
727 SR_PRIV int sr_es519xx_19200_11b_parse(const uint8_t *buf, float *floatval,
728 struct sr_datafeed_analog *analog, void *info)
730 struct es519xx_info *info_local;
733 info_local->baudrate = 19200;
734 info_local->packet_size = 11;
736 return sr_es519xx_parse(buf, floatval, analog, info);
740 * Functions for 19200 baud / 14 bytes protocols.
741 * This includes ES51921 and ES51922.
743 SR_PRIV gboolean sr_es519xx_19200_14b_packet_valid(const uint8_t *buf)
745 struct es519xx_info info;
747 info.baudrate = 19200;
748 info.packet_size = 14;
750 return sr_es519xx_packet_valid(buf, &info);
753 SR_PRIV int sr_es519xx_19200_14b_parse(const uint8_t *buf, float *floatval,
754 struct sr_datafeed_analog *analog, void *info)
756 struct es519xx_info *info_local;
759 info_local->baudrate = 19200;
760 info_local->packet_size = 14;
762 return sr_es519xx_parse(buf, floatval, analog, info);
766 * Functions for 19200 baud / 14 bytes protocols with selectable LPF.
767 * This includes ES51931 and ES51932.
769 SR_PRIV gboolean sr_es519xx_19200_14b_sel_lpf_packet_valid(const uint8_t *buf)
771 struct es519xx_info info;
773 info.baudrate = 19200;
774 info.packet_size = 14;
775 info.selectable_lpf = TRUE;
777 return sr_es519xx_packet_valid(buf, &info);
780 SR_PRIV int sr_es519xx_19200_14b_sel_lpf_parse(const uint8_t *buf,
781 float *floatval, struct sr_datafeed_analog *analog, void *info)
783 struct es519xx_info *info_local;
786 info_local->baudrate = 19200;
787 info_local->packet_size = 14;
788 info_local->selectable_lpf = TRUE;
790 return sr_es519xx_parse(buf, floatval, analog, info);