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 #define LOG_PREFIX "es519xx"
37 /* Factors for the respective measurement mode (0 means "invalid"). */
38 static const float factors_2400_11b[8][8] = {
39 {1e-4, 1e-3, 1e-2, 1e-1, 1, 0, 0, 0 }, /* V */
40 {1e-7, 1e-6, 0, 0, 0, 0, 0, 0 }, /* uA */
41 {1e-5, 1e-4, 0, 0, 0, 0, 0, 0 }, /* mA */
42 {1e-2, 0, 0, 0, 0, 0, 0, 0 }, /* A */
43 {1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 0, 0 }, /* RPM */
44 {1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0, 0 }, /* Resistance */
45 {1, 1e1, 1e2, 1e3, 1e4, 1e5, 0, 0 }, /* Frequency */
46 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
48 static const float factors_19200_11b_5digits[8][8] = {
49 {1e-4, 1e-3, 1e-2, 1e-1, 1e-5, 0, 0, 0}, /* V */
50 {1e-8, 1e-7, 0, 0, 0, 0, 0, 0}, /* uA */
51 {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* mA */
52 {0, 1e-3, 0, 0, 0, 0, 0, 0}, /* A */
53 {1e-4, 1e-3, 1e-2, 1e-1, 1, 0, 0, 0}, /* Manual A */
54 {1e-2, 1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Resistance */
55 {1e-1, 0, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Frequency */
56 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
58 static const float factors_19200_11b_clampmeter[8][8] = {
59 {1e-3, 1e-2, 1e-1, 1, 1e-4, 0, 0, 0}, /* V */
60 {1e-7, 1e-6, 0, 0, 0, 0, 0, 0}, /* uA */
61 {1e-5, 1e-4, 0, 0, 0, 0, 0, 0}, /* mA */
62 {1e-2, 0, 0, 0, 0, 0, 0, 0}, /* A */
63 {1e-3, 1e-2, 1e-1, 1, 0, 0, 0, 0}, /* Manual A */
64 {1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0, 0}, /* Resistance */
65 {1e-1, 0, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Frequency */
66 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
68 static const float factors_19200_11b[8][8] = {
69 {1e-3, 1e-2, 1e-1, 1, 1e-4, 0, 0, 0}, /* V */
70 {1e-7, 1e-6, 0, 0, 0, 0, 0, 0}, /* uA */
71 {1e-5, 1e-4, 0, 0, 0, 0, 0, 0}, /* mA */
72 {1e-3, 1e-2, 0, 0, 0, 0, 0, 0}, /* A */
73 {0, 0, 0, 0, 0, 0, 0, 0}, /* Manual A */
74 {1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0, 0}, /* Resistance */
75 {1, 1e1, 1e2, 1e3, 1e4, 0, 0, 0}, /* Frequency */
76 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 0}, /* Capacitance */
78 static const float factors_19200_14b[8][8] = {
79 {1e-4, 1e-3, 1e-2, 1e-1, 1e-5, 0, 0, 0}, /* V */
80 {1e-8, 1e-7, 0, 0, 0, 0, 0, 0}, /* uA */
81 {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* mA */
82 {1e-3, 0, 0, 0, 0, 0, 0, 0}, /* A */
83 {1e-4, 1e-3, 1e-2, 1e-1, 1, 0, 0, 0}, /* Manual A */
84 {1e-2, 1e-1, 1, 1e1, 1e2, 1e3, 1e4, 0}, /* Resistance */
85 {1e-2, 1e-1, 0, 1, 1e1, 1e2, 1e3, 1e4}, /* Frequency */
86 {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5}, /* Capacitance */
89 static int parse_value(const uint8_t *buf, struct es519xx_info *info,
92 int i, intval, num_digits;
95 num_digits = 4 + ((info->packet_size == 14) ? 1 : 0);
97 /* Bytes 1-4 (or 5): Value (4 or 5 decimal digits) */
99 sr_spew("Over limit.");
102 } else if (info->is_ul) {
103 sr_spew("Under limit.");
106 } else if (!isdigit(buf[1]) || !isdigit(buf[2]) ||
107 !isdigit(buf[3]) || !isdigit(buf[4]) ||
108 (num_digits == 5 && !isdigit(buf[5]))) {
109 sr_err("Value contained invalid digits: %02x %02x %02x %02x "
110 "(%c %c %c %c).", buf[1], buf[2], buf[3], buf[4],
111 buf[1], buf[2], buf[3], buf[4]);
114 intval = (info->is_digit4) ? 1 : 0;
115 for (i = 0; i < num_digits; i++)
116 intval = 10 * intval + (buf[i + 1] - '0');
119 intval *= info->is_sign ? -1 : 1;
121 floatval = (float)intval;
123 /* Note: The decimal point position will be parsed later. */
125 sr_spew("The display value is %f.", floatval);
132 static int parse_range(uint8_t b, float *floatval,
133 const struct es519xx_info *info)
140 if (idx < 0 || idx > 7) {
141 sr_dbg("Invalid range byte / index: 0x%02x / 0x%02x.", b, idx);
145 /* Parse range byte (depends on the measurement mode). */
146 if (info->is_voltage)
148 else if (info->is_current && info->is_micro)
150 else if (info->is_current && info->is_milli)
152 else if (info->is_current && info->is_auto)
154 else if (info->is_current && !info->is_auto)
155 mode = 4; /* Manual A */
156 else if (info->is_rpm)
157 /* Not a typo, it's really index 4 in factors_2400_11b[][]. */
159 else if (info->is_resistance || info->is_continuity)
160 mode = 5; /* Resistance */
161 else if (info->is_frequency)
162 mode = 6; /* Frequency */
163 else if (info->is_capacitance)
164 mode = 7; /* Capacitance */
166 sr_dbg("Invalid mode, range byte was: 0x%02x.", b);
172 factor = (const float[]){1e-1, 1}[idx];
173 else if (info->is_milli)
174 factor = (const float[]){1e-2, 1e-1}[idx];
176 else if (info->baudrate == 2400)
177 factor = factors_2400_11b[mode][idx];
178 else if (info->fivedigits)
179 factor = factors_19200_11b_5digits[mode][idx];
180 else if (info->clampmeter)
181 factor = factors_19200_11b_clampmeter[mode][idx];
182 else if (info->packet_size == 11)
183 factor = factors_19200_11b[mode][idx];
184 else if (info->packet_size == 14)
185 factor = factors_19200_14b[mode][idx];
188 sr_dbg("Invalid factor for range byte: 0x%02x.", b);
192 /* Apply respective factor (mode-dependent) on the value. */
194 sr_dbg("Applying factor %f, new value is %f.", factor, *floatval);
199 static void parse_flags(const uint8_t *buf, struct es519xx_info *info)
201 int function, status;
203 function = 5 + ((info->packet_size == 14) ? 1 : 0);
204 status = function + 1;
207 if (info->alt_functions) {
208 info->is_sign = (buf[status] & (1 << 3)) != 0;
209 info->is_batt = (buf[status] & (1 << 2)) != 0; /* Bat. low */
210 info->is_ol = (buf[status] & (1 << 1)) != 0; /* Overflow */
211 info->is_ol |= (buf[status] & (1 << 0)) != 0; /* Overflow */
213 info->is_judge = (buf[status] & (1 << 3)) != 0;
214 info->is_sign = (buf[status] & (1 << 2)) != 0;
215 info->is_batt = (buf[status] & (1 << 1)) != 0; /* Bat. low */
216 info->is_ol = (buf[status] & (1 << 0)) != 0; /* Overflow */
219 if (info->packet_size == 14) {
221 info->is_max = (buf[8] & (1 << 3)) != 0;
222 info->is_min = (buf[8] & (1 << 2)) != 0;
223 info->is_rel = (buf[8] & (1 << 1)) != 0;
224 info->is_rmr = (buf[8] & (1 << 0)) != 0;
227 info->is_ul = (buf[9] & (1 << 3)) != 0; /* Underflow */
228 info->is_pmax = (buf[9] & (1 << 2)) != 0; /* Max. peak value */
229 info->is_pmin = (buf[9] & (1 << 1)) != 0; /* Min. peak value */
232 info->is_dc = (buf[10] & (1 << 3)) != 0;
233 info->is_ac = (buf[10] & (1 << 2)) != 0;
234 info->is_auto = (buf[10] & (1 << 1)) != 0;
235 info->is_vahz = (buf[10] & (1 << 0)) != 0;
237 /* LPF: Low-pass filter(s) */
238 if (info->selectable_lpf) {
240 info->is_hold = (buf[11] & (1 << 3)) != 0;
241 info->is_vbar = (buf[11] & (1 << 2)) != 0;
242 info->is_lpf1 = (buf[11] & (1 << 1)) != 0;
243 info->is_lpf0 = (buf[11] & (1 << 0)) != 0;
246 info->is_vbar = (buf[11] & (1 << 2)) != 0;
247 info->is_hold = (buf[11] & (1 << 1)) != 0;
248 info->is_lpf1 = (buf[11] & (1 << 0)) != 0;
250 } else if (info->alt_functions) {
252 info->is_dc = (buf[8] & (1 << 3)) != 0;
253 info->is_auto = (buf[8] & (1 << 2)) != 0;
254 info->is_apo = (buf[8] & (1 << 0)) != 0;
255 info->is_ac = !info->is_dc;
258 if (info->baudrate == 2400) {
259 info->is_pmax = (buf[7] & (1 << 3)) != 0;
260 info->is_pmin = (buf[7] & (1 << 2)) != 0;
261 info->is_vahz = (buf[7] & (1 << 0)) != 0;
262 } else if (info->fivedigits) {
263 info->is_ul = (buf[7] & (1 << 3)) != 0;
264 info->is_pmax = (buf[7] & (1 << 2)) != 0;
265 info->is_pmin = (buf[7] & (1 << 1)) != 0;
266 info->is_digit4 = (buf[7] & (1 << 0)) != 0;
267 } else if (info->clampmeter) {
268 info->is_ul = (buf[7] & (1 << 3)) != 0;
269 info->is_vasel = (buf[7] & (1 << 2)) != 0;
270 info->is_vbar = (buf[7] & (1 << 1)) != 0;
272 info->is_hold = (buf[7] & (1 << 3)) != 0;
273 info->is_max = (buf[7] & (1 << 2)) != 0;
274 info->is_min = (buf[7] & (1 << 1)) != 0;
278 info->is_dc = (buf[8] & (1 << 3)) != 0;
279 info->is_ac = (buf[8] & (1 << 2)) != 0;
280 info->is_auto = (buf[8] & (1 << 1)) != 0;
281 if (info->baudrate == 2400)
282 info->is_apo = (buf[8] & (1 << 0)) != 0;
284 info->is_vahz = (buf[8] & (1 << 0)) != 0;
288 if (info->alt_functions) {
289 switch (buf[function]) {
291 info->is_current = info->is_auto = TRUE;
294 info->is_current = info->is_micro = info->is_auto = TRUE;
297 info->is_current = info->is_milli = info->is_auto = TRUE;
300 info->is_voltage = TRUE;
302 case 0x37: /* Resistance */
303 info->is_resistance = TRUE;
305 case 0x36: /* Continuity */
306 info->is_continuity = TRUE;
308 case 0x3b: /* Diode */
309 info->is_diode = TRUE;
311 case 0x3a: /* Frequency */
312 info->is_frequency = TRUE;
314 case 0x34: /* ADP0 */
315 case 0x35: /* ADP0 */
316 info->is_adp0 = TRUE;
318 case 0x38: /* ADP1 */
319 case 0x39: /* ADP1 */
320 info->is_adp1 = TRUE;
322 case 0x32: /* ADP2 */
323 case 0x33: /* ADP2 */
324 info->is_adp2 = TRUE;
326 case 0x30: /* ADP3 */
327 case 0x31: /* ADP3 */
328 info->is_adp3 = TRUE;
331 sr_err("Invalid function byte: 0x%02x.", buf[function]);
335 /* Note: Some of these mappings are fixed up later. */
336 switch (buf[function]) {
338 info->is_voltage = TRUE;
341 info->is_current = info->is_micro = info->is_auto = TRUE;
344 info->is_current = info->is_milli = info->is_auto = TRUE;
347 info->is_current = info->is_auto = TRUE;
349 case 0x39: /* Manual A */
350 info->is_current = TRUE;
351 info->is_auto = FALSE; /* Manual mode */
353 case 0x33: /* Resistance */
354 info->is_resistance = TRUE;
356 case 0x35: /* Continuity */
357 info->is_continuity = TRUE;
359 case 0x31: /* Diode */
360 info->is_diode = TRUE;
362 case 0x32: /* Frequency / RPM / duty cycle */
363 if (info->packet_size == 14) {
365 info->is_frequency = TRUE;
367 info->is_duty_cycle = TRUE;
372 info->is_frequency = TRUE;
375 case 0x36: /* Capacitance */
376 info->is_capacitance = TRUE;
378 case 0x34: /* Temperature */
379 info->is_temperature = TRUE;
381 info->is_celsius = TRUE;
383 info->is_fahrenheit = TRUE;
384 /* IMPORTANT: The digits always represent Celsius! */
386 case 0x3e: /* ADP0 */
387 info->is_adp0 = TRUE;
389 case 0x3c: /* ADP1 */
390 info->is_adp1 = TRUE;
392 case 0x38: /* ADP2 */
393 info->is_adp2 = TRUE;
395 case 0x3a: /* ADP3 */
396 info->is_adp3 = TRUE;
399 sr_err("Invalid function byte: 0x%02x.", buf[function]);
404 if (info->is_current && (info->is_micro || info->is_milli) && info->is_vasel) {
405 info->is_current = info->is_auto = FALSE;
406 info->is_voltage = TRUE;
409 if (info->baudrate == 2400) {
410 /* Inverted mapping between mA and A, and no manual A. */
411 if (info->is_current && (info->is_milli || !info->is_auto)) {
412 info->is_milli = !info->is_milli;
413 info->is_auto = TRUE;
418 static void handle_flags(struct sr_datafeed_analog *analog,
419 float *floatval, const struct es519xx_info *info)
422 * Note: is_micro etc. are not used directly to multiply/divide
423 * floatval, this is handled via parse_range() and factors[][].
426 /* Measurement modes */
427 if (info->is_voltage) {
428 analog->mq = SR_MQ_VOLTAGE;
429 analog->unit = SR_UNIT_VOLT;
431 if (info->is_current) {
432 analog->mq = SR_MQ_CURRENT;
433 analog->unit = SR_UNIT_AMPERE;
435 if (info->is_resistance) {
436 analog->mq = SR_MQ_RESISTANCE;
437 analog->unit = SR_UNIT_OHM;
439 if (info->is_frequency) {
440 analog->mq = SR_MQ_FREQUENCY;
441 analog->unit = SR_UNIT_HERTZ;
443 if (info->is_capacitance) {
444 analog->mq = SR_MQ_CAPACITANCE;
445 analog->unit = SR_UNIT_FARAD;
447 if (info->is_temperature && info->is_celsius) {
448 analog->mq = SR_MQ_TEMPERATURE;
449 analog->unit = SR_UNIT_CELSIUS;
451 if (info->is_temperature && info->is_fahrenheit) {
452 analog->mq = SR_MQ_TEMPERATURE;
453 analog->unit = SR_UNIT_FAHRENHEIT;
455 if (info->is_continuity) {
456 analog->mq = SR_MQ_CONTINUITY;
457 analog->unit = SR_UNIT_BOOLEAN;
458 *floatval = (*floatval < 0.0 || *floatval > 25.0) ? 0.0 : 1.0;
460 if (info->is_diode) {
461 analog->mq = SR_MQ_VOLTAGE;
462 analog->unit = SR_UNIT_VOLT;
465 analog->mq = SR_MQ_FREQUENCY;
466 analog->unit = SR_UNIT_REVOLUTIONS_PER_MINUTE;
468 if (info->is_duty_cycle) {
469 analog->mq = SR_MQ_DUTY_CYCLE;
470 analog->unit = SR_UNIT_PERCENTAGE;
473 /* Measurement related flags */
475 analog->mqflags |= SR_MQFLAG_AC;
477 analog->mqflags |= SR_MQFLAG_DC;
479 analog->mqflags |= SR_MQFLAG_AUTORANGE;
481 analog->mqflags |= SR_MQFLAG_DIODE;
484 * Note: HOLD only affects the number displayed on the LCD,
485 * but not the value sent via the protocol! It also does not
486 * affect the bargraph on the LCD.
488 analog->mqflags |= SR_MQFLAG_HOLD;
490 analog->mqflags |= SR_MQFLAG_MAX;
492 analog->mqflags |= SR_MQFLAG_MIN;
494 analog->mqflags |= SR_MQFLAG_RELATIVE;
498 sr_spew("Judge bit is set.");
500 sr_spew("Battery is low.");
502 sr_spew("Input overflow.");
504 sr_spew("Input underflow.");
506 sr_spew("pMAX active, LCD shows max. peak value.");
508 sr_spew("pMIN active, LCD shows min. peak value.");
510 sr_spew("VAHZ active.");
512 sr_spew("Auto-Power-Off enabled.");
514 sr_spew("VBAR active.");
515 if ((!info->selectable_lpf && info->is_lpf1) ||
516 (info->selectable_lpf && (!info->is_lpf0 || !info->is_lpf1)))
517 sr_spew("Low-pass filter feature is active.");
520 static gboolean flags_valid(const struct es519xx_info *info)
524 /* Does the packet have more than one multiplier? */
525 count = (info->is_micro) ? 1 : 0;
526 count += (info->is_milli) ? 1 : 0;
528 sr_err("More than one multiplier detected in packet.");
532 /* Does the packet "measure" more than one type of value? */
533 count = (info->is_voltage) ? 1 : 0;
534 count += (info->is_current) ? 1 : 0;
535 count += (info->is_resistance) ? 1 : 0;
536 count += (info->is_frequency) ? 1 : 0;
537 count += (info->is_capacitance) ? 1 : 0;
538 count += (info->is_temperature) ? 1 : 0;
539 count += (info->is_continuity) ? 1 : 0;
540 count += (info->is_diode) ? 1 : 0;
541 count += (info->is_rpm) ? 1 : 0;
543 sr_err("More than one measurement type detected in packet.");
547 /* Both AC and DC set? */
548 if (info->is_ac && info->is_dc) {
549 sr_err("Both AC and DC flags detected in packet.");
556 static gboolean sr_es519xx_packet_valid(const uint8_t *buf,
557 struct es519xx_info *info)
561 s = info->packet_size;
563 if (s == 11 && memcmp(buf, buf + s, s))
566 if (buf[s - 2] != '\r' || buf[s - 1] != '\n')
569 parse_flags(buf, info);
571 if (!flags_valid(info))
577 static int sr_es519xx_parse(const uint8_t *buf, float *floatval,
578 struct sr_datafeed_analog *analog,
579 struct es519xx_info *info)
583 if (!sr_es519xx_packet_valid(buf, info))
586 if ((ret = parse_value(buf, info, floatval)) != SR_OK) {
587 sr_err("Error parsing value: %d.", ret);
591 if ((ret = parse_range(buf[0], floatval, info)) != SR_OK)
594 handle_flags(analog, floatval, info);
599 * Functions for 2400 baud / 11 bytes protocols.
600 * This includes ES51962, ES51971, ES51972, ES51978 and ES51989.
602 SR_PRIV gboolean sr_es519xx_2400_11b_packet_valid(const uint8_t *buf)
604 struct es519xx_info info = { 0 };
606 info.baudrate = 2400;
607 info.packet_size = 11;
609 return sr_es519xx_packet_valid(buf, &info);
612 SR_PRIV int sr_es519xx_2400_11b_parse(const uint8_t *buf, float *floatval,
613 struct sr_datafeed_analog *analog, void *info)
615 struct es519xx_info *info_local;
618 memset(info_local, 0, sizeof(struct es519xx_info));
619 info_local->baudrate = 2400;
620 info_local->packet_size = 11;
622 return sr_es519xx_parse(buf, floatval, analog, info);
626 * Functions for 2400 baud / 11 byte protocols.
627 * This includes ES51960, ES51977 and ES51988.
629 SR_PRIV gboolean sr_es519xx_2400_11b_altfn_packet_valid(const uint8_t *buf)
631 struct es519xx_info info = { 0 };
633 info.baudrate = 2400;
634 info.packet_size = 11;
635 info.alt_functions = TRUE;
637 return sr_es519xx_packet_valid(buf, &info);
640 SR_PRIV int sr_es519xx_2400_11b_altfn_parse(const uint8_t *buf,
641 float *floatval, struct sr_datafeed_analog *analog, void *info)
643 struct es519xx_info *info_local;
646 memset(info_local, 0, sizeof(struct es519xx_info));
647 info_local->baudrate = 2400;
648 info_local->packet_size = 11;
649 info_local->alt_functions = TRUE;
651 return sr_es519xx_parse(buf, floatval, analog, info);
655 * Functions for 19200 baud / 11 bytes protocols with 5 digits display.
656 * This includes ES51911, ES51916 and ES51918.
658 SR_PRIV gboolean sr_es519xx_19200_11b_5digits_packet_valid(const uint8_t *buf)
660 struct es519xx_info info = { 0 };
662 info.baudrate = 19200;
663 info.packet_size = 11;
664 info.fivedigits = TRUE;
666 return sr_es519xx_packet_valid(buf, &info);
669 SR_PRIV int sr_es519xx_19200_11b_5digits_parse(const uint8_t *buf,
670 float *floatval, struct sr_datafeed_analog *analog, void *info)
672 struct es519xx_info *info_local;
675 memset(info_local, 0, sizeof(struct es519xx_info));
676 info_local->baudrate = 19200;
677 info_local->packet_size = 11;
678 info_local->fivedigits = TRUE;
680 return sr_es519xx_parse(buf, floatval, analog, info);
684 * Functions for 19200 baud / 11 bytes protocols with clamp meter support.
685 * This includes ES51967 and ES51969.
687 SR_PRIV gboolean sr_es519xx_19200_11b_clamp_packet_valid(const uint8_t *buf)
689 struct es519xx_info info = { 0 };
691 info.baudrate = 19200;
692 info.packet_size = 11;
693 info.clampmeter = TRUE;
695 return sr_es519xx_packet_valid(buf, &info);
698 SR_PRIV int sr_es519xx_19200_11b_clamp_parse(const uint8_t *buf,
699 float *floatval, struct sr_datafeed_analog *analog, void *info)
701 struct es519xx_info *info_local;
704 memset(info_local, 0, sizeof(struct es519xx_info));
705 info_local->baudrate = 19200;
706 info_local->packet_size = 11;
707 info_local->clampmeter = TRUE;
709 return sr_es519xx_parse(buf, floatval, analog, info);
713 * Functions for 19200 baud / 11 bytes protocols.
714 * This includes ES51981, ES51982, ES51983, ES51984 and ES51986.
716 SR_PRIV gboolean sr_es519xx_19200_11b_packet_valid(const uint8_t *buf)
718 struct es519xx_info info = { 0 };
720 info.baudrate = 19200;
721 info.packet_size = 11;
723 return sr_es519xx_packet_valid(buf, &info);
726 SR_PRIV int sr_es519xx_19200_11b_parse(const uint8_t *buf, float *floatval,
727 struct sr_datafeed_analog *analog, void *info)
729 struct es519xx_info *info_local;
732 memset(info_local, 0, sizeof(struct es519xx_info));
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 = { 0 };
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 memset(info_local, 0, sizeof(struct es519xx_info));
760 info_local->baudrate = 19200;
761 info_local->packet_size = 14;
763 return sr_es519xx_parse(buf, floatval, analog, info);
767 * Functions for 19200 baud / 14 bytes protocols with selectable LPF.
768 * This includes ES51931 and ES51932.
770 SR_PRIV gboolean sr_es519xx_19200_14b_sel_lpf_packet_valid(const uint8_t *buf)
772 struct es519xx_info info = { 0 };
774 info.baudrate = 19200;
775 info.packet_size = 14;
776 info.selectable_lpf = TRUE;
778 return sr_es519xx_packet_valid(buf, &info);
781 SR_PRIV int sr_es519xx_19200_14b_sel_lpf_parse(const uint8_t *buf,
782 float *floatval, struct sr_datafeed_analog *analog, void *info)
784 struct es519xx_info *info_local;
787 memset(info_local, 0, sizeof(struct es519xx_info));
788 info_local->baudrate = 19200;
789 info_local->packet_size = 14;
790 info_local->selectable_lpf = TRUE;
792 return sr_es519xx_parse(buf, floatval, analog, info);