Mercurial > code > home > repos > homeauto
changeset 847:a93be1639c98
catch another broken-usb state
Ignore-this: 5b9545e31635c27d1d8d9ecdf3dcdf28
darcs-hash:20120927224344-312f9-b7af0a95cfadfc9be21304d4d928c505d5117a3a
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Thu, 27 Sep 2012 15:43:44 -0700 |
parents | 5c6133c227d0 |
children | 54f29f298513 |
files | service/usbReset/usbReset.py |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/service/usbReset/usbReset.py Sun Aug 26 22:55:24 2012 -0700 +++ b/service/usbReset/usbReset.py Thu Sep 27 15:43:44 2012 -0700 @@ -94,9 +94,11 @@ def haveDevice(usbId): try: log.debug("checking for %s", usbId) - hubDevice(usbId) + dev = hubDevice(usbId) + # sometimes the dev will exist but fail to open + open(dev, "r") return True - except ValueError: + except (ValueError, IOError): return False def resetDevice(dev): @@ -184,16 +186,16 @@ if not haveDevice(Id.ftdi): if haveFrontHub3: - resetDevice(Id.frontDoorHub3) + resetDevice(hubDevice(Id.frontDoorHub3)) else: if haveFrontHub2: - resetDevice(Id.frontDoorHub2) + resetDevice(hubDevice(Id.frontDoorHub2)) else: if haveFrontHub1: - resetDevice(Id.frontDoorHub1) + resetDevice(hubDevice(Id.frontDoorHub1)) else: if haveFrontHub0: - resetDevice(Id.frontDoorHub0) + resetDevice(hubDevice(Id.frontDoorHub0)) else: raise ValueError("don't have the first hub") else: @@ -201,10 +203,10 @@ if not haveDevice(Id.garagePowerSerial): if haveGarageHub1: - resetDevice(Id.garageHub1) + resetDevice(hubDevice(Id.garageHub1)) else: if haveGarageHub0: - resetDevice(Id.garageHub0) + resetDevice(hubDevice(Id.garageHub0)) else: raise ValueError("don't have the first hub") else: @@ -232,7 +234,7 @@ elif hostname == 'dash': if not os.path.exists("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900gbcG-if00-port0"): - resetDevice("/dev/bus/usb/003/001") + resetDevice(hubDevice("/dev/bus/usb/003/001")) else: raise NotImplementedError