Closed bee-mois closed 5 months ago
core.py of this repo probably has the same problem. though it does not explicitly stop with an error. if stopped with strg-c it prints:
(.venv) mepi@testpi:~ $ ds18b20-datalogger
^CTraceback (most recent call last):
File "/home/mepi/datalogger/.venv/bin/ds18b20-datalogger", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/mepi/datalogger/.venv/lib/python3.11/site-packages/ds18b20_datalogger/cli.py", line 5, in main
reading = read_ds18b20_sensor_matrix()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mepi/datalogger/.venv/lib/python3.11/site-packages/ds18b20_datalogger/core.py", line 149, in read_ds18b20_sensor_matrix
tc = read_temp(folder)
^^^^^^^^^^^^^^^^^
File "/home/mepi/datalogger/.venv/lib/python3.11/site-packages/ds18b20_datalogger/core.py", line 37, in read_temp
temp = try_temp(device_file)
^^^^^^^^^^^^^^^^^^^^^
File "/home/mepi/datalogger/.venv/lib/python3.11/site-packages/ds18b20_datalogger/core.py", line 47, in try_temp
lines = read_temp_raw(device_file + "/w1_slave")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mepi/datalogger/.venv/lib/python3.11/site-packages/ds18b20_datalogger/core.py", line 29, in read_temp_raw
lines = f.readlines()
^^^^^^^^^^^^^
File "<frozen codecs>", line 319, in decode
KeyboardInterrupt
NameError: name 'temp_ir_1_1' is not defined. Did you mean: 'temp_ir_3_1'?
core.py of this repo probably has the same problem.
Regarding the error you are describing, I don't think that core.py
has this problem. It has been mitigated by just defining all the variables unconditionally, like this:
It's all totally redundant 🙈, but it was the easiest way to fix that flaw on behalf of the current program architecture.
i see. so we close this. because this repo is about core.py (and not some antedescendents).
if one sensor is offline, the whole script is stopping with an error:
how could the script be changed so that it finishes even if one or more sensors are offline and the available values are logged?
(temp-matrix_5x6.py refers to the main script before its name change to core.py.)