Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 5.0.0 #280

Merged
merged 11 commits into from
Jul 10, 2024
Merged

🚀 5.0.0 #280

merged 11 commits into from
Jul 10, 2024

Conversation

… Pi 5 (#274)

* move to gpiozero

* fix: use same relay object

* fix: inverted state

* fix(driver): add class method for get_or_create_Relay

* fix(driver): fix xor

* fix(__init__): remove useless space

* fix(driver): remove to_return + add explicit pin_factory + fix xor

* feat: drop support to py<=3.8

* fix(test): fix test_driver

* fix(test_driver): revert test data + fix test + add get_or_create test

* fix(test): remove test_driver_get_or_create

* fix(test): fix init tests

* fix(driver): add typing to relays list + fix mypy config

* fix(test): remove unused import

* fix(driver+test): remove Trailing whitespaces
@RobinTail RobinTail added enhancement New feature or request release Chores for releasing new versions breaking Breaking changes dependencies labels Jul 9, 2024
@coveralls
Copy link

coveralls commented Jul 9, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 05da3a3 on develop
into ee7e2f0 on master.

@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

🚀 5.0.0a4 is published, @ch3p4ll3 .
Please install/upgrade to it from the Pre-release channel and let me know how it works with Raspberry Pi 5.

https://github.com/borisbu/OctoRelay/releases/download/5.0.0a4/release.zip

@RobinTail RobinTail mentioned this pull request Jul 9, 2024
@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

I'm getting the following error in logs when running on Raspberry Pi 4 (OctoPi* 1.0.0, build 2023.06.27.080047 — latest):

    import _lgpio
ImportError: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.33' not found (required by /home/pi/oprint/lib/python3.9/site-packages/_lgpio.cpython-39-arm-linux-gnueabihf.so)

Looks like I can not upgrade it with the currently installed OS.
The latest version available is 2.31

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

How did you installed octoprint and the plugin? I tried the lib also on my pi3b+ creating a new venv and works without any problem.

Edit: Oh, it's octopi

@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

Octopi 1.0 is Debian "bullseye" RpiOS 2022-09-22, @ch3p4ll3
https://github.com/guysoft/OctoPi/releases/tag/1.0.0

The most frustrating to me is that lgpio installed on it without any issues, but failed to operate in runtime.
Meaning that there is no compatibility check at all.

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

Could you try manually install the library?

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

I'll also try also in my 3B+ with octopi

@RobinTail
Copy link
Collaborator Author

Could you try manually install the library?

I installed it, @ch3p4ll3 , but it I think it should also somehow be connected to python (instead of regular pip install lgpio)

install -m 0644 lgpio.h                  /usr/local/include
install -m 0644 rgpio.h                  /usr/local/include
install -m 0755 liblgpio.so.1 /usr/local/lib
install -m 0755 librgpio.so.1 /usr/local/lib
install -m 0755 rgpiod                   /usr/local/bin
install -m 0755 rgs                      /usr/local/bin
install -m 0644 rgpiod.1                 /usr/local/man/man1
install -m 0644 rgs.1                    /usr/local/man/man1
install -m 0644 lgpio.3                  /usr/local/man/man3
install -m 0644 rgpio.3                  /usr/local/man/man3
ldconfig
/usr/bin/python3
/usr/bin/python3

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

I think I found the problem. the package libc6-dev in the repo is too old. Current version is: 2.38, while octopi has 2.31 and lgpio needs at least 2.33. I found out that bullseye last version is 2.31

So, I don't think there are many chances to get this work on Octopi if they don't update to bookworm :(

@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

Exactly, @ch3p4ll3 , my findings were similar.
Related issue: guysoft/OctoPi#823

Looks like they can not enable camera streaming on it yet.

@RobinTail
Copy link
Collaborator Author

Anyway, does it work on Raspberry 5 with another OS, @ch3p4ll3 ?
Do you see the buttons? Do they operate relays?

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

yeah, I already tested it when I was developing in my fork. Btw I have an idea. We can use different PinFactories based on the system.

For example:

  • We know that bullseye has libc < 2.33, and octopi still does not support Pi5 so rpi.GPIO still works -> we can use rpi.GPIO factory
  • bookworm has libc > 2.33, raspbian usually comes with this version -> we can use lgpio factory

Or try with lgpio and in case fallback to rpi.GPIO

@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

That's a great idea, @ch3p4ll3 . Yes, Bullseye has ldd version 2.31. If you could make it select the proper factory somehow, that would make it compatible with current OctoPi.
But my knowledge and expertise is limited in this field: I'm not sure how to detect which factory to use.
I hope you'll find a way

@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

Btw, I read that gpiozero can decide on the factory itself, somehow, if you don't define it explicitly. Maybe we can install both and it will choose the right one?
Sounds a bit optimistic probably.

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

Btw, I read that gpiozero can decide on the factory itself, somehow, if you don't define it explicitly. Maybe we can install both and it will choose the right one? Sounds a bit optimistic probably.

Yeah we can try, Idk if it will also work with Pi5, I think it'll depend on the "loading" order of the pins factories

@ch3p4ll3
Copy link
Contributor

ch3p4ll3 commented Jul 9, 2024

Ok, just tested. the first pinFactory that gpiozero tries is lgpio, so I think this will work. Tomorrow I'll make some commits and test in my Pi5

@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 9, 2024

I found the list of default factories used in the specific order when none is specified:
https://github.com/gpiozero/gpiozero/blob/f3a338e56c28dd2d904016b3a8594f82c47da291/gpiozero/devices.py#L273-L286

* fix(driver): remove explicit PinFactory (to be tested)

* fix(setup): add RPi.GPIO
@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 10, 2024

🚀 5.0.0a5 published, @ch3p4ll3
Please check that is still works on Raspberry 5.
I will check on my 4 with Octopi.

@ch3p4ll3
Copy link
Contributor

Yep, still working on my Pi5

@RobinTail
Copy link
Collaborator Author

✅ Regression test on Raspberry Pi 4 with OctoPi 1.0.0 (Bullseye) passed!
Thank you @ch3p4ll3

@RobinTail
Copy link
Collaborator Author

Yep, still working on my Pi5

Perfect! I think it's a great achievement. I highly appreciate your effort and I'm glad with our collaboration.

I'm going to perform some chores and make a couple more tests before the final release.
Thank you so much, @ch3p4ll3

tests/test_init.py Outdated Show resolved Hide resolved
* Drop Python 3.7 (EOL).

* Type constraints for the list of Tasks.

* Revert "Type constraints for the list of Tasks."

This reverts commit 946f697.

* Removing typing-extensions.
* Restore standalone xor in driver.

* Ref: Simpler truthy condition in Relay::toggle().

* Simpler conditional invocation of on/off in Relay::toggle().

* Reusing xor() in the condition of Relay::get_or_create_relay().
@RobinTail RobinTail added the refactoring Better implementation of the same thing label Jul 10, 2024
@RobinTail
Copy link
Collaborator Author

🚀 5.0.0rc1
✅ QA passed

* Renaming Relay::relays to cache.

* Renaming Relay::get_or_create_relay() to ensure().

* Renaming class Relay to Driver.

* Renaming Driver::relay to handle.

* Fix test suite name.

* Renaming to DriverMock in main test.
@RobinTail RobinTail marked this pull request as ready for review July 10, 2024 13:56
@RobinTail
Copy link
Collaborator Author

RobinTail commented Jul 10, 2024

🚀 5.0.0rc2
✅ Regression test passed

@ch3p4ll3 , please confirm one last time that the version 5.0.0rc2 still works on Raspberry Pi 5

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@RobinTail RobinTail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready

@ch3p4ll3
Copy link
Contributor

image
I think something broke. The request return 400, CSRF validation failed

@RobinTail
Copy link
Collaborator Author

Try to refresh the page hardly (Cmd+Shift+R) or re-login, @ch3p4ll3
CSRF means that the session key of the UI does not match the running API (probably after the update)

@ch3p4ll3
Copy link
Contributor

uh nice, yep still working

@RobinTail RobinTail added the documentation Improvements or additions to documentation label Jul 10, 2024
@RobinTail RobinTail merged commit 52f5c4b into master Jul 10, 2024
31 checks passed
@RobinTail
Copy link
Collaborator Author

Marketplace listing update: OctoPrint/plugins.octoprint.org#1311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking changes dependencies documentation Improvements or additions to documentation enhancement New feature or request refactoring Better implementation of the same thing release Chores for releasing new versions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Buttons not showing on Raspberry Pi 5 Task: Drop Python 3.7 (EOL)
3 participants