comparison 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
comparison
equal deleted inserted replaced
56:91b476ebc0f2 57:19045ad9f5f5
133 break 133 break
134 if found: 134 if found:
135 break 135 break
136 if not found: 136 if not found:
137 raise BaseException("Could not find a suitable USB device") 137 raise BaseException("Could not find a suitable USB device")
138 138
139 # Open the device and claim the USB interface that supports the spec 139 # Open the device and claim the USB interface that supports the spec
140 handle = dev.open() 140 handle = dev.open()
141 handle.setConfiguration(dev.configurations[confidx].value) 141 handle.setConfiguration(dev.configurations[confidx].value)
142 handle.claimInterface(altif.interfaceNumber) 142 handle.claimInterface(altif.interfaceNumber)
143 handle.setAltInterface(altif.alternateSetting) 143 handle.setAltInterface(altif.alternateSetting)
144 self.dev = dev 144 self.dev = dev
145 self.handle = handle 145 self.handle = handle
146 146
147 # Get some info for humans 147 # Get some info for humans
148 self.vendname = handle.getString(dev.iManufacturer, 1024) 148 try:
149 self.prodname = handle.getString(dev.iProduct, 1024) 149 self.vendname = handle.getString(dev.iManufacturer, 1024)
150 self.serial = handle.getString(dev.iSerialNumber, 1024) 150 except ValueError:
151 self.vendname = None
152 try:
153 self.prodname = handle.getString(dev.iProduct, 1024)
154 except ValueError:
155 self.prodname = None
156 try:
157 self.serial = handle.getString(dev.iSerialNumber, 1024)
158 except ValueError:
159 self.serial = None
151 160
152 # Determine the endpoints for each operation type 161 # Determine the endpoints for each operation type
153 self.intrep = self.bulkinep = self.bulkoutep = None 162 self.intrep = self.bulkinep = self.bulkoutep = None
154 163
155 for ep in altif.endpoints: 164 for ep in altif.endpoints: