Page 1 of 1

getState raises exception 51 (Unknown Value)

Posted: Thu Jan 10, 2019 12:41 am
by Nadav
With an 1012 i/o board, in the channel attach event, calling the channel getState sometime returns exception 51 EPHIDGET_UNKNOWNVAL.
It is not consistent - sometimes it happens, sometimes not.

Stack trace:
File "/home/pi/Envs/djhome/lib/python3.6/site-packages/Phidget22/Devices/", line 127, in getState
raise PhidgetException(result)
Phidget22.PhidgetException.PhidgetException: 51

I am unable to understand why/when.

Can you kindly suggest how i can better debug?

Re: getState raises exception 51 (Unknown Value)

Posted: Mon Jan 14, 2019 10:32 am
by jdecoux
Is it a digital input channel that is failing to get the state?

If so, then problems calling getState from the attach handler are likely caused by trying to access the state of the input before the device has had a chance to report its state to your program.

Try giving the input more time to receive the state from the device before polling for it, or catch the exception so your program can try again later.

Re: getState raises exception 51 (Unknown Value)

Posted: Mon Jan 14, 2019 1:00 pm
by Patrick
What is the version of your 1012?

Input state should never be undefined in the attach handler for the 1012, unless it is a very old 1012.

Can you post a snippet of Python code which causes the exception?


Re: getState raises exception 51 (Unknown Value)

Posted: Wed Jan 16, 2019 2:06 am
by Nadav
Root cause was not calling channel.close() during process termination.
This caused intermittent exceptions the next time the process was started.

Can this be better handled by the Phidget Python library itself, by registering to atexit?

Thanks everyone for your helpful suggestions!