added consistency=any
[air-quality] / mh-z19b.pl
index 0c3fbd1..8edaa3f 100755 (executable)
@@ -6,9 +6,8 @@ use Device::SerialPort;
 use Time::HiRes;
 use Data::Dump qw(dump);
 
-my $port = shift @ARGV || '/dev/ttyUSB0';
-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';
+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.92:8086/write?consistency=any&db=rot13';
 
 my $s = new Device::SerialPort( $port ) || die $!;
 $s->baudrate(9600);
@@ -16,7 +15,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 +29,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;