Posted by cazauxfrederick
What steps will reproduce the problem?
WebIOPi version used? => 0.6
Python version used? => 0.6 included
Distro used? (WebIOPi has only been tested on Raspbian Wheezy) => Raspbian Wheezy
Raspberry Pi board revision? (1 or 2) =>Rev 2
For Javascript side bugs, Browser? =>Chrome for Windows and Chrome for Androïd
Please provide any additional information below.
Thanx for your help!
Files attached
Posted by cazauxfrederick
Sorry, error in title : Script STOPS looping!
Posted by cazauxfrederick
UPDATE :
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner self.run() File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/utils.py", line 78, in run self.func() File "/usr/share/webiopi/htdocs/thermostat/thermostat.py", line 40, in loop tempc = round(tmp.getCelsius()-1, 1)
So, i guess this is what happens too when in background. I just wonder why I can't see it in /var/log/webiopi ?
But I have a temporary solution to try : add an exception on getCelcius() method in order it doesn't stop if an error occurs with it.
I'll let you know about next steps...
Posted by trouch
1-Wire sensors sometimes does not work. You have to test the result before using it :
temp = tmp.getCelsius() if (temp != None): tempc = round(temp-1, 1) ...
Posted by davidpaulmiller
Question: Is the exception occurring in the assigning of tempc, or the calling of tmp.getCelsius()? If it occurs in tmp.getCelsius(), it is too late for us to test the result before using it at our code level, it already has failed... I think cazauxfr...@gmail.com has the right idea in adding an exception to getCelsius() method.
Posted by trouch
your stack trace is self explaining getCelsius returns None, without throwing any error. your error occur then, when your trying to do None-1 (temp being replaced by its value which is None)
Posted by cazauxfrederick
Yep... So I've added an exception on "tempc = round(tmp.getCelcius()-1, 1)". And that does the trick ! The tempc keeps its last value when the error occurs and doesn't affect the rest of the script. I've also added a variable in which I log the time of errors. That let me see that it happens compeletly randomly (or at least I can't figure a situation where it occurs).
Thank you for your help...
I still don't understand why I couldn't see those errors in the "/var/log/webiopi" when the script ran in background. What's the difference between the stack displayed in foreground and what is stored in the log file ?
Posted by davidpaulmiller
Interesting - I don't know if you notice in my exception *(issue 66) that it looks as though the exception is thrown in the Celsius2Fahrenheit call:
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/__init__.py", line 93, in Celsius2Fahrenheit return value * 1.8 + 32 TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
I've worked around my issue by calling getCelsius(), adding the test for null, and then converting to Fahrenheit myself -
Posted by trouch
indeed
Posted by trouch
Posted by trouch
Posted by trouch
temporarly fixed by r1421 - 1-Wire sensors return extremely low temperature instead of None when reading error occurs