From 4b416859c02dc726158fb9ca37c2338ad908259d Mon Sep 17 00:00:00 2001 From: realraum Date: Tue, 19 Jul 2011 13:00:18 +0000 Subject: [PATCH] try to reset openpcd if mifare-read starts outputting nonsense --- checkcard.pl | 9 +++++++-- reset_openpcd.sh | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 reset_openpcd.sh 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 -- 1.7.10.4