From: realraum <realraum@realraum.at>
Date: Tue, 19 Jul 2011 13:00:18 +0000 (+0000)
Subject: try to reset openpcd if mifare-read starts outputting nonsense
X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=4b416859c02dc726158fb9ca37c2338ad908259d;p=svn42.git

try to reset openpcd if mifare-read starts outputting nonsense
---

diff --git a/checkcard.pl b/checkcard.pl
index fb576be..082b638 100755
--- a/checkcard.pl
+++ b/checkcard.pl
@@ -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
index 0000000..4602c47
--- /dev/null
+++ b/reset_openpcd.sh
@@ -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