So i have this small linux-based device that collects some data and implements usb gadget to emulate a flash drive, so that people can have access to the data.
I was able to capture the eject event by detecting the power loss on the vbus pin, as mentioned in this article, which works very well.
Using Linux USB gadget - Need to capture eject event
But I can't figure out a way to detect the plug-in event. I need this information so that the device can stop collecting data and avoid crashing the file system. Detecting the power on status on USB pin is not a option since the usb port is also used as a charging interface.
But the kernel is aware of this event since it prints "g_multi gadget: high-speed config #1: Multifunction with CDC ECM" in the console.
My question is how can I extract the plug-in event from kernel in C?
Thanks in advanced.