Page 1 of 1

Open phidget in the attach handler

Posted: Tue Sep 27, 2016 7:39 am
by joss@jossgray.net
Hi,

I'm using a the Manager object and an handler for the AttachEventHandler to detect Phidgets on startup of my application.

The handler is called correctly but the Device in the argments (which is an interface kit), has attached as true but no available sensors.

If I call open on that device, I get the Unsupported exception. “Not Supported.”.

What state are phidgets in when in the attach handler?

Re: Open phidget in the attach handler

Posted: Tue Sep 27, 2016 10:57 am
by mparadis
Phidgets are received as generic Phidget objects when they are detected by the manager. You have to typecast them to the appropriate Phidget object before having access to it's special members. Have a look at this page for a full explanation, and look at the "HelloWorld" example for your language to see the code for the manager.

Re: Open phidget in the attach handler

Posted: Wed Sep 28, 2016 9:13 am
by joss@jossgray.net
Yep, I already cast to the correct type before using open or any other method.

Re: Open phidget in the attach handler

Posted: Wed Sep 28, 2016 9:31 am
by Patrick
Phidgets you get back from a Manager are informational only - you can read the serial number, class, name, etc. but they aren't opened. If you want to interact with one, you have to create a new Phidget object of the correct type and call open on it.

Usually you won't want to use the manager at all, unless you don't know what kinds of Phidgets will be used with your system. If you do know what Phidgets you want to open, just create and open them and wait for their attach events.

-Patrick

Re: Open phidget in the attach handler

Posted: Wed Sep 28, 2016 10:03 am
by joss@jossgray.net
I see, so if I am using multiple interface kits, I should create a single InterfaceKit instance, hook the attach event, and then each event will contain a valid InterfaceKit instance?