Fix USB usage in tool/
authorNIIBE Yutaka <gniibe@fsij.org>
Wed, 1 Jun 2016 00:49:28 +0000 (09:49 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Wed, 1 Jun 2016 00:49:28 +0000 (09:49 +0900)
ChangeLog
tool/gnuk_token.py
tool/stlinkv2.py

index 76bd48f..520f81d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2016-06-01  Niibe Yutaka  <gniibe@fsij.org>
 
 2016-06-01  Niibe Yutaka  <gniibe@fsij.org>
 
+       * tool/stlinkv2.py (stlinkv2.__init__): Don't
+       call setConfiguration.
+
+       * tool/gnuk_token.py (gnuk_token, regnual): Don't
+       call setAltInterface, it's not needed.
+
        * src/usb-ccid.c (ccid_notify_slot_change): New.
        (ccid_thread): Call ccid_notify_slot_change at
        interface_reset and EV_CARD_CHANGE.
        * src/usb-ccid.c (ccid_notify_slot_change): New.
        (ccid_thread): Call ccid_notify_slot_change at
        interface_reset and EV_CARD_CHANGE.
index ad3ce9c..a6280f5 100644 (file)
@@ -68,7 +68,6 @@ class gnuk_token(object):
             raise ValueError("Wrong interface sub class")
         self.__devhandle = device.open()
         self.__devhandle.claimInterface(interface)
             raise ValueError("Wrong interface sub class")
         self.__devhandle = device.open()
         self.__devhandle.claimInterface(interface)
-        self.__devhandle.setAltInterface(0)
 
         self.__intf = interface.interfaceNumber
         self.__alt = interface.alternateSetting
 
         self.__intf = interface.interfaceNumber
         self.__alt = interface.alternateSetting
@@ -473,7 +472,6 @@ class regnual(object):
             raise ValueError("Wrong interface class")
         self.__devhandle = dev.open()
         self.__devhandle.claimInterface(intf)
             raise ValueError("Wrong interface class")
         self.__devhandle = dev.open()
         self.__devhandle.claimInterface(intf)
-        self.__devhandle.setAltInterface(0)
 
     def mem_info(self):
         mem = self.__devhandle.controlMsg(requestType = 0xc0, request = 0,
 
     def mem_info(self):
         mem = self.__devhandle.controlMsg(requestType = 0xc0, request = 0,
index 651ee87..a169ff5 100755 (executable)
@@ -146,15 +146,7 @@ class stlinkv2(object):
         if intf.interfaceClass != 0xff: # Vendor specific
             raise ValueError("Wrong interface class.", intf.interfaceClass)
         self.__devhandle = dev.open()
         if intf.interfaceClass != 0xff: # Vendor specific
             raise ValueError("Wrong interface class.", intf.interfaceClass)
         self.__devhandle = dev.open()
-        # ST-Link/V2-1 has other interfaces
-        # Some other processes or kernel would use it
-        # So, write access to configuration causes error
-        try:
-            self.__devhandle.setConfiguration(conf.value)
-        except:
-            pass
         self.__devhandle.claimInterface(intf.interfaceNumber)
         self.__devhandle.claimInterface(intf.interfaceNumber)
-        # self.__devhandle.setAltInterface(0)  # This was not good for libusb-win32 with wrong arg intf, new correct value 0 would be OK
 
     def shutdown(self):
         self.__devhandle.releaseInterface()
 
     def shutdown(self):
         self.__devhandle.releaseInterface()