Page 1 of 1

About pyusb

Posted: Wed Mar 11, 2020 2:43 am
by DaHuFa
I want use pyusb to test my CCID device. But I'm new to pyusb. I installed pyusb and liusb. But when I called get_active_configuration() or set_configuration(), I got the "Operation not supported or unimplemented on this platform" information. Why?

Re: About pyusb

Posted: Wed Mar 11, 2020 2:45 am
by DaHuFa
Did my smartcard reader driver cause this question?

Re: About pyusb

Posted: Thu Mar 12, 2020 2:13 am
by DaHuFa
Now I resolved this problem by installed the newest libusb(libusb-1.0.22). And set_configuration() worked rightly. But a new question appread. Tt is write function.

Code: Select all

dev = usb.core.find(idVendor=0x096e, idProduct=0x0856)

dev.set_configuration()
cfg = dev.get_active_configuration()

for intf in cfg:
    if intf.bInterfaceClass == 0x0B: #smart card
        break
        
out_ep = None
in_ep = None
for ep in intf:
    if usb.util.endpoint_direction(ep.bEndpointAddress) == usb.util.ENDPOINT_IN:
        in_ep = ep
    if usb.util.endpoint_direction(ep.bEndpointAddress) == usb.util.ENDPOINT_OUT:
        out_ep = ep

print out_ep
print in_ep
dev.ctrl_transfer(bmRequestType=0x80, bRequest=0x06, wValue=0x0302, wIndex=0x0409, data_or_wLength=0x0018)
out.write('\x63\x00\x00\x00\x00\x00\x00\x00\x00\x00')
The error appeared when PC processing out.write function:
NotImplementedError: Operation not supported or unimplemented on this platform
:?: :?: :?:

Re: About pyusb

Posted: Thu Mar 26, 2020 5:17 am
by lucas21
Thanks for the information!

Re: About pyusb

Posted: Fri Apr 24, 2020 2:54 am
by DaHuFa
Now, I'm getting a little clearer on Libusb. winUSB is the grandfather. libusb is the son. pyusb is grandson. All operations base on winUSB. libusb is only a lib. It encapsulates winUSB operations and provides a uniform interfaces. pyusb is python module. If I use C language, I can use libusb too.

Re: About pyusb

Posted: Thu May 14, 2020 6:16 am
by DaHuFa
If you want to work on libusb, the fist step is replacing your device driver. I usb "zadig-2.5.exe" replaced my CCID reader. I can send apdu and recv sw now. :lol: