This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Detecting USB host

Other Parts Discussed in Thread: AM1808

Hi al,

Short version of my question:

Is it possible for a Linux application to determine if a USB host is connected to its USB device port?  If yes, what is the suggested method to make the determination?

Longer version:

We are running Linux on an AM1808-based embedded system.  The system is powered from 5V that is provided to a USB mini-B connector.  Power is provided either by a host PC OR by an external wall brick.  Shortly after boot we would like to know whether power is being provided by the PC or by the wall brick.  We're hoping there is some way to call into the Linux USB device driver stack running on the AM1808 to determine if a host is present or not present. If it would help in the determination process, the Linux application could install the Linux driver (module) that causes the AM1808 appear as a mass storage device to the PC.

 

Thanks,

Doug

  • If connected to a linux PC then PC would enumerate the device and send SET_CONFIGURATION command at the end of enumeration. This can be used for this purpose. The correct place to look at would be the gadget driver (say file_storage) and check .setup() function where all setup request are handled.

    Ajay