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?

closed as unclear what you're asking by Sean Houlihane, Ghanima, Aurora0001 Apr 26 '17 at 13:56

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What embedded system are you using? – Helmar Apr 5 '17 at 16:53
  • I m using STM32 micro controllers ,for programming i m using embedded c. – Nagaraj Hegde Apr 5 '17 at 16:58
  • If power from USB disappears then the UART-USB converter was unplugged, so check if it is enough for you to monitor supply voltage from USB. – Bence Kaulics Apr 5 '17 at 17:49
  • 3
    This is not an IoT question. You would probably get a better answer elsewhere, for instance at electronics.stackexchange.com – Mawg Apr 6 '17 at 6:54
  • 2
    This sort of question is really best asked on EE.SE. Without reference to a specific IoT OS, there is nothing which makes it likely that the experts here will know much about this specific subject. EE.SE has orders of magnitude more experience available to you. For example electronics.stackexchange.com/questions/52285 might help. – Sean Houlihane Apr 26 '17 at 6:58
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).

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

  • This has nothing to do with the question which was asked. The functionality you refer to is a host side API, while the question asks from the perspective of a device. Additionally the question itself is off topic and does not belong here. – Chris Stratton Apr 24 '17 at 19:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.