X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=checkcard.pl;h=fb576be920eb8867663f076b994db06eedf3bba1;hb=ae63af1c2a2512719f2d31a9ac87518edab6ca4d;hp=263ffe71ed348797d64d983ddda90dd2ea8c492c;hpb=afc36c1874ead0a61d77846384081488d9616eb7;p=svn42.git diff --git a/checkcard.pl b/checkcard.pl index 263ffe7..fb576be 100755 --- a/checkcard.pl +++ b/checkcard.pl @@ -3,23 +3,31 @@ use Socket; use strict; my $fh; -#my $fifofile = "/tmp/door_cmd.fifo"; -my $socketfile = "/tmp/door_cmd.socket"; +my $socketfile = $ARGV[0] || "/var/run/tuer/door_cmd.socket"; +my $keysfile = '/flash/keys'; + sleep(1) while (! -S $socketfile); my $socketaddr = sockaddr_un($socketfile); -my $keys; my %good; +my $keys_last_read=0; -open $keys,'/flash/keys'; -while (<$keys>) +sub read_keys { - chomp; - if ($_ =~ /^([0-9A-Fa-f]{8})\s+(.+)$/) - { - $good{$1}=$2; - } + %good=(); + my $keys; + open $keys,$keysfile; + while (<$keys>) + { + chomp; + if ($_ =~ /^([0-9A-Fa-f]{8})\s+(.+)$/) + { + $good{$1}=$2; + } + } + close $keys; + $keys_last_read = -M ($keysfile); } sub send_to_fifo @@ -30,9 +38,15 @@ sub send_to_fifo close($conn); } +read_keys(); + + while (sleep 1) { - open $fh,'/flash/tuer_python/mifare-read 0 2>&1 |'; + open $fh,'/flash/tuer/mifare-read 0 2>&1 |'; + + read_keys() unless ($keys_last_read == -M ($keysfile)); + while (<$fh>) { next unless /UID/;