From: Jonas M. <jo...@pr...> - 2022-02-04 00:22:15
|
On Thu, Feb 3, 2022 at 7:25 PM stuart lynne <stu...@gm...> wrote: > > I am working with libant and pyusb to support Ant+ devices. > > The issue I am trying to fix is preventing access to a device that is already open by another process. There may (usually will) be multiple Ant+ devices plugged in, and one or more may be in active use by another program. > > I need to find an unused device and then open that, without interfering with the use of the other open devices. > > Currently, I'm testing on Linux, but this will be deployed on Windows and macOS as well. > > There doesn't appear to be anything to prevent multiple access, and at least initial testing with two processes both using pyusb shows them interfering with each other as they open, close while attempting to access the Ant device. Hi Stuart, As far as I know there is no cross-platform way to unilaterally prevent other processes from accessing a USB device. However, careful use of [libusb_]claim_interface() by both processes can prevent one from trampling over the other: claiming the interface should fail if another process has already done it, so each process can use it as a pseudo-lock for the device it's working on. Note that I'm talking about *explicitly* claiming the interface – with usb.tools.claim_interface() – and not the automatic claiming/releasing that PyUSB does by default. Jonas > > Suggestions would be appreciated. > > Thanks! > > > -- > __________O___________ > _______-\<,____________ > _____(_)/_(_)___________ > _________________________ > Stuart_Lynne____<stu...@gm...>____604-518-1749(m)__604-461-7532(h) > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users |