Home:ALL Converter>USB host hotplug detection in embedded usb gadget device

USB host hotplug detection in embedded usb gadget device

Ask Time:2019-11-28T21:36:24         Author:poseidon

Json Formatter

We are developing an embedded device running Linux, which needs to act as a usb serial gadget and connect to android phones for different types of data transfer. In order to initiate the communication with the host usb (android phone), I need to detect whenever the USB host is connected to the device. I came to know about writing udev rules in order to run an executable on usb host insertion/removal, but We already have a main C program that manages all of the device's main functionality. I would be running a thread in this program which would be responsible for this communication. Is there any way by which I can receive the USB hotplug event in this thread. I am really trying to avoid using loops in this thread so that it doesn't get CPU intensive. So is there any way by which I can receive the USB hotplug event?

Author:poseidon,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59090126/usb-host-hotplug-detection-in-embedded-usb-gadget-device
yy