Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fe46149b9 | |||
| e7d92fba8a | |||
| 6b1b0f479f | |||
| e5c3e9c824 |
@@ -79,6 +79,14 @@ class PicoKey:
|
||||
self.product = Product(Product.UNKNOWN)
|
||||
self.version = (0, 0)
|
||||
|
||||
def close(self):
|
||||
if isinstance(self.__card, RescuePicoKey):
|
||||
self.__card.close()
|
||||
else:
|
||||
self.__card.disconnect()
|
||||
self.__card.release()
|
||||
self.__card = None
|
||||
|
||||
def transmit(self, apdu):
|
||||
response, sw1, sw2 = self.__card.transmit(apdu)
|
||||
return response, sw1, sw2
|
||||
|
||||
+16
-11
@@ -20,6 +20,8 @@
|
||||
import os
|
||||
import usb.core
|
||||
import usb.util
|
||||
import libusb_package
|
||||
import usb.backend.libusb1
|
||||
from .ICCD import ICCD
|
||||
|
||||
class RescuePicoKey:
|
||||
@@ -37,12 +39,8 @@ class RescuePicoKey:
|
||||
if intf is not None:
|
||||
return True
|
||||
return False
|
||||
if (os.name == 'nt'):
|
||||
import libusb_package
|
||||
import usb.backend.libusb1
|
||||
backend = usb.backend.libusb1.get_backend(find_library=libusb_package.find_library)
|
||||
else:
|
||||
backend = None
|
||||
|
||||
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:
|
||||
@@ -51,7 +49,7 @@ class RescuePicoKey:
|
||||
found = False
|
||||
for dev in devs:
|
||||
if (dev.manufacturer == 'Pol Henarejos'):
|
||||
|
||||
dev.set_configuration()
|
||||
cfg = dev.get_active_configuration()
|
||||
for intf in cfg:
|
||||
if (intf.bInterfaceClass == 0xFF):
|
||||
@@ -70,15 +68,22 @@ class RescuePicoKey:
|
||||
self.__int = epint.bEndpointAddress if epint else None
|
||||
self.__iccd = ICCD(self)
|
||||
self.__active = None
|
||||
try:
|
||||
self.powerOff()
|
||||
except Exception as e:
|
||||
print("RescuePicoKey: exception during power off:", e)
|
||||
self.powerOff()
|
||||
found = True
|
||||
break
|
||||
if (not found):
|
||||
raise Exception('Not found any Pico Key device')
|
||||
|
||||
def close(self):
|
||||
if self.__dev:
|
||||
usb.util.dispose_resources(self.__dev)
|
||||
|
||||
def __exit__(self, exc_type, exc, tb):
|
||||
self.close()
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def __str__(self):
|
||||
return str(self.__dev)
|
||||
|
||||
|
||||
+1
-1
@@ -18,4 +18,4 @@
|
||||
*/
|
||||
"""
|
||||
|
||||
__version__ = "1.1.3"
|
||||
__version__ = "1.1.5"
|
||||
|
||||
Reference in New Issue
Block a user