From: Dobrica Pavlinusic Date: Wed, 12 Feb 2020 20:31:02 +0000 (+0100) Subject: use /dev/serial/by-path/ X-Git-Url: http://git.rot13.org/?p=air-quality;a=commitdiff_plain;h=632fc9b95bf751f33b6d71238adc6bb94f2e5ae6 use /dev/serial/by-path/ --- diff --git a/dsm501.pl b/dsm501.pl index 0032747..3b2f914 100755 --- a/dsm501.pl +++ b/dsm501.pl @@ -6,7 +6,7 @@ use Device::SerialPort; use Time::HiRes; use Data::Dump qw(dump); -my $port = shift @ARGV || '/dev/ttyUSB4'; +my $port = shift @ARGV || '/dev/serial/by-path/pci-0000:00:1a.7-usb-0:5.1.3: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 $measurement = $ENV{MEASUREMENT} || 'dsm501'; diff --git a/mh-z19b.pl b/mh-z19b.pl index 94abb05..c2f8ffe 100755 --- a/mh-z19b.pl +++ b/mh-z19b.pl @@ -6,8 +6,7 @@ use Device::SerialPort; use Time::HiRes; use Data::Dump qw(dump); -my $port = shift @ARGV || '/dev/ttyUSB0'; -$port = '/dev/ttyUSB5'; +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'; diff --git a/mq.sh b/mq.sh index 2db7b33..9e77384 100755 --- a/mq.sh +++ b/mq.sh @@ -1,3 +1,3 @@ #!/bin/sh -MEASUREMENT=mq /home/dpavlin/air-quality/dsm501.pl /dev/ttyUSB0 +MEASUREMENT=mq /home/dpavlin/air-quality/dsm501.pl /dev/serial/by-path/pci-0000:00:1a.7-usb-0:5.3.2:1.0-port0 diff --git a/zph02.pl b/zph02.pl index aeaaffb..ef54765 100755 --- a/zph02.pl +++ b/zph02.pl @@ -6,8 +6,7 @@ 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 $port = shift @ARGV || '/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'; @@ -23,6 +22,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);