projects
/
svn42.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
138139e
)
update
author
realraum
<realraum@realraum.at>
Thu, 30 Apr 2009 04:12:38 +0000
(
04:12
+0000)
committer
realraum
<realraum@realraum.at>
Thu, 30 Apr 2009 04:12:38 +0000
(
04:12
+0000)
checkcard.pl
patch
|
blob
|
history
door_daemon.py
patch
|
blob
|
history
diff --git
a/checkcard.pl
b/checkcard.pl
index
71c1966
..
b948393
100755
(executable)
--- a/
checkcard.pl
+++ b/
checkcard.pl
@@
-1,8
+1,13
@@
#!/usr/bin/perl -w
#!/usr/bin/perl -w
+use Socket;
use strict;
my $fh;
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;
my $keys;
my %good;
@@
-18,12
+23,10
@@
while (<$keys>)
sub send_to_fifo
{
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)
}
while (sleep 1)
diff --git
a/door_daemon.py
b/door_daemon.py
index
5fb9567
..
fefc6cd
100755
(executable)
--- 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')
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;
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()
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"
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"
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:
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)
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)
#signal.signal(signal.SIGTERM, exit_handler)
signal.signal(signal.SIGINT, exit_handler)
signal.signal(signal.SIGQUIT, exit_handler)