From 4a6885e6e410acb11120a7998ce1ec9176c9c27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 19 Apr 2015 23:39:39 +0200 Subject: [PATCH] Add a script that should poweroff the teensy. Not working. --- v2/backend/forwarding/resetUSB.sh | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 v2/backend/forwarding/resetUSB.sh diff --git a/v2/backend/forwarding/resetUSB.sh b/v2/backend/forwarding/resetUSB.sh new file mode 100644 index 0000000..1ddb670 --- /dev/null +++ b/v2/backend/forwarding/resetUSB.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +port='' + +for i in `seq 2 5`; +do + echo '1-1.'$i > /sys/bus/usb/drivers/usb/unbind + if [ $? == 0 ]; then + echo 'Found port: 1-1.'$i + port='1-1.'$i + break + fi +done + +if [ ${#port} == 0 ]; then + echo Unable to find a device connected on USB, trying to reconnect on all ports... + for i in `seq 2 5`; + do + echo '1-1.'$i > /sys/bus/usb/drivers/usb/bind + if [ $? == 0 ]; then + echo 'Found port: 1-1.'$i + break + fi + done +else + sleep 1 + echo -n Reconnect... + echo $port > /sys/bus/usb/drivers/usb/bind +fi + +if [ $? == 0 ]; then + echo done + echo -e 'Device reachable on port: \n\t' `dmesg | grep cdc_acm | tail -n 1 | cut -d: -f 3` + echo You may have to change the port in forwarder.py +else + echo Failed, you probably have to move your body to the teensy. +fi + +