vpelletier / python-libusb1

Python ctype-based wrapper around libusb1
GNU Lesser General Public License v2.1
174 stars 67 forks source link

Hotplug support on windows #40

Closed RyanHope closed 3 years ago

RyanHope commented 6 years ago

I've wasted a few days now trying to getting the hotplug code to run on Windows with no luck. This package always tells me my libusb driver is out of date. I have tried using native python, msys2, mingw, cygwin, miniconda... All the non-native python environments should have libusb1.0 installed so I am not sure why this package keeps finding/using some 0.1 lib. I've tried installing the pacakge from pypi and from source. Not sure what the trick is. Is there any way to get this package to use libusbK?

vpelletier commented 5 years ago

This package always tells me my libusb driver is out of date.

What is the exact error message you are getting ? I do not think I have put any version detection, so this is surprising.

I have tried using native python, msys2, mingw, cygwin, miniconda... All the non-native python environments should have libusb1.0 installed

The way ctypes locates a so/dll/dylib/... is following OS specifics. On windows, AFAIK it will look first in the "current" directory (for interpreters I'm not sure whether this is the script's directory or the interpreter's directory though), and then goes on to system32 folder I believe.

so I am not sure why this package keeps finding/using some 0.1 lib.

1.0 and 0.1 have different file names, so it should never be loading 0.1 at all.

You may want to add a print in usb1/libusb1.py right after _loadLibrary is called so you can see where it loaded the library from (maybe from an attribute of the libusb object). If there is an way to check which files a process have opened (lsof -p equivalent) it would also help, but I do not know ofone on windows.

Is there any way to get this package to use libusbK?

I believe libusbK is (mostly ? only ?) the kernel part, allowing userland (libusb1) to access usb devices with more freedom than the MS-provided API. But here too, I lack in windows experience, sorry.

eine commented 5 years ago

@RyanHope, I think that this is documented in https://github.com/libusb/libusb/wiki/Windows#development-considerations:

Because Windows does not provide a native poll() function, and cygwin is the only development environment that provides such a call, the use of libusb file descriptors with poll() on cygwin is NOT supported.

Because there is no native poll() on Windows, the ability to return externally pollable file descriptors on Windows libusb_get_pollfd() returns an error.


I arrived here while trying to guess why trying to execute jwise/pyusbip on Cygwin (Windows 10) produces NotImplementedError: Your libusb does not seem to implement pollable FDs.

Regarding the examples in this repo, listdevs.py works ok. However, hotplug.py shows Hotplug support is missing. Please update your libusb version. I think this is just a misleading error message, according to the quotes above.

RyanHope commented 5 years ago

Are you installing libusbK and not the other libusb?

On Tue, Aug 20, 2019 at 3:00 AM 1138-4EB notifications@github.com wrote:

@RyanHope https://github.com/RyanHope, I think that this is documented in https://github.com/libusb/libusb/wiki/Windows#development-considerations:

Because Windows does not provide a native poll() function, and cygwin is the only development environment that provides such a call, the use of libusb file descriptors with poll() on cygwin is NOT supported.

Because there is no native poll() on Windows, the ability to return externally pollable file descriptors on Windows libusb_get_pollfd() returns an error.


I arrived here while trying to guess why trying to execute jwise/pyusbip https://github.com/jwise/pyusbip on Cygwin (Windows 10) produces NotImplementedError: Your libusb does not seem to implement pollable FDs.

Regarding the examples in this repo, listdevs.py https://github.com/vpelletier/python-libusb1/blob/master/examples/listdevs.py works ok. However, hotplug.py https://github.com/vpelletier/python-libusb1/blob/master/examples/hotplug.py shows Hotplug support is missing. Please update your libusb version. I think this is just a misleading error message, according to the quotes above.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vpelletier/python-libusb1/issues/40?email_source=notifications&email_token=AABCNTNW57IEFJ3RYAHOMQ3QFOJBFA5CNFSM4FZNT3LKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4VI34Q#issuecomment-522882546, or mute the thread https://github.com/notifications/unsubscribe-auth/AABCNTPZ7TDKMS4KNVXCJK3QFOJBFANCNFSM4FZNT3LA .

eine commented 5 years ago

Are you installing libusbK and not the other libusb?

I don't think so. I installed libusb1.0 (1.0.21-1) through Cygwin only.

The 'Driver Details' of the device say FTDI Ltd. 2.12.10.3 built by: WinDDK.

mcuee commented 3 years ago

Please take note hotplug has not been implemented in libusb Windows. https://github.com/libusb/libusb/issues/86

vpelletier commented 3 years ago

@mcuee Thanks for the link, I did not realize this is not implemented on Windows (I remembered seeing long discussions about this, but somehow imagined it was eventually implemented).

vpelletier commented 3 years ago

I close this, as it depends on libusb features which do not exist yet.

mcuee commented 3 years ago

Yes it is good to close this. libusb hotplug support for Windows will not be there any time soon now that no developers are working on this feature.