getState raises exception 51 (Unknown Value)

Supporting 2.7 and 3.2+
Post Reply
Nadav
Phidgetsian
Posts: 11
Joined: Fri Jan 13, 2017 1:50 am
Contact:

getState raises exception 51 (Unknown Value)

Post 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/DigitalInput.py", 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?
jdecoux
Labview Developer
Posts: 180
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: getState raises exception 51 (Unknown Value)

Post 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.
User avatar
Patrick
Lead Developer
Posts: 634
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: getState raises exception 51 (Unknown Value)

Post 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?

-Patrick
Nadav
Phidgetsian
Posts: 11
Joined: Fri Jan 13, 2017 1:50 am
Contact:

Re: getState raises exception 51 (Unknown Value)

Post 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?
See https://stackoverflow.com/questions/385 ... ogram-exit

Thanks everyone for your helpful suggestions!
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests