From: Dobrica Pavlinusic Date: Sat, 8 Feb 2020 14:09:52 +0000 (+0100) Subject: die on invalid data X-Git-Url: http://git.rot13.org/?p=air-quality;a=commitdiff_plain;h=14271635ea185cf8075b9d5335cdd137725bcfd5 die on invalid data --- diff --git a/mh-z19b.pl b/mh-z19b.pl index 0c3fbd1..94abb05 100755 --- a/mh-z19b.pl +++ b/mh-z19b.pl @@ -7,6 +7,7 @@ use Time::HiRes; use Data::Dump qw(dump); my $port = shift @ARGV || '/dev/ttyUSB0'; +$port = '/dev/ttyUSB5'; my $influx_url = shift @ARGV || 'http://10.13.37.229:8186/write?db=telegraf'; $influx_url = 'http://10.13.37.92:8086/write?db=rot13'; @@ -16,7 +17,7 @@ $s->databits(8); $s->parity('none'); $s->stopbits(1); $s->handshake('none'); -$s->read_char_time(0); +$s->read_char_time(1); $s->read_const_time(10); $s->debug(1); @@ -30,8 +31,7 @@ while (1) { if ( $len > 0 ) { my @v = unpack('C*', $string); if ( $#v < 8 ) { - warn "# $len ",dump($string), dump( @v ), $/; - next; + die "# $len ",dump($string), dump( @v ), $/; } my $sum = 0;