Page 1 of 1

PhidgetInterfaceKit 8/8/8 1018_2

Posted: Mon Aug 05, 2024 12:16 pm
by sfergusson
I am using a older PhidgetInterfaceKit 8/8/8 1018_2. Using the Phidget22 library with C/C++ on a Windows 10 machine. When reading the digital inputs I call the function PhidgetDigitalInput_getState(). I expect a value of 0 returned when the input is LOW, and a 1 when the input is HIGH. However, occasionally I start getting a value of 2 returned by this function. I have had this happen both when the input is high and when it is low.

What would cause this to happen? What does a value of 2 signify, what state is it supposed to be?

Re: PhidgetInterfaceKit 8/8/8 1018_2

Posted: Tue Aug 06, 2024 12:16 pm
by jdecoux
A returned value of 2 from PhidgetDigitalInput_getState() is a signifier for "Unknown". This typically occurs if you try and poll the value too soon after opening the device, before it has a chance to report its actual state.

You can also check the return code [code = PhidgetDigitalInput_getState()], which in this case would give you "EPHIDGET_UNKNOWNVAL". In languages other than C, this would throw an exception, but users of C must be more vigilant.