seeed-studio / seeed_python_reterminal Goto Github PK
View Code? Open in Web Editor NEWThis is a Python library which enables you to use the onboard hardware on the reTerminal.
License: MIT License
This is a Python library which enables you to use the onboard hardware on the reTerminal.
License: MIT License
I tried to run test_led.py, it produced an error.
python test_led.py
STA ON, USR OFF
Traceback (most recent call last):
File "/home/pi/Downloads/Seeed_Python_ReTerminal/samples/test_led.py", line 7, in
rt.sta_led = True
File "/usr/local/lib/python3.9/dist-packages/seeed_python_reterminal/core.py", line 41, in sta_led
self.sta_led_green = value
File "/usr/local/lib/python3.9/dist-packages/seeed_python_reterminal/core.py", line 50, in sta_led_green
self.__write_to_file(_Core.__STA_LED_GREEN_BRIGHTNESS, "1" if value else "0")
File "/usr/local/lib/python3.9/dist-packages/seeed_python_reterminal/core.py", line 147, in __write_to_file
with open(file_name, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/leds/usr_led2/brightness'
Raspberry Pi CM4 inside ReSeed terminal running Debian Bookworm 64bit. OS/Python info:
sudoer@hostname:~/ $ lsb_release -d | tail -n 1
Description: Debian GNU/Linux 12 (bookworm)
sudoer@hostname:~/ $ pip3 --version
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)
sudoer@hostname:~/ $ python --version
Python 3.11.2
On Raspberry Pi systems running the latest stable Debian (Bookworm 12), the sudo pip3 install seeed-python-reterminal
installation procedure does not work:
sudoer@hostname:~/ $ sudo pip3 install seeed-python-reterminal
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
For more information visit http://rptl.io/venv
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
The reason why can be found in the raspberry pi docs, see Python on Raspberry Pi
From Bookworm onwards, packages installed via pip must be installed into a Python Virtual Environment using venv. This has been introduced by the Python community, not by Raspberry Pi; see PEP 668 for more details.
PEP 668 essentially recommends that system python packages should be installed using the system package manager, while user python packages should be installed inside a venv
.
Since seeed-python-reterminal
requires access to system-level files, and since there is no debian release of the package, the correct installation workflow is unclear.
Here are a couple ideas for changes to the installation instructions/workflow that should fix this problem.
I've included output from the README User LEDS Test script to show that these solutions should work.
--breaks-system-packages
flagThis is the fastest but least robust solution. Should look like this:
sudoer@hostname: $ sudo pip3 install seeed-python-reterminal --break-system-packages
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting seeed-python-reterminal
Downloading https://www.piwheels.org/simple/seeed-python-reterminal/seeed_python_reterminal-0.5-py3-none-any.whl (7.2 kB)
Requirement already satisfied: evdev in /usr/lib/python3/dist-packages (from seeed-python-reterminal) (1.6.1)
Installing collected packages: seeed-python-reterminal
Successfully installed seeed-python-reterminal-0.5
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Then:
sudoer@hostname:~/ $ sudo python ./user-leds-test.py
STA ON, USR OFF
STA OFF, USR ON
STA RED, USR OFF
STA OFF, USR OFF
.deb
of Seeed_Python_ReterminalThis would replace the "Install from Source" instructions, and remove the warning statements of using --breaks-system-packages
.
There are many ways to do this, here's one using stdeb
:
# Install debian dependencies
sudoer@hostname:~/ $ sudo apt install stdeb dh-python
# Download source
sudoer@hostname:~/ $ git clone https://github.com/Seeed-Studio/Seeed_Python_ReTerminal && cd ./Seeed_Python_ReTerminal
# Create .deb
sudoer@hostname:~/Seeed_Python_ReTerminal $ python3 setup.py --command-packages=stdeb.command debianize
sudoer@hostname:~/Seeed_Python_ReTerminal dpkg-buildpackage -b -us -uc
# Install .deb
sudoer@hostname:~/Seeed_Python_ReTerminal sudo apt install ../python3-seeed-python-reterminal
Then:
sudoer@hostname:~/ $ sudo python ./user-leds-test.py
STA ON, USR OFF
STA OFF, USR ON
STA RED, USR OFF
STA OFF, USR OFF
If there are any Debian Maintainers interested in maintaining this package, I think distributing a Debian package would be the most robust solution in the long run. I am not a Debian Maintainer.
The workflow would be:
sudo apt install python3-seeed-python-reterminal
The only issue with using venv
is the need for root
access to /sys/
folders, but that can be resolved, and users should be directed to this workflow anyway.
The following workflow works:
$ python -m venv --system-site-packages env
$ source env/bin/activate
(env) $ pip install seeed-python-reterminal
(env) $ sudo $(which python) ./user-leds-test.py
STA ON, USR OFF
STA OFF, USR ON
STA RED, USR OFF
STA OFF, USR OFF
The version of this library installed with pip
does not includes the property illuminance
from core.py
.
Tested in multiple reTerminals.
Install the library as per official instructions: sudo pip3 install seeed-python-reterminal
Start a python shell, import the module and try to read illuminance data:
import seeed_python_reterminal.core as rt
print(rt.illuminance)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: '_Core' object has no attribute 'illuminance'
The library version in pypi is 0.2, published on May 20. 2021, and matches the version 0.2 in setup.py
of this repo.
The illuminance property and example were added on June 15, 2021. Uploading a new version 0.3 to pypi might be necessary.
pip3 show seeed-python-reterminal
. Look for Location:
path.core.py
with CLI editor of choice (eg. nano, vim, etc).core.py
, match code in the main branch. __LIGHT_ILLUMINANCE = "/sys/bus/iio/devices/iio:device0/in_illuminance_input"
@property
def illuminance(self):
return int(self.__read_1st_line_from_file(_Core.__LIGHT_ILLUMINANCE))
Hi,
The reTerminal DM will be supported ?
Thank you
Hello, I have a problem with my reTerminal and I can’t find solutions online.
I had the problem with the reTerminal powering up a blank screen after the first boot.
So I flashed the 32 bit Raspbian-reTerminal image by following the instructions from : https://wiki.seeedstudio.com/reTerminal-FAQ/#q2-how-can-i-flash-raspberry-pi-os-which-is-originally-shipped-with-reterminal
The reTerminal is now working great except for bluetooth.
Indeed, after the first boot I type sudo systemctl status bluetooth
and I get this result :
bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:bluetoothd(8)
Sep 20 16:35:27 tgf systemd[1]: Condition check resulted in Bluetooth service being skipped.
Sep 20 16:36:56 tgf systemd[1]: Condition check resulted in Bluetooth service being skipped.
So I typed sudo modprobe btusb
and then started bluetooth manually, when I type sudo systemctl status bluetooth
I now get this result :
bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-09-20 16:37:18 BST; 1s ago
Docs: man:bluetoothd(8)
Main PID: 1569 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 4164)
CPU: 49ms
CGroup: /system.slice/bluetooth.service
└─1569 /usr/libexec/bluetooth/bluetoothd
Sep 20 16:37:18 tgf systemd[1]: Starting Bluetooth service...
Sep 20 16:37:18 tgf bluetoothd[1569]: Bluetooth daemon 5.55
Sep 20 16:37:18 tgf systemd[1]: Started Bluetooth service.
Sep 20 16:37:18 tgf bluetoothd[1569]: Starting SDP server
Sep 20 16:37:18 tgf bluetoothd[1569]: Bluetooth management interface 1.21 initialized
Now my problem is that when I type “hcitool dev” there is no device.
Also, I saw online that it could be a problem with the UART and when I type “sudo systemctl status hciuart.service” I get this result :
hciuart.service - Configure Bluetooth Modems connected by UART
Loaded: loaded (/lib/systemd/system/hciuart.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2023-09-20 16:35:49 BST; 4min 12s ago
Process: 557 ExecStart=/usr/bin/btuart (code=exited, status=1/FAILURE)
CPU: 68ms
Sep 20 16:35:19 tgf systemd[1]: Starting Configure Bluetooth Modems connected by UART...
Sep 20 16:35:49 tgf btuart[625]: Initialization timed out.
Sep 20 16:35:49 tgf btuart[625]: bcm43xx_init
Sep 20 16:35:49 tgf systemd[1]: hciuart.service: Control process exited, code=exited, status=1/FAILURE
Sep 20 16:35:49 tgf systemd[1]: hciuart.service: Failed with result 'exit-code'.
Sep 20 16:35:49 tgf systemd[1]: Failed to start Configure Bluetooth Modems connected by UART.
Does anyone have a solution for this? My goal is to be able to scan bluetooth devices around the reTerminal.
I bought a Bluetooth adapter : Asus USB-BT500 and plugged it to the reTerminal, it is recognized and I can scan bluetooth devices.
Does that mean that I have problem with the hardware in reTerminal or maybe I need to change some configurations in order to use bluetooth with the ReTerminal's hardware ?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.