Author Topic: USB detection on Linux Embedded  (Read 12298 times)

nstjean

  • Member
  • ***
  • Posts: 6
USB detection on Linux Embedded
« 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

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research

nstjean

  • Member
  • ***
  • Posts: 6
Re: USB detection on Linux Embedded
« Reply #2 on: May 02, 2016, 10:17:12 am »
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.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB detection on Linux Embedded
« Reply #3 on: May 02, 2016, 08:26:51 pm »
What will the device do with the information?

Typically, a device learns of attach/detach by detecting the presence/absence of VBUS.

nstjean

  • Member
  • ***
  • Posts: 6
Re: USB detection on Linux Embedded
« Reply #4 on: May 03, 2016, 10:53:38 am »
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.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB detection on Linux Embedded
« Reply #5 on: May 03, 2016, 04:58:54 pm »