use /dev/serial/by-path/
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 12 Feb 2020 20:31:02 +0000 (21:31 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 12 Feb 2020 20:31:02 +0000 (21:31 +0100)
dsm501.pl
mh-z19b.pl
mq.sh
zph02.pl

index 0032747..3b2f914 100755 (executable)
--- 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';
index 94abb05..c2f8ffe 100755 (executable)
@@ -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 (executable)
--- 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
index aeaaffb..ef54765 100755 (executable)
--- 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);