From: realraum Date: Thu, 30 Apr 2009 04:12:38 +0000 (+0000) Subject: update X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=889622e0c6757408211798cfe8562a026a93b5b2;p=svn42.git update --- diff --git a/checkcard.pl b/checkcard.pl index 71c1966..b948393 100755 --- a/checkcard.pl +++ b/checkcard.pl @@ -1,8 +1,13 @@ #!/usr/bin/perl -w +use Socket; use strict; my $fh; -my $fifofile = "/tmp/door_cmd.fifo"; +#my $fifofile = "/tmp/door_cmd.fifo"; + +my $socketfile = "/tmp/door_cmd.socket"; +exit(1) unless (-S $socketfile); +my $socketaddr = sockaddr_un($socketfile); my $keys; my %good; @@ -18,12 +23,10 @@ while (<$keys>) sub send_to_fifo { - if( -p $fifofile) - { - open(my $fifo,"> $fifofile"); - print $fifo shift(@_)."\n"; - close($fifo); - } + socket(my $conn, PF_UNIX, SOCK_STREAM,0) || die "socket: $!"; + connect($conn, $socketaddr) || die "socket connect: $!"; + print $conn shift(@_)."\n"; + close($conn); } while (sleep 1) diff --git a/door_daemon.py b/door_daemon.py index 5fb9567..fefc6cd 100755 --- a/door_daemon.py +++ b/door_daemon.py @@ -39,8 +39,8 @@ class StatusDisplay(): class ArduinoUSBThread ( threading.Thread ): def __init__(self, file_dev_ttyusb): self.re_isidle = re.compile(r'idle') - self.re_isopen = re.compile(r'open') - self.re_isclosed = re.compile(r'close|closing') + self.re_isopen = re.compile(r'Status: opened, idle') + self.re_isclosed = re.compile(r'Status: closed, idle') self.re_toolong = re.compile(r'took too long!') self.min_seconds_between_reset=10; self.timestamp_send_reset=0; @@ -114,14 +114,14 @@ class ArduinoUSBThread ( threading.Thread ): time.sleep(0.5) continue self.cv_updatestatus.acquire() - self.lastline=line + self.lastline=line.strip() logging.info(self.file_dev_ttyusb+": "+self.lastline) if self.re_isclosed.search(self.lastline): self.last_status="closed" - self.statusdisplay.display_open() + self.statusdisplay.display_closed() elif self.re_isopen.search(self.lastline): self.last_status="open" - self.statusdisplay.display_closed() + self.statusdisplay.display_open() elif self.re_toolong.search(self.lastline): self.last_status="error" if (time.time() - self.timestamp_send_reset) > self.min_seconds_between_reset: @@ -214,6 +214,7 @@ def exit_handler(signum, frame): arduino.stop() sys.exit(0) +#signals proapbly don't work because of readline #signal.signal(signal.SIGTERM, exit_handler) signal.signal(signal.SIGINT, exit_handler) signal.signal(signal.SIGQUIT, exit_handler)