Not compatible on Pi 4 #354

Closed
opened 2020-10-17 00:02:14 +01:00 by Arsenal10108 · 4 comments
Arsenal10108 commented 2020-10-17 00:02:14 +01:00 (Migrated from github.com)

It looks like the Adafruit_DHT library is deprecated and not compatible on the PI4 as the platform Detect doesn't know about the BCM 2711 chipset, thinks its not a PI.

Adafuits site says that they support the CircuitPython Libraries, Which do work on the Pi4 is there a work around for this or a way to get the plugin to work on a PI4?

It looks like the Adafruit_DHT library is deprecated and not compatible on the PI4 as the platform Detect doesn't know about the BCM 2711 chipset, thinks its not a PI. Adafuits site says that they support the CircuitPython Libraries, Which do work on the Pi4 is there a work around for this or a way to get the plugin to work on a PI4?
haplm commented 2020-10-17 22:13:28 +01:00 (Migrated from github.com)

I've got in working in shell (for python3) by following instruction here:
https://github.com/adafruit/Adafruit_Python_DHT

pi@octopi:~/Adafruit_Python_DHT/examples $ ./AdafruitDHT.py 22 5
Temp=23.3*  Humidity=54.2%

Unfortunately it doesn't work inside the plugin:

2020-10-17 23:03:53,219 - octoprint.plugins.enclosure - INFO - Failed to execute python scripts, try disabling use SUDO on advanced section of the plugin.
2020-10-17 23:03:53,222 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments:
("a bytes-like object is required, not 'str'",)
I've got in working in shell (for python3) by following instruction here: https://github.com/adafruit/Adafruit_Python_DHT ``` pi@octopi:~/Adafruit_Python_DHT/examples $ ./AdafruitDHT.py 22 5 Temp=23.3* Humidity=54.2% ``` Unfortunately it doesn't work inside the plugin: ``` 2020-10-17 23:03:53,219 - octoprint.plugins.enclosure - INFO - Failed to execute python scripts, try disabling use SUDO on advanced section of the plugin. 2020-10-17 23:03:53,222 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments: ("a bytes-like object is required, not 'str'",) ```
haplm commented 2020-10-17 22:52:50 +01:00 (Migrated from github.com)

I think I found it:
456497f7e6/octoprint_enclosure/init.py#L880

It invokes python2, so this has to be changed to python3.

Then there's a problem with decoding the response.

temp, hum = stdout.split("|")

has to be changed to

temp, hum = stdout.decode().split("|")

I will create pull request tomorrow

I think I found it: https://github.com/vitormhenrique/OctoPrint-Enclosure/blob/456497f7e67067514e1711b0566db8988037897c/octoprint_enclosure/__init__.py#L880 It invokes python2, so this has to be changed to python3. Then there's a problem with decoding the response. ```temp, hum = stdout.split("|")``` has to be changed to ```temp, hum = stdout.decode().split("|")``` I will create pull request tomorrow
haplm commented 2020-10-18 13:40:50 +01:00 (Migrated from github.com)

Actually, while my fix works for my specific environment, the situation is more complicated should this be deployed to others. The way how Enclosure plugin is written means that it is invoking python scripts via shell, instead of calling the code internally. And this is a problem with all the scripts.

Should this method be used going forward, it requires configurable python interpreter (2.7 vs. 3x), and perhaps even different handling of certain things (like .decode() needed before .split() on 3.x).

Try fixing your local installation in ~/oprint/lib/python3.7/site-packages/octoprint_enclosure and let me know if you need some help. I will open a separate issue around this.

Actually, while my fix works for my specific environment, the situation is more complicated should this be deployed to others. The way how Enclosure plugin is written means that it is invoking python scripts via shell, instead of calling the code internally. And this is a problem with all the scripts. Should this method be used going forward, it requires configurable python interpreter (2.7 vs. 3x), and perhaps even different handling of certain things (like .decode() needed before .split() on 3.x). Try fixing your local installation in ```~/oprint/lib/python3.7/site-packages/octoprint_enclosure``` and let me know if you need some help. I will open a separate issue around this.
vitormhenrique commented 2020-10-19 20:40:13 +01:00 (Migrated from github.com)

this is all gonna be part of python 3 support as I'm ditching all those old libraries and changing the entire thing...

https://github.com/vitormhenrique/OctoPrint-Enclosure/issues/302

this is all gonna be part of python 3 support as I'm ditching all those old libraries and changing the entire thing... https://github.com/vitormhenrique/OctoPrint-Enclosure/issues/302
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#354