dyvardana / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

Temperature Exception when 1-Wire returns None #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Don't know exactly. The script and html attached. After a while (like 2h30), 
the server is still running but the loop does not run anymore. Don't have any 
error in log. Could it be too much HTTP requests ? But HTTP requests still work.
2.
3.
...

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!

Original issue reported on code.google.com by cazauxfr...@gmail.com on 10 Dec 2013 at 7:31

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, error in title : Script STOPS looping!

Original comment by cazauxfr...@gmail.com on 10 Dec 2013 at 7:33

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
indeed

Original comment by tro...@trouch.com on 12 Dec 2013 at 10:16

GoogleCodeExporter commented 9 years ago

Original comment by tro...@trouch.com on 4 Jan 2014 at 9:00

GoogleCodeExporter commented 9 years ago

Original comment by tro...@trouch.com on 4 Jan 2014 at 9:01

GoogleCodeExporter commented 9 years ago
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