# Need to know when USB is connected to host PC

**URL:** <https://forum.legato.io/t/need-to-know-when-usb-is-connected-to-host-pc/6227>\
**Category:** Legato Application Framework\
**Created:** [June 14, 2022, 3:54pm UTC](https://forum.legato.io/t/need-to-know-when-usb-is-connected-to-host-pc/6227 "2022-06-14T15:54:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnottage](https://avatars.discourse-cdn.com/v4/letter/g/58f4c7/32.png) [@gnottage](https://forum.legato.io/u/gnottage)\
**Post date:** [June 14, 2022, 3:54pm UTC](https://forum.legato.io/t/need-to-know-when-usb-is-connected-to-host-pc/6227/1 "2022-06-14T15:54:20Z")

</div>

My application needs to know when there is an active host PC connection. We are using http over the USB ecm IP link, and as this is stateless cannot determine if the connection is there or not. Is there an API in Legato that can be queried that will indicate if the USB is connected to a host PC?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 14, 2022, 4:03pm UTC](https://forum.legato.io/t/need-to-know-when-usb-is-connected-to-host-pc/6227/2 "2022-06-14T16:03:42Z")

</div>

you can use unsandboxed application to read  
/sys/devices/78d9000.usb/power\_supply/usb/online:

> [@USB link to the board](https://forum.legato.io/t/usb-link-to-the-board/5872/2):
>
> how about this? root@swi-mdm9x28-wp:/sys/bus/platform/drivers# cat /sys/devices/78d9000.usb/power\_supply/usb/online 1 root@swi-mdm9x28-wp:/sys/bus/platform/drivers# cat /sys/devices/78d9000.usb/power\_supply/usb/online 0

---

<div class="post-metadata">

**Author:** ![gnottage](https://avatars.discourse-cdn.com/v4/letter/g/58f4c7/32.png) [@gnottage](https://forum.legato.io/u/gnottage)\
**Post date:** [June 15, 2022, 8:24am UTC](https://forum.legato.io/t/need-to-know-when-usb-is-connected-to-host-pc/6227/3 "2022-06-15T08:24:11Z")

</div>

Thank you, this is just what I’m looking for 🙂
