#!/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;
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)
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;
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:
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)