How to enable and get access to GPIO Uart (ttyAMA0) at Pi3

Hello

This is the Solution to get ttyAMA0 working:
add to config.txt:

dtoverlay=pi3-miniuart-bt

open terminal connection and use these commands:

sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service
sudo systemctl mask serial-getty@ttyAMA0.service

to get access with user created python script you have to edit accessrights with (use this after every reboot):

sudo chmod 666 /dev/ttyAMA0

this is my python testscript:

import os
import serial

os.popen(‘sudo chmod 666 /dev/ttyAMA0’)

ser = serial.Serial(
port=’/dev/ttyAMA0’,
baudrate=38400,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=None)

print(’[%s] connected’ % ser.portstr)
count = 1

try:
while True:
message = ser.read_until(’\r’).strip()
if message != ‘’:
print(‘Line %s: %s’ % (count, message))
count += 1

except KeyboardInterrupt:
pass

ser.close()
print(’\n[%s] closed’ % ser.portstr)

Old Request:
Yesterday and today I tried more hours to get the GPIO Uart ttyAMA0 working on Pi3.
My aim is to use the GPIO Uart for Communication to/from Arduinow with Kodi Addon with Baud 38400.

After lot of dtoverlay and systemctl (from lot of outdated websites) i got the message output with simple python script. But i have to run the script with sudo.:

deleted code…

The messages came in, but there are some other messages between, like “password incorrect” “osmc login:”
Do you know what it is, and how to disable this stuff?

Could you tell me how to get access without sudo and kill the confuse messages between?

And yes, i did found the threads in this forum, but i mean these are outdated also.

the image what i’m using is: OSMC_TGT_rbp2_20180316.img.gz

regards

Disable the Getty or auto-login. It depends on what you’re actually trying to do.

sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.sservice

only “mutes” osmc at ttyAMA0 till the next reboot.
what are the further commands to get it working all the time?

after every re-/boot i have to run:

sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service
sudo chmod -v 666 /dev/ttyAMA0

is there a way fix it all the time?

The getty systemd service is generated at boot time by a binary executable /lib/systemd/system-generators/systemd-getty-generator

You’ll probably be able to prevent it from creating the service if you run

sudo systemctl mask serial-getty@ttyAMA0.sservice