X-Git-Url: http://git.rot13.org/?p=air-quality;a=blobdiff_plain;f=dsm501.pl;h=33277e5d19a152bc35491b6c0adc331bc46bff2b;hp=41578a563378d8b253268ee2e1fb9e541972a4c0;hb=HEAD;hpb=198bb15fd95864d39e31c6f3d09f6b394cf1d9fa diff --git a/dsm501.pl b/dsm501.pl index 41578a5..0a237a7 100755 --- a/dsm501.pl +++ b/dsm501.pl @@ -6,9 +6,9 @@ use Device::SerialPort; use Time::HiRes; use Data::Dump qw(dump); -my $port = shift @ARGV || '/dev/ttyUSB2'; -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/platform-3f980000.usb-usb-0:1.3:1.0-port0'; +my $influx_url = shift @ARGV || 'http://192.168.3.40:8086/write?consistency=any&db=rot13'; +my $measurement = $ENV{MEASUREMENT} || 'dsm501'; my $s = new Device::SerialPort( $port ) || die $!; $s->baudrate(115200); @@ -16,8 +16,8 @@ $s->databits(8); $s->parity('none'); $s->stopbits(1); $s->handshake('none'); -$s->read_char_time(5); -$s->read_const_time(10); +$s->read_char_time(0); # don't wait for each char +$s->read_const_time(200); # ms for complete read while (1) { @@ -26,12 +26,12 @@ while (1) { my $t = int( Time::HiRes::time() * 1_000_000_000 ); die $! if ! defined($len); if ( $len > 0 ) { - warn "# len=$len ",dump($string); + #warn "# len=$len ",dump($string); if ( $string !~ m/^#/ ) { $string =~ s/[\r\n]+$//; $string =~ s/\s/,/g; - my $influx = "dsm501,dc=trnjanska $string $t"; - print "$influx\n"; + my $influx = "$measurement,dc=trnjanska $string $t"; + print "$influx\n" if -e '/dev/shm/air-debug'; system "curl --silent -XPOST '$influx_url' --data-binary '$influx'" } else { warn "SKIP: $string\n";