try to reset openpcd if mifare-read starts outputting nonsense
authorrealraum <realraum@realraum.at>
Tue, 19 Jul 2011 13:00:18 +0000 (13:00 +0000)
committerrealraum <realraum@realraum.at>
Tue, 19 Jul 2011 13:00:18 +0000 (13:00 +0000)
checkcard.pl
reset_openpcd.sh [new file with mode: 0755]

index fb576be..082b638 100755 (executable)
@@ -47,9 +47,14 @@ while (sleep 1)
 
   read_keys() unless ($keys_last_read == -M ($keysfile));
 
-       while (<$fh>)
+  READLOOP: while (<$fh>)
        {
-               next unless /UID/;
+               unless (/UID/)
+    {
+      close($fh);
+      system("/flash/tuer/reset_openpcd.sh");
+      last READLOOP;
+    }
                my ($id) = /UID=(\S+)\s+/;
                if ($good{$id})
                {
diff --git a/reset_openpcd.sh b/reset_openpcd.sh
new file mode 100755 (executable)
index 0000000..4602c47
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/zsh
+local devPath
+for idVendor in /sys/bus/usb/devices/*/idVendor; do
+  devPath=${idVendor:h} 
+  if [[ "$(< $idVendor)" == "16c0" && "$(< ${devPath}/idProduct )" == "076b" ]]; then
+    echo -n suspend >! ${devPath}/power/level
+    sleep 1
+    echo -n on >! ${devPath}/power/level
+  fi
+done