Closed GoogleCodeExporter closed 9 years ago
Sorry, error in title : Script STOPS looping!
Original comment by cazauxfr...@gmail.com
on 10 Dec 2013 at 7:33
UPDATE :
I've just run the script in foreground for a while, and I got an exception
related to the temp sensor :
-----
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)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
-----
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...
Original comment by cazauxfr...@gmail.com
on 10 Dec 2013 at 8:22
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)
...
Original comment by tro...@trouch.com
on 10 Dec 2013 at 2:31
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.
Original comment by davidpau...@gmail.com
on 10 Dec 2013 at 7:31
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)
Original comment by tro...@trouch.com
on 10 Dec 2013 at 7:59
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 ?
Original comment by cazauxfr...@gmail.com
on 10 Dec 2013 at 8:09
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 -
Original comment by davidpau...@gmail.com
on 12 Dec 2013 at 8:04
indeed
Original comment by tro...@trouch.com
on 12 Dec 2013 at 10:16
Original comment by tro...@trouch.com
on 4 Jan 2014 at 9:00
Original comment by tro...@trouch.com
on 4 Jan 2014 at 9:01
temporarly fixed by r1421 - 1-Wire sensors return extremely low temperature
instead of None when reading error occurs
Original comment by tro...@trouch.com
on 31 Jan 2014 at 1:11
Original issue reported on code.google.com by
cazauxfr...@gmail.com
on 10 Dec 2013 at 7:31Attachments: