Code: Select all
uname -r
5.4.72-v7l+
Code: Select all
ls -l /dev/serial0
lrwxrwxrwx 1 root root 5 Nov 22 00:07 /dev/serial0 -> ttyS0
pi@raspberrypi:~ $ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Nov 22 00:07 /dev/ttyS0
Code: Select all
pi@raspberrypi:~ $ python3 -m mh_z19
{"co2": 395}
Code: Select all
ls -l /dev/ttyS0
crw--w---- 1 root tty 4, 64 Nov 22 00:09 /dev/ttyS0
Code: Select all
python3 -m mh_z19
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/serial0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/mh_z19/__init__.py", line 60, in mh_z19
ser = connect_serial()
File "/home/pi/.local/lib/python3.7/site-packages/mh_z19/__init__.py", line 56, in connect_serial
timeout=1.0)
File "/home/pi/.local/lib/python3.7/site-packages/serial/serialutil.py", line 240, in __init__
self.open()
File "/home/pi/.local/lib/python3.7/site-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/serial0: [Errno 13] Permission denied: '/dev/serial0'
null
Code: Select all
sudo chmod g+r /dev/ttyS0
Code: Select all
python3 -m mh_z19
Whats wrong here? Since I'm not root the script shouldn't be able to change group and permission of /dev/ttyS0
Trying it manually fails, as expected.
Code: Select all
pi@raspberrypi:~ $ chmod g-r /dev/ttyS0
chmod: changing permissions of '/dev/ttyS0': Operation not permitted