question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Received IndexError instead of SensorNotReadyError from get_raw_sensor_strings() when reading DS18B20

See original GitHub issue

I am having a few DS18B20 sensors connected to raspberry pi zero. From time to time the contents of the file /sys/bus/w1/devices/28.../w1_slave appears to be empty (not sure why). Hence the contents of the list data in the method get_raw_sensor_strings() in file async_core.py is empty as well. Accessing it raises an IndexError.

Changing line 65 in file async_core.py from:

     if (
            data[0].strip()[-3:] != "YES" or "00 00 00 00 00 00 00 00 00" in data[0]
        ):  # pragma: no cover
            raise SensorNotReadyError(self) 

to

     if (
           not data or data[0].strip()[-3:] != "YES" or "00 00 00 00 00 00 00 00 00" in data[0]
        ):  # pragma: no cover
            raise SensorNotReadyError(self) 

resolves the problem.

Thanks.

PS: I am using version w1thermsensor 2.0.0a1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
timofurrercommented, Sep 13, 2020

I’ve released v2.0.0a2

1reaction
timofurrercommented, Aug 31, 2020

Thanks for the report. We’ve already fixed that for the non-async version of the code, see #94 .

I’ve made the same change now in the async code and will release asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DS18b20 No Longer Working - "List INdex Out of Range"
I just installed them in my project, but now the sensors are not being picked up. The board lights up, so it is...
Read more >
python - IndexError DS18B20 Temperature sensor
When I run it as root I get an error (line 9) device_folder = glob.glob(base_dir + '28-000005b89af')[0] IndexError: list index out of range...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found