Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b1b0f479f | |||
| e5c3e9c824 | |||
| a90e215aba | |||
| 9be8b77983 |
@@ -17,8 +17,11 @@
|
||||
*/
|
||||
"""
|
||||
|
||||
import os
|
||||
import usb.core
|
||||
import usb.util
|
||||
import libusb_package
|
||||
import usb.backend.libusb1
|
||||
from .ICCD import ICCD
|
||||
|
||||
class RescuePicoKey:
|
||||
@@ -37,7 +40,12 @@ class RescuePicoKey:
|
||||
return True
|
||||
return False
|
||||
|
||||
devs = usb.core.find(find_all=True, custom_match=find_class(0x0B))
|
||||
backend = usb.backend.libusb1.get_backend(find_library=libusb_package.find_library)
|
||||
try:
|
||||
devs = usb.core.find(find_all=True, custom_match=find_class(0x0B), backend=backend)
|
||||
except Exception as e:
|
||||
print("RescuePicoKey: exception during usb.core.find:", e)
|
||||
devs = []
|
||||
found = False
|
||||
for dev in devs:
|
||||
if (dev.manufacturer == 'Pol Henarejos'):
|
||||
@@ -77,8 +85,15 @@ class RescuePicoKey:
|
||||
assert(self.__dev.write(self.__out, data, timeout) == len(data))
|
||||
|
||||
def exchange(self, data, timeout=2000):
|
||||
self.write(data=data, timeout=timeout)
|
||||
return self.read(timeout=timeout)
|
||||
try:
|
||||
self.write(data=data, timeout=timeout)
|
||||
except Exception as e:
|
||||
raise Exception("USB write error: " + str(e))
|
||||
try:
|
||||
ret = self.read(timeout=timeout)
|
||||
except Exception as e:
|
||||
raise Exception("USB read error: " + str(e))
|
||||
return ret
|
||||
|
||||
def powerOn(self):
|
||||
if (not self.__active):
|
||||
|
||||
+1
-1
@@ -18,4 +18,4 @@
|
||||
*/
|
||||
"""
|
||||
|
||||
__version__ = "1.1.2"
|
||||
__version__ = "1.1.4"
|
||||
|
||||
Reference in New Issue
Block a user