Mercurial > ~darius > hgwebdir.cgi > pyinst
diff usb488.py @ 57:19045ad9f5f5
Make it more tolerant if we can't read strings.
Probably unnecessary, was due to cro acting weird.
author | Daniel O'Connor <doconnor@gsoft.com.au> |
---|---|
date | Fri, 08 Jan 2021 14:01:41 +1030 |
parents | 91b476ebc0f2 |
children | 0684a20cc5c3 |
line wrap: on
line diff
--- a/usb488.py Tue Dec 08 14:00:45 2020 +1030 +++ b/usb488.py Fri Jan 08 14:01:41 2021 +1030 @@ -135,7 +135,7 @@ break if not found: raise BaseException("Could not find a suitable USB device") - + # Open the device and claim the USB interface that supports the spec handle = dev.open() handle.setConfiguration(dev.configurations[confidx].value) @@ -145,9 +145,18 @@ self.handle = handle # Get some info for humans - self.vendname = handle.getString(dev.iManufacturer, 1024) - self.prodname = handle.getString(dev.iProduct, 1024) - self.serial = handle.getString(dev.iSerialNumber, 1024) + try: + self.vendname = handle.getString(dev.iManufacturer, 1024) + except ValueError: + self.vendname = None + try: + self.prodname = handle.getString(dev.iProduct, 1024) + except ValueError: + self.prodname = None + try: + self.serial = handle.getString(dev.iSerialNumber, 1024) + except ValueError: + self.serial = None # Determine the endpoints for each operation type self.intrep = self.bulkinep = self.bulkoutep = None