Using 2020-12-02-raspios-buster-armhf-lite I have a GPS that outputs TTL connected to the UART pins (pins 4, 6, 8, 10) with serial login disabled. After first booting up I can see output from the GPS if I cat /dev/serial0 (output masked for privacy).
$ cat /dev/serial0 | tr [0-9] X
$GPGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,XX*XX
$GPGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX*XX
$GLGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,,XX,XX,XXX,XX,XX,XX,XXX,*XE
$GLGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,,XX,XX,XXX,*XX
$GNGLL,XXXX.XXXXX,N,XXXXX.XXXXX,W,XXXXXX.XX,A,A*XX
^C
I can also run a python program to receive output.
$ cat gps.py
#!/usr/bin/python3
import serial
import re
sp = serial.Serial('/dev/serial0', 9600, timeout=1.0)
sp.flushInput()
while True:
try:
data = sp.read_until()
print(re.sub('[0-9]', 'X', data.decode('ascii')))
except serial.SerialTimeoutException:
print('Timeout.')
continue
except KeyboardInterrupt:
print('Interrupt.')
break;
print('Exiting...')
sp.close()
$ ./gps.py
$GPGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,,XX,XX,XXX,XX*XC
$GPGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,XX*XD
$GPGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX*XX
$GLGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,,XX,XX,XXX,XX,XX,XX,XXX,XX*XX
$GLGSV,X,X,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,XX,XX,XX,XXX,*XX
^CInterrupt.
Exiting...
However, after running the python program I can no longer see output from cat /dev/serial0. The command returns immediately and no output is produced. I can rerun the python program and see output, but can no longer see anything from cat /dev/serial0 until I reboot. Can someone tell me why that is?