Dear maintainers,
my client and I have the same USB-Device. I have written a program for it.
It runs fine on both Linux systems. It runs fine on my Windows but crashes on my client's.
Both have installed the driver with inf-wizard and the system control shows libusb0.dll on
both machines.
 
However, pyusb1 does not care about it; there is no single line related to the registry in the code.
Instead pyusb started searching with pyusb1 backend and finds some libusb1 in some private direcory
of some other device. And crashed.
 
This is not acceptable.
I have written a demo to fetch the correct service from the registry, it follows here:
-------------------------------------------------------------------------------------
from __future__ import print_function
# call this only on Windows
try:
    from _winreg import *
except:
    from winreg import *
def getService(vid,pid):
    vidpid = r"\VID_%04x&PID_%04x" % (vid,pid)
    path = r"SYSTEM\ControlSet002\ENUM\USB" + vidpid
    key = OpenKey(HKEY_LOCAL_MACHINE,path,0,KEY_READ)
    try:
        i = 0
        enumkey = EnumKey(key,i)
        i = i + 1
    except Exception as message:
        pass # print("enumkey",message)
        
    newkey = OpenKeyEx(key,enumkey,0,KEY_READ)
    service,Size = QueryValueEx(newkey,"Service")
    return service
if __name__ == "__main__":
    print ("service for 0x5656 0x0834 is",getService(0x5656,0x0834))
-----------------------------------------------------------------------------------------
The output is
"service for 0x5656 0x0834 is libusb0"
 
I am aware of the backend=xxx switches and the findlibrary hooks.
They are useful to override defaults in special cases.
 
However this does not answer the question which defaults are appropiate in the normal case.
On Windows the registry entry is the most appropriate default.
 
I hope this can help you to amend pyusb1 (which is a great tool anyway).
 
Sincerely Hermann Hamann
 
 
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to