getState raises exception 51 (Unknown Value)

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

getState raises exception 51 (Unknown Value)

Postby Nadav » Thu Jan 10, 2019 12:41 am

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: 59
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: getState raises exception 51 (Unknown Value)

Postby jdecoux » Mon Jan 14, 2019 10:32 am

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: 3039
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: getState raises exception 51 (Unknown Value)

Postby Patrick » Mon Jan 14, 2019 1:00 pm

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: 10
Joined: Fri Jan 13, 2017 1:50 am
Contact:

Re: getState raises exception 51 (Unknown Value)

Postby Nadav » Wed Jan 16, 2019 2:06 am

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/3850261/doing-something-before-program-exit

Thanks everyone for your helpful suggestions!


Return to “Python”

Who is online

Users browsing this forum: No registered users and 1 guest