I try to open serial port, but cant with permission. But works with sudo.
How i can get permission for serial port?
sas@sas-linuxmint ~ $groups sas
sas : sas adm tty dialout cdrom sudo dip plugdev lpadmin sambashare
This my code:
def get_serial_port():
ser_devs = [dev for dev in os.listdir('/dev') if dev.startswith('tty')]
for i in ser_devs:
port = "/dev/" + i
try :
ser = serial.Serial(port, 19200)
if ser.is_open:
print("OPEN!!!!!!!!!!!!!!!!!!!!!! {}".format(port))
ser.close()
except serial.SerialException as e:
print(e, port)
return None
output:
[Errno 13] could not open port /dev/ttyprintk: [Errno 13] Permission denied: '/dev/ttyprintk' /dev/ttyprintk
for all ports.
I tried change mod for port, but it doesn't work too
sudo chmod 766 /dev/ttyS10
sudo chmod -R a+rw /dev/ttyS10
sudo chmod 777 /dev/ttyS10
sudo chmod 666 /dev/ttyS10
/dev/ttyprintk
;-) – Alfe