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
33 #include <libsigrok/libsigrok.h>
34 #include "libsigrok-internal.h"
36 #define LOG_PREFIX "es519xx"
38 /* Exponents for the respective measurement mode. */
39 static const int exponents_2400_11b[9][8] = {
40 { -4, -3, -2, -1, 0, 0, 0, 0 }, /* V */
41 { -7, -6, 0, 0, 0, 0, 0, 0 }, /* uA */
42 { -5, -4, 0, 0, 0, 0, 0, 0 }, /* mA */
43 { -2, 0, 0, 0, 0, 0, 0, 0 }, /* A */
44 { 1, 2, 3, 4, 5, 6, 0, 0 }, /* RPM */
45 { -1, 0, 1, 2, 3, 4, 0, 0 }, /* Resistance */
46 { 0, 1, 2, 3, 4, 5, 0, 0 }, /* Frequency */
47 { -12, -11, -10, -9, -8, -7, -6, -5 }, /* Capacitance */
48 { -3, 0, 0, 0, 0, 0, 0, 0 }, /* Diode */
50 static const int exponents_19200_11b_5digits[9][8] = {
51 { -4, -3, -2, -1, -5, 0, 0, 0 }, /* V */
52 { -8, -7, 0, 0, 0, 0, 0, 0 }, /* uA */
53 { -6, -5, 0, 0, 0, 0, 0, 0 }, /* mA */
54 { 0, -3, 0, 0, 0, 0, 0, 0 }, /* A */
55 { -4, -3, -2, -1, 0, 0, 0, 0 }, /* Manual A */
56 { -2, -1, 0, 1, 2, 3, 4, 0 }, /* Resistance */
57 { -1, 0, 0, 1, 2, 3, 4, 0 }, /* Frequency */
58 { -12, -11, -10, -9, -8, -7, -6, -5 }, /* Capacitance */
59 { -4, 0, 0, 0, 0, 0, 0, 0 }, /* Diode */
61 static const int exponents_19200_11b_clampmeter[9][8] = {
62 { -3, -2, -1, 0, -4, 0, 0, 0 }, /* V */
63 { -7, -6, 0, 0, 0, 0, 0, 0 }, /* uA */
64 { -5, -4, 0, 0, 0, 0, 0, 0 }, /* mA */
65 { -2, 0, 0, 0, 0, 0, 0, 0 }, /* A */
66 { -3, -2, -1, 0, 0, 0, 0, 0 }, /* Manual A */
67 { -1, 0, 1, 2, 3, 4, 0, 0 }, /* Resistance */
68 { -1, 0, 0, 1, 2, 3, 4, 0 }, /* Frequency */
69 { -12, -11, -10, -9, -8, -7, -6, -5 }, /* Capacitance */
70 { -3, 0, 0, 0, 0, 0, 0, 0 }, /* Diode */
72 static const int exponents_19200_11b[9][8] = {
73 { -3, -2, -1, 0, -4, 0, 0, 0 }, /* V */
74 { -7, -6, 0, 0, 0, 0, 0, 0 }, /* uA */
75 { -5, -4, 0, 0, 0, 0, 0, 0 }, /* mA */
76 { -3, -2, 0, 0, 0, 0, 0, 0 }, /* A */
77 { 0, 0, 0, 0, 0, 0, 0, 0 }, /* Manual A */
78 { -1, 0, 1, 2, 3, 4, 0, 0 }, /* Resistance */
79 { 0, 1, 2, 3, 4, 0, 0, 0 }, /* Frequency */
80 { -12, -11, -10, -9, -8, -7, -6, 0 }, /* Capacitance */
81 { -3, 0, 0, 0, 0, 0, 0, 0 }, /* Diode */
83 static const int exponents_19200_14b[9][8] = {
84 { -4, -3, -2, -1, -5, 0, 0, 0 }, /* V */
85 { -8, -7, 0, 0, 0, 0, 0, 0 }, /* uA */
86 { -6, -5, 0, 0, 0, 0, 0, 0 }, /* mA */
87 { -3, 0, 0, 0, 0, 0, 0, 0 }, /* A */
88 { -4, -3, -2, -1, 0, 0, 0, 0 }, /* Manual A */
89 { -2, -1, 0, 1, 2, 3, 4, 0 }, /* Resistance */
90 { -2, -1, 0, 0, 1, 2, 3, 4 }, /* Frequency */
91 { -12, -11, -10, -9, -8, -7, -6, -5 }, /* Capacitance */
92 { -4, 0, 0, 0, 0, 0, 0, 0 }, /* Diode */
95 static int parse_value(const uint8_t *buf, struct es519xx_info *info,
98 int i, intval, num_digits;
101 num_digits = 4 + ((info->packet_size == 14) ? 1 : 0);
103 /* Bytes 1-4 (or 5): Value (4 or 5 decimal digits) */
105 sr_spew("Over limit.");
108 } else if (info->is_ul) {
109 sr_spew("Under limit.");
112 } else if (!isdigit(buf[1]) || !isdigit(buf[2]) ||
113 !isdigit(buf[3]) || !isdigit(buf[4]) ||
114 (num_digits == 5 && !isdigit(buf[5]))) {
115 sr_dbg("Value contained invalid digits: %02x %02x %02x %02x "
116 "(%c %c %c %c).", buf[1], buf[2], buf[3], buf[4],
117 buf[1], buf[2], buf[3], buf[4]);
120 intval = (info->is_digit4) ? 1 : 0;
121 for (i = 0; i < num_digits; i++)
122 intval = 10 * intval + (buf[i + 1] - '0');
125 intval *= info->is_sign ? -1 : 1;
127 floatval = (float)intval;
129 /* Note: The decimal point position will be parsed later. */
131 sr_spew("The display value is %f.", floatval);
138 static int parse_range(uint8_t b, float *floatval, struct es519xx_info *info)
145 if (idx < 0 || idx > 7) {
146 sr_dbg("Invalid range byte / index: 0x%02x / 0x%02x.", b, idx);
150 /* Parse range byte (depends on the measurement mode). */
151 if (info->is_voltage)
153 else if (info->is_current && info->is_micro)
155 else if (info->is_current && info->is_milli)
157 else if (info->is_current && info->is_auto)
159 else if (info->is_current && !info->is_auto)
160 mode = 4; /* Manual A */
161 else if (info->is_rpm)
162 /* Not a typo, it's really index 4 in exponents_2400_11b[][]. */
164 else if (info->is_resistance || info->is_continuity)
165 mode = 5; /* Resistance */
166 else if (info->is_frequency)
167 mode = 6; /* Frequency */
168 else if (info->is_capacitance)
169 mode = 7; /* Capacitance */
170 else if (info->is_diode)
171 mode = 8; /* Diode */
172 else if (info->is_duty_cycle)
173 mode = 0; /* Dummy, unused */
175 sr_dbg("Invalid mode, range byte was: 0x%02x.", b);
181 exponent = (const int[]){-1, 0}[idx];
182 else if (info->is_milli)
183 exponent = (const int[]){-2, -1}[idx];
185 else if (info->is_duty_cycle)
187 else if (info->baudrate == 2400)
188 exponent = exponents_2400_11b[mode][idx];
189 else if (info->fivedigits)
190 exponent = exponents_19200_11b_5digits[mode][idx];
191 else if (info->clampmeter)
192 exponent = exponents_19200_11b_clampmeter[mode][idx];
193 else if (info->packet_size == 11)
194 exponent = exponents_19200_11b[mode][idx];
195 else if (info->packet_size == 14)
196 exponent = exponents_19200_14b[mode][idx];
198 /* Apply respective exponent (mode-dependent) on the value. */
199 *floatval *= powf(10, exponent);
200 sr_dbg("Applying exponent %d, new value is %f.", exponent, *floatval);
202 info->digits = -exponent;
207 static void parse_flags(const uint8_t *buf, struct es519xx_info *info)
209 int function, status;
211 function = 5 + ((info->packet_size == 14) ? 1 : 0);
212 status = function + 1;
215 if (info->alt_functions) {
216 info->is_sign = (buf[status] & (1 << 3)) != 0;
217 info->is_batt = (buf[status] & (1 << 2)) != 0; /* Bat. low */
218 info->is_ol = (buf[status] & (1 << 1)) != 0; /* Overflow */
219 info->is_ol |= (buf[status] & (1 << 0)) != 0; /* Overflow */
221 info->is_judge = (buf[status] & (1 << 3)) != 0;
222 info->is_sign = (buf[status] & (1 << 2)) != 0;
223 info->is_batt = (buf[status] & (1 << 1)) != 0; /* Bat. low */
224 info->is_ol = (buf[status] & (1 << 0)) != 0; /* Overflow */
227 if (info->packet_size == 14) {
229 info->is_max = (buf[8] & (1 << 3)) != 0;
230 info->is_min = (buf[8] & (1 << 2)) != 0;
231 info->is_rel = (buf[8] & (1 << 1)) != 0;
232 info->is_rmr = (buf[8] & (1 << 0)) != 0;
235 info->is_ul = (buf[9] & (1 << 3)) != 0; /* Underflow */
236 info->is_pmax = (buf[9] & (1 << 2)) != 0; /* Max. peak value */
237 info->is_pmin = (buf[9] & (1 << 1)) != 0; /* Min. peak value */
240 info->is_dc = (buf[10] & (1 << 3)) != 0;
241 info->is_ac = (buf[10] & (1 << 2)) != 0;
242 info->is_auto = (buf[10] & (1 << 1)) != 0;
243 info->is_vahz = (buf[10] & (1 << 0)) != 0;
245 /* LPF: Low-pass filter(s) */
246 if (info->selectable_lpf) {
248 info->is_hold = (buf[11] & (1 << 3)) != 0;
249 info->is_vbar = (buf[11] & (1 << 2)) != 0;
250 info->is_lpf1 = (buf[11] & (1 << 1)) != 0;
251 info->is_lpf0 = (buf[11] & (1 << 0)) != 0;
254 info->is_vbar = (buf[11] & (1 << 2)) != 0;
255 info->is_hold = (buf[11] & (1 << 1)) != 0;
256 info->is_lpf1 = (buf[11] & (1 << 0)) != 0;
258 } else if (info->alt_functions) {
260 info->is_dc = (buf[8] & (1 << 3)) != 0;
261 info->is_auto = (buf[8] & (1 << 2)) != 0;
262 info->is_apo = (buf[8] & (1 << 0)) != 0;
263 info->is_ac = !info->is_dc;
266 if (info->baudrate == 2400) {
267 info->is_pmax = (buf[7] & (1 << 3)) != 0;
268 info->is_pmin = (buf[7] & (1 << 2)) != 0;
269 info->is_vahz = (buf[7] & (1 << 0)) != 0;
270 } else if (info->fivedigits) {
271 info->is_ul = (buf[7] & (1 << 3)) != 0;
272 info->is_pmax = (buf[7] & (1 << 2)) != 0;
273 info->is_pmin = (buf[7] & (1 << 1)) != 0;
274 info->is_digit4 = (buf[7] & (1 << 0)) != 0;
275 } else if (info->clampmeter) {
276 info->is_ul = (buf[7] & (1 << 3)) != 0;
277 info->is_vasel = (buf[7] & (1 << 2)) != 0;
278 info->is_vbar = (buf[7] & (1 << 1)) != 0;
280 info->is_hold = (buf[7] & (1 << 3)) != 0;
281 info->is_max = (buf[7] & (1 << 2)) != 0;
282 info->is_min = (buf[7] & (1 << 1)) != 0;
286 info->is_dc = (buf[8] & (1 << 3)) != 0;
287 info->is_ac = (buf[8] & (1 << 2)) != 0;
288 info->is_auto = (buf[8] & (1 << 1)) != 0;
289 if (info->baudrate == 2400)
290 info->is_apo = (buf[8] & (1 << 0)) != 0;
292 info->is_vahz = (buf[8] & (1 << 0)) != 0;
296 if (info->alt_functions) {
297 switch (buf[function]) {
299 info->is_current = info->is_auto = TRUE;
302 info->is_current = info->is_micro = info->is_auto = TRUE;
305 info->is_current = info->is_milli = info->is_auto = TRUE;
308 info->is_voltage = TRUE;
310 case 0x37: /* Resistance */
311 info->is_resistance = TRUE;
313 case 0x36: /* Continuity */
314 info->is_continuity = TRUE;
316 case 0x3b: /* Diode */
317 info->is_diode = TRUE;
319 case 0x3a: /* Frequency */
320 info->is_frequency = TRUE;
322 case 0x34: /* ADP0 */
323 case 0x35: /* ADP0 */
324 info->is_adp0 = TRUE;
326 case 0x38: /* ADP1 */
327 case 0x39: /* ADP1 */
328 info->is_adp1 = TRUE;
330 case 0x32: /* ADP2 */
331 case 0x33: /* ADP2 */
332 info->is_adp2 = TRUE;
334 case 0x30: /* ADP3 */
335 case 0x31: /* ADP3 */
336 info->is_adp3 = TRUE;
339 sr_dbg("Invalid function byte: 0x%02x.", buf[function]);
343 /* Note: Some of these mappings are fixed up later. */
344 switch (buf[function]) {
346 info->is_voltage = TRUE;
349 info->is_current = info->is_micro = info->is_auto = TRUE;
352 info->is_current = info->is_milli = info->is_auto = TRUE;
355 info->is_current = info->is_auto = TRUE;
357 case 0x39: /* Manual A */
358 info->is_current = TRUE;
359 info->is_auto = FALSE; /* Manual mode */
361 case 0x33: /* Resistance */
362 info->is_resistance = TRUE;
364 case 0x35: /* Continuity */
365 info->is_continuity = TRUE;
367 case 0x31: /* Diode */
368 info->is_diode = TRUE;
370 case 0x32: /* Frequency / RPM / duty cycle */
371 if (info->packet_size == 14) {
373 info->is_duty_cycle = TRUE;
375 info->is_frequency = TRUE;
380 info->is_frequency = TRUE;
383 case 0x36: /* Capacitance */
384 info->is_capacitance = TRUE;
386 case 0x34: /* Temperature */
387 info->is_temperature = TRUE;
389 info->is_celsius = TRUE;
391 info->is_fahrenheit = TRUE;
392 /* IMPORTANT: The digits always represent Celsius! */
394 case 0x3e: /* ADP0 */
395 info->is_adp0 = TRUE;
397 case 0x3c: /* ADP1 */
398 info->is_adp1 = TRUE;
400 case 0x38: /* ADP2 */
401 info->is_adp2 = TRUE;
403 case 0x3a: /* ADP3 */
404 info->is_adp3 = TRUE;
407 sr_dbg("Invalid function byte: 0x%02x.", buf[function]);
412 if (info->is_vahz && (info->is_voltage || info->is_current)) {
413 info->is_voltage = FALSE;
414 info->is_current = FALSE;
415 info->is_milli = info->is_micro = FALSE;
416 if (info->packet_size == 14) {
418 info->is_duty_cycle = TRUE;
420 info->is_frequency = TRUE;
425 info->is_frequency = TRUE;
429 if (info->is_current && (info->is_micro || info->is_milli) && info->is_vasel) {
430 info->is_current = info->is_auto = FALSE;
431 info->is_voltage = TRUE;
434 if (info->baudrate == 2400) {
435 /* Inverted mapping between mA and A, and no manual A. */
436 if (info->is_current && (info->is_milli || !info->is_auto)) {
437 info->is_milli = !info->is_milli;
438 info->is_auto = TRUE;
443 static void handle_flags(struct sr_datafeed_analog *analog,
444 float *floatval, const struct es519xx_info *info)
447 * Note: is_micro etc. are not used directly to multiply/divide
448 * floatval, this is handled via parse_range() and exponents[][].
451 /* Measurement modes */
452 if (info->is_voltage) {
453 analog->meaning->mq = SR_MQ_VOLTAGE;
454 analog->meaning->unit = SR_UNIT_VOLT;
456 if (info->is_current) {
457 analog->meaning->mq = SR_MQ_CURRENT;
458 analog->meaning->unit = SR_UNIT_AMPERE;
460 if (info->is_resistance) {
461 analog->meaning->mq = SR_MQ_RESISTANCE;
462 analog->meaning->unit = SR_UNIT_OHM;
464 if (info->is_frequency) {
465 analog->meaning->mq = SR_MQ_FREQUENCY;
466 analog->meaning->unit = SR_UNIT_HERTZ;
468 if (info->is_capacitance) {
469 analog->meaning->mq = SR_MQ_CAPACITANCE;
470 analog->meaning->unit = SR_UNIT_FARAD;
472 if (info->is_temperature && info->is_celsius) {
473 analog->meaning->mq = SR_MQ_TEMPERATURE;
474 analog->meaning->unit = SR_UNIT_CELSIUS;
476 if (info->is_temperature && info->is_fahrenheit) {
477 analog->meaning->mq = SR_MQ_TEMPERATURE;
478 analog->meaning->unit = SR_UNIT_FAHRENHEIT;
480 if (info->is_continuity) {
481 analog->meaning->mq = SR_MQ_CONTINUITY;
482 analog->meaning->unit = SR_UNIT_BOOLEAN;
483 *floatval = (*floatval < 0.0 || *floatval > 25.0) ? 0.0 : 1.0;
485 if (info->is_diode) {
486 analog->meaning->mq = SR_MQ_VOLTAGE;
487 analog->meaning->unit = SR_UNIT_VOLT;
490 analog->meaning->mq = SR_MQ_FREQUENCY;
491 analog->meaning->unit = SR_UNIT_REVOLUTIONS_PER_MINUTE;
493 if (info->is_duty_cycle) {
494 analog->meaning->mq = SR_MQ_DUTY_CYCLE;
495 analog->meaning->unit = SR_UNIT_PERCENTAGE;
498 /* Measurement related flags */
500 analog->meaning->mqflags |= SR_MQFLAG_AC;
502 analog->meaning->mqflags |= SR_MQFLAG_DC;
504 analog->meaning->mqflags |= SR_MQFLAG_AUTORANGE;
506 analog->meaning->mqflags |= SR_MQFLAG_DIODE;
509 * Note: HOLD only affects the number displayed on the LCD,
510 * but not the value sent via the protocol! It also does not
511 * affect the bargraph on the LCD.
513 analog->meaning->mqflags |= SR_MQFLAG_HOLD;
515 analog->meaning->mqflags |= SR_MQFLAG_MAX;
517 analog->meaning->mqflags |= SR_MQFLAG_MIN;
519 analog->meaning->mqflags |= SR_MQFLAG_RELATIVE;
523 sr_spew("Judge bit is set.");
525 sr_spew("Battery is low.");
527 sr_spew("Input overflow.");
529 sr_spew("Input underflow.");
531 sr_spew("pMAX active, LCD shows max. peak value.");
533 sr_spew("pMIN active, LCD shows min. peak value.");
535 sr_spew("VAHZ active.");
537 sr_spew("Auto-Power-Off enabled.");
539 sr_spew("VBAR active.");
540 if ((!info->selectable_lpf && info->is_lpf1) ||
541 (info->selectable_lpf && (!info->is_lpf0 || !info->is_lpf1)))
542 sr_spew("Low-pass filter feature is active.");
545 static gboolean flags_valid(const struct es519xx_info *info)
549 /* Does the packet have more than one multiplier? */
550 count = (info->is_micro) ? 1 : 0;
551 count += (info->is_milli) ? 1 : 0;
553 sr_dbg("More than one multiplier detected in packet.");
557 /* Does the packet "measure" more than one type of value? */
558 count = (info->is_voltage) ? 1 : 0;
559 count += (info->is_current) ? 1 : 0;
560 count += (info->is_resistance) ? 1 : 0;
561 count += (info->is_frequency) ? 1 : 0;
562 count += (info->is_capacitance) ? 1 : 0;
563 count += (info->is_temperature) ? 1 : 0;
564 count += (info->is_continuity) ? 1 : 0;
565 count += (info->is_diode) ? 1 : 0;
566 count += (info->is_rpm) ? 1 : 0;
568 sr_dbg("More than one measurement type detected in packet.");
572 /* Both AC and DC set? */
573 if (info->is_ac && info->is_dc) {
574 sr_dbg("Both AC and DC flags detected in packet.");
581 static gboolean sr_es519xx_packet_valid(const uint8_t *buf,
582 struct es519xx_info *info)
586 s = info->packet_size;
588 if (s == 11 && memcmp(buf, buf + s, s))
591 if (buf[s - 2] != '\r' || buf[s - 1] != '\n')
594 parse_flags(buf, info);
596 if (!flags_valid(info))
602 static int sr_es519xx_parse(const uint8_t *buf, float *floatval,
603 struct sr_datafeed_analog *analog,
604 struct es519xx_info *info)
608 if (!sr_es519xx_packet_valid(buf, info))
611 if ((ret = parse_value(buf, info, floatval)) != SR_OK) {
612 sr_dbg("Error parsing value: %d.", ret);
616 if ((ret = parse_range(buf[0], floatval, info)) != SR_OK)
619 analog->encoding->digits = info->digits;
620 analog->spec->spec_digits = info->digits;
622 handle_flags(analog, floatval, info);
627 * Functions for 2400 baud / 11 bytes protocols.
628 * This includes ES51962, ES51971, ES51972, ES51978 and ES51989.
630 SR_PRIV gboolean sr_es519xx_2400_11b_packet_valid(const uint8_t *buf)
632 struct es519xx_info info;
634 memset(&info, 0, sizeof(struct es519xx_info));
635 info.baudrate = 2400;
636 info.packet_size = 11;
638 return sr_es519xx_packet_valid(buf, &info);
641 SR_PRIV int sr_es519xx_2400_11b_parse(const uint8_t *buf, float *floatval,
642 struct sr_datafeed_analog *analog, void *info)
644 struct es519xx_info *info_local;
647 memset(info_local, 0, sizeof(struct es519xx_info));
648 info_local->baudrate = 2400;
649 info_local->packet_size = 11;
651 return sr_es519xx_parse(buf, floatval, analog, info);
655 * Functions for 2400 baud / 11 byte protocols.
656 * This includes ES51960, ES51977 and ES51988.
658 SR_PRIV gboolean sr_es519xx_2400_11b_altfn_packet_valid(const uint8_t *buf)
660 struct es519xx_info info;
662 memset(&info, 0, sizeof(struct es519xx_info));
663 info.baudrate = 2400;
664 info.packet_size = 11;
665 info.alt_functions = TRUE;
667 return sr_es519xx_packet_valid(buf, &info);
670 SR_PRIV int sr_es519xx_2400_11b_altfn_parse(const uint8_t *buf,
671 float *floatval, struct sr_datafeed_analog *analog, void *info)
673 struct es519xx_info *info_local;
676 memset(info_local, 0, sizeof(struct es519xx_info));
677 info_local->baudrate = 2400;
678 info_local->packet_size = 11;
679 info_local->alt_functions = TRUE;
681 return sr_es519xx_parse(buf, floatval, analog, info);
685 * Functions for 19200 baud / 11 bytes protocols with 5 digits display.
686 * This includes ES51911, ES51916 and ES51918.
688 SR_PRIV gboolean sr_es519xx_19200_11b_5digits_packet_valid(const uint8_t *buf)
690 struct es519xx_info info;
692 memset(&info, 0, sizeof(struct es519xx_info));
693 info.baudrate = 19200;
694 info.packet_size = 11;
695 info.fivedigits = TRUE;
697 return sr_es519xx_packet_valid(buf, &info);
700 SR_PRIV int sr_es519xx_19200_11b_5digits_parse(const uint8_t *buf,
701 float *floatval, struct sr_datafeed_analog *analog, void *info)
703 struct es519xx_info *info_local;
706 memset(info_local, 0, sizeof(struct es519xx_info));
707 info_local->baudrate = 19200;
708 info_local->packet_size = 11;
709 info_local->fivedigits = TRUE;
711 return sr_es519xx_parse(buf, floatval, analog, info);
715 * Functions for 19200 baud / 11 bytes protocols with clamp meter support.
716 * This includes ES51967 and ES51969.
718 SR_PRIV gboolean sr_es519xx_19200_11b_clamp_packet_valid(const uint8_t *buf)
720 struct es519xx_info info;
722 memset(&info, 0, sizeof(struct es519xx_info));
723 info.baudrate = 19200;
724 info.packet_size = 11;
725 info.clampmeter = TRUE;
727 return sr_es519xx_packet_valid(buf, &info);
730 SR_PRIV int sr_es519xx_19200_11b_clamp_parse(const uint8_t *buf,
731 float *floatval, struct sr_datafeed_analog *analog, void *info)
733 struct es519xx_info *info_local;
736 memset(info_local, 0, sizeof(struct es519xx_info));
737 info_local->baudrate = 19200;
738 info_local->packet_size = 11;
739 info_local->clampmeter = TRUE;
741 return sr_es519xx_parse(buf, floatval, analog, info);
745 * Functions for 19200 baud / 11 bytes protocols.
746 * This includes ES51981, ES51982, ES51983, ES51984 and ES51986.
748 SR_PRIV gboolean sr_es519xx_19200_11b_packet_valid(const uint8_t *buf)
750 struct es519xx_info info;
752 memset(&info, 0, sizeof(struct es519xx_info));
753 info.baudrate = 19200;
754 info.packet_size = 11;
756 return sr_es519xx_packet_valid(buf, &info);
759 SR_PRIV int sr_es519xx_19200_11b_parse(const uint8_t *buf, float *floatval,
760 struct sr_datafeed_analog *analog, void *info)
762 struct es519xx_info *info_local;
765 memset(info_local, 0, sizeof(struct es519xx_info));
766 info_local->baudrate = 19200;
767 info_local->packet_size = 11;
769 return sr_es519xx_parse(buf, floatval, analog, info);
773 * Functions for 19200 baud / 14 bytes protocols.
774 * This includes ES51921 and ES51922.
776 SR_PRIV gboolean sr_es519xx_19200_14b_packet_valid(const uint8_t *buf)
778 struct es519xx_info info;
780 memset(&info, 0, sizeof(struct es519xx_info));
781 info.baudrate = 19200;
782 info.packet_size = 14;
784 return sr_es519xx_packet_valid(buf, &info);
787 SR_PRIV int sr_es519xx_19200_14b_parse(const uint8_t *buf, float *floatval,
788 struct sr_datafeed_analog *analog, void *info)
790 struct es519xx_info *info_local;
793 memset(info_local, 0, sizeof(struct es519xx_info));
794 info_local->baudrate = 19200;
795 info_local->packet_size = 14;
797 return sr_es519xx_parse(buf, floatval, analog, info);
801 * Functions for 19200 baud / 14 bytes protocols with selectable LPF.
802 * This includes ES51931 and ES51932.
804 SR_PRIV gboolean sr_es519xx_19200_14b_sel_lpf_packet_valid(const uint8_t *buf)
806 struct es519xx_info info;
808 memset(&info, 0, sizeof(struct es519xx_info));
809 info.baudrate = 19200;
810 info.packet_size = 14;
811 info.selectable_lpf = TRUE;
813 return sr_es519xx_packet_valid(buf, &info);
816 SR_PRIV int sr_es519xx_19200_14b_sel_lpf_parse(const uint8_t *buf,
817 float *floatval, struct sr_datafeed_analog *analog, void *info)
819 struct es519xx_info *info_local;
822 memset(info_local, 0, sizeof(struct es519xx_info));
823 info_local->baudrate = 19200;
824 info_local->packet_size = 14;
825 info_local->selectable_lpf = TRUE;
827 return sr_es519xx_parse(buf, floatval, analog, info);