Page 1 of 1

Detect hub connected to USB

Posted: Sat Dec 19, 2020 6:59 pm
by carnaby
I'm trying to detect connection and disconnection of a VINT Hub from the USB port in C# and cannot figure out how to do it from the available documentation. Anyone know how to do this? I can open a phidget voltage ratio input and then disconnect and reconnect the USB cable and the attached and detached events for the individual sensors fire and work, but how to detect initially that the HUB is not connected and subsequently when I plug it in?

Re: Detect hub connected to USB

Posted: Mon Dec 21, 2020 10:26 am
by fraser
The best way to monitor the state of devices being attached/detached is through the Manager object. There are examples of how to use it available. If you want something specifically for the Hub object alone, you can create a Phidget22.Hub object with attach/detach handlers similar to the other sensors you've worked with

Re: Detect hub connected to USB

Posted: Sun Jan 03, 2021 12:03 am
by carnaby
Starting to make sense but I'm not able to get my code working exactly. Can you point me to the examples? I'm having a hard time finding a C# example that opens the manager or a hub and uses their attach/detach events.

Re: Detect hub connected to USB

Posted: Sun Jan 03, 2021 2:56 pm
by carnaby
I think I have this figured out. I read more documentation and it's making sense. Especially these points:

Be sure to register Attach and Detach event handlers for the Manager before opening it, to ensure you program doesn't miss the events reported for devices already connected to your system.

A Phidget is attached after it has been opened and the Phidget library finds and connects to the corresponding hardware device.
Most API calls are only valid on attached Phidgets.