what Linux library should i use to get asynchronous notifications of added usb devices? I'd like my program to work on any Linux device so I'll need to use a library that isn't specific to one Linux version
Depending on your Android version, you must do either of the following: Drag down the status bar, tap Connected as <connection type> under Notifications, and select Camera (PTP). Go to Settings > Storage > Menu > USB computer connection, and select Camera (PTP).
Enter the following command: Get-PnpDevice -PresentOnly | Where-Object { $_. InstanceId -match '^USB' } . That command will show a list of all present USB devices.
The Linux kernel supports two main types of USB drivers: drivers on a host system and drivers on a device. The USB drivers for a host system control the USB devices that are plugged into it, from the host's point of view (a common USB host is a desktop computer.)
If you are using 'C' then I would suggest using the notification features of libudev. Here is a good link with example 'C' code.
libudev Document
Hope that helps.
--Jim
You need to include what language you are using before we can talk libraries, but if you want to just hook into a shell and parse infos you can use udevadm. You also will have to consider user mode, versus kernel mode, and you will most likely have to run your program or in kernel mode to be able to listen for this type of event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With