1

I want to check if UART usb is connected to PC or not from my embedded program. Is there any indication line I can get in usb to connect to interrupt pin to detect from.embedded setup? From PC side I can get indication of usb connected and disconnected. But I want to know from embedded hardware side.

Details : Data will be sending continuously from embedded setup to PC through usb as soon as usb disconnected from PC I need to take some action in setup. For that I need to get indication of disconnect. It is time critical task so I can't add any heartbeat to keep both in sink.

Is there any other line indication through usb?

anonymous2
  • 4,902
  • 3
  • 22
  • 49

2 Answers2

3

The UART protocol (in its simplest form) has no presence detection. All you can do is monitor the data which is being transmitted (in both directions). This assumes that your USB-UART bridge is external to the STM32.

If the STM32 itself is providing the USB endpoint, then there will be status available from the USB peripheral (as described in the reference manual for the part).

Sean Houlihane
  • 10,524
  • 2
  • 26
  • 62
1

On Android, a discovery devices functionality is implemented, maybe you can also implement it on your embedded device or at least find an API that provides it.

Discovering a device

Your application can discover USB devices by either using an intent filter to be notified when the user connects a device or by enumerating USB devices that are already connected. Using an intent filter is useful if you want to be able to have your application automatically detect a desired device. Enumerating connected USB devices is useful if you want to get a list of all connected devices or if your application did not filter for an intent.

developer.androind.com source

Snake Sanders
  • 961
  • 1
  • 6
  • 12