From: Xiaofan C. <xia...@gm...> - 2022-02-04 10:14:34
|
On Fri, Feb 4, 2022 at 4:40 PM stuart lynne <stu...@gm...> wrote: > > Yes, I'm looking at claim_interface/release_interface. It seems to take > a bit of a song and dance to get it to work. > > And I'm definitely seeing different results between Linux and Windows. > I can live with that, platform.system() can be used to differentiate with > different solutions. > > A bigger issue (especially for Windows which is the main target and > possibly macOS) will be playing nice with existing commercial programs. > Can't interfere with them, just need to find an available Ant+ dongle without > causing problems and then claiming it so other programs won't attempt to use it. > > Under Linux it appears that set_configuration() will fail if another process has > done a claim_interface(). It doesn't look like claim_interface() can fail, which > possibly means two processes could get past the set_configuration() test and > then both attempt to do a claim_interface(). Windows can be a big problem. What is the driver used with your ANT+ dongle? I remember my old Garmin ANT dongle (for use with the Garmin VivoFit 1 and 3) uses libusb-win32 driver. We have improved the support of libusb0.sys in libusb 1.0.25 release but there may still be some problems. Ref: https://github.com/libusb/libusb/wiki/FAQ#How_to_use_libusb_under_Windows Good thing is that pyusb does support libusb-0.1 backend even though libusb-1.0 backend is recommended. If your ANT+ dongle uses WinUSB driver, you have a problem as WinUSB does not support multiple concurrent applications. Ref: https://github.com/libusb/libusb/wiki/Windows#Known_Restrictions There is a workaround -- you have to write a daemon (eg: Windows service) to deal with them and then multiple applications can call the daemon to work with the ANT+ device. For macOS, as long as your ANT+ dongle is not claimed exclusively by existing kernel drivers, hopefully it will be fine. Read the libusb caveats as well for things to take note under all operating systems. https://libusb.sourceforge.io/api-1.0/libusb_caveats.html -- Xiaofan |