PORTS Forum
Ports and Interfaces => USB => Topic started by: nstjean on April 28, 2016, 03:10:21 pm
-
Hi,
On a phyCORE-AM335x running Linux, I am trying to detect when USB cable is connect and disconnect. Is there a way to handle interrupt or event on USB from withing a main application?
I noticed that the interrupt count in /proc/interrupt for "musb-hdrc.0" increases when cable is connect/disconnected.
Yet, I have tried using libudev, without success.
A message is displayed on terminal when connecting and disconnecting USB cable between PC and board.
"[...] musb Haptic controller gadget disconnected" and "[...] Haptic Controller: high-speed #1: 2mA, Haptic controller [...] Haptic Controller: Using interface 0"
Any advice or comment will be appreciated
Thanks
-
Maybe this will help:
http://unix.stackexchange.com/questions/28548/how-to-run-custom-scripts-upon-usb-device-plug-in
-
Thanks Jan,
This link gave me hints, but, I did not manage to trig an event when connecting and disconnecting the usb cable. When I run "udevadm monitor", there is no event displayed upon cable connection or disconnection.
On my setup, the phyCore is the device, and I wish to detect when the PC (host) is connected or not. The detection is on the phyCORE side (linux embedded).
I have also been looking for a detection of the power USB from PC, found nothing yet.
-
What will the device do with the information?
Typically, a device learns of attach/detach by detecting the presence/absence of VBUS.
-
The idea is to know when to open and close the handle on the USB device, depending of existing link or not between device and PC.
-
Some ideas here:
https://e2e.ti.com/support/embedded/linux/f/354/t/65332