X-Git-Url: http://git.rot13.org/?p=air-quality;a=blobdiff_plain;f=mh-z19b.pl;h=c2f8ffe302d16299fc7f41fb5292719af320a764;hp=c925661d169c5646ddc90c60ef6ab215d3c412d5;hb=bcefa9e3896d896801b4361aa7a03c17eae60ad3;hpb=395e7f06a7d973f3dd808ca87676dde1a3f5246a diff --git a/mh-z19b.pl b/mh-z19b.pl index c925661..c2f8ffe 100755 --- a/mh-z19b.pl +++ b/mh-z19b.pl @@ -6,7 +6,7 @@ use Device::SerialPort; use Time::HiRes; use Data::Dump qw(dump); -my $port = shift @ARGV || '/dev/ttyUSB0'; +my $port = shift @ARGV || '/dev/serial/by-path/pci-0000:00:1a.7-usb-0:5.3.4:1.2'; 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 +16,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); @@ -29,7 +29,9 @@ while (1) { die $! if ! defined($len); if ( $len > 0 ) { my @v = unpack('C*', $string); - #warn "# $len ",dump($string), dump( @v ), $/; + if ( $#v < 8 ) { + die "# $len ",dump($string), dump( @v ), $/; + } my $sum = 0; foreach my $i ( 1 .. $#v - 1 ) {