From: Matthew G. <ma...@gi...> - 2015-08-05 15:24:13
|
If you want to restrict access to the device to a single process, you could write a wrapper function that attempts to detach the kernel driver if it's attached, then claim the interface. Once the interface(s) is/are claimed, other processes won't be able to issue r/w calls to the device, AFAIK. If you want to allow multiple processes access to the device, you could use something like boost::named_mutex to take care of protecting critical sections. It's multi platform too. If you need something more complex, like an ordered queuing mechanism, you'll likely either need to use some sort of shared memory construct or write a system service/daemon. ============================================================ Matthew Giassa, MASc, MIEEE, EIT Security, Embedded Systems and DSP Specialist linkedin: https://ca.linkedin.com/in/giassa e-mail: ma...@gi... website: www.giassa.net Original Message From: Peter Stuge Sent: Wednesday, August 5, 2015 7:26 AM To: lib...@li... Subject: Re: [libusb] libusb_open twice for same device maisaid wrote: > I am using libusb-1.0 , when I try to call libusb_open multiple times back to > back for the same device , it succeeds in the first call and returns -3 ( > error-access) in the next time. Is this scenario guaranteed to always occur. No. > Does libusb prevents multiple open to same device from the same > process or different processes? Quote the opposite: The libusb-1.0 API intends to allow multiple open of the same device at the very least from different processes. There may however exist some implementation differences in this area across the different platforms. > If libusb allow multiple open to same device, is there a way to avoid > that or a parameter to set to make only one open allowed per usb device. There are ways, but not within libusb. You would have to create this using some kind of system-wide semaphore. How to do that is platform- specific unfortunately. //Peter ------------------------------------------------------------------------------ _______________________________________________ libusb-devel mailing list lib...@li... https://lists.sourceforge.net/lists/listinfo/libusb-devel |