I have been trying to find a solution for 2 days but I wasn't able to find one. I want to change the permission of the /dev/ttyAMA0 but seems to be impossible. I tried with sudo chmod 777 /deb/ttyAMA0 but at the following minute the port recovered old permissions for read, write and execute. The next thing that I tried was writing an udev rule with the following code: KERNEL=="ttyAMA0", MODE="0777, but nothing end with success.
I want to read information from an antenna that is connected on the serial port ttyAMA0, the problem is that I am not able to read the information unless I will give read permissions.
When I try to sudo adduser $USER tty
the output is the following:The user pi' is already a member of tty'. Moreover, when I execute a script to access the /dev/ttyAMA0 the result is:
Permission denied: '/dev/ttyAMA0'.
I have these permissions on ttyAMA0 port:
crw--w---- 1 root tty 204, 64 Jul 5 11:15 ttyAMA0
the output of lsof /dev/ttyAMA0
is the following:
agetty 800 root 0u CHR 204,64 0t0 1157 /dev/ttyAMA0
agetty 800 root 1u CHR 204,64 0t0 1157 /dev/ttyAMA0
agetty 800 root 2u CHR 204,64 0t0 1157 /dev/ttyAMA0
I used this command to kill the process:
sudo systemctl stop serial-getty@ttyAMA0.service
Now I am able to change the permissions without any automatic change in permissions each minute. The problem now is that each time I reboot the Raspberry the permissions change to the default configuration.
I switched the serial ports ttyAMA0
and ttyS0
to get a better control of the Baudrate, that is the reason why the ttyAMA0
port has crw--w----
instead of crw-rw----
.
I don't know what else I can do.