twsnnl
twsnnl

Reputation: 11

Script to reset USB when unavailable

I have set up a VenusOS pi with home-made ve-direct cables. Every now and then Venus gives a 'not connected' on all devices and the touchscreen (also usb) does not work anymore. I have not found a way to reset the USB hub AND fixes this, so best thing is to just reboot. When the problem occurs there is some logging with 'timeout', so i want to reboot when my script sees that.

#!/bin/bash

tail -fn0 /var/log/vedirect.ttyUSB0/current | while read line ; do
echo "${line}" | grep -i "timeout" > /dev/null
if [ $? = 0 ] ; then
truncate -s 0 /var/log/vedirect.ttyUSB0/current
        reboot
fi
done

1, I also want to check vedirect.ttyUSB1/current, but do not know how to check both. 2, if it does not find anything, it needs to stop checking, or, the script runs on boot with init.d. What is best practice?

I tried to start this on boot with update-rc.d, but then it fails to boot, probably cause the script is not compliant.

Upvotes: 0

Views: 54

Answers (0)

Related Questions