Device shared / exclusive locking? #615
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi#615
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I noticed while implementing the NetBSD backend that each platform has different defaults.
hidrawhas no locking by default.uhidhas mandatory locking in most implementations. I don't know what the situation is for the Mac and Win32 backends.Would there be any value in adding an API for locking the device in the
hidapibackend? For most unix platforms,flockcan be used to achieve advisory locking for cooperating applications so it isn't without its merits but this would only be effective where the platform doesn't already enforce its own locks beyond the control of the application.I could see there being value in the application having a way to get a lock on the device as well as knowing the type of lock that is in effect because sharing access between applications may be a problem depending on the device being used. I have seen devices that use vendor HID protocols that are stateful and therefore should not be interrupted by another application. One example is a HID device that implemented
ymodemprotocol by treating the HID transport as a packet system in order to upload firmware updates.The thing is that there is no uniform to this approach. Depending on the platform - not everything is possible (e.g. libusb doesn't allow shared access to the device at all).
I've described this somewhere in comments to other tickets and can find my full answer at the moment.
Long story short: you may add something backend-specific if you think that makes sense.
Take a look at hid_darwin_set_open_exclusive for example.