X-Git-Url: http://git.rot13.org/?p=air-quality;a=blobdiff_plain;f=zph02.pl;h=a6407fad11d671f8cf5f6201bf3eb0a425649de5;hp=aeaaffbb686518eb449507712e22f7316095b511;hb=c9bd23bbf3f7abefcc2f766ae8edf8a64d3570a4;hpb=2e19ee9624f8d86fc74686dfa1dc6e5215ed9c95 diff --git a/zph02.pl b/zph02.pl index aeaaffb..a6407fa 100755 --- a/zph02.pl +++ b/zph02.pl @@ -6,10 +6,8 @@ use Device::SerialPort; use Time::HiRes; use Data::Dump qw(dump); -my $port = shift @ARGV || '/dev/ttyUSB1'; -$port = '/dev/serial/by-path/pci-0000:00:1a.7-usb-0:5.4:1.0-port0'; -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.4.2:1.0'; +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); @@ -23,6 +21,11 @@ $s->read_const_time(10); while (1) { + alarm 3; + # Usb serial which I'm using is buggy and blocks from time to time. + # This will ensure that we have passed here every 3 seconds + # or we will be killed and systemd will restart us + my ($len, $string) = $s->read(9); my $t = int( Time::HiRes::time() * 1_000_000_000 ); die $! if ! defined($len);