To view the output of a device connected to UART4 on the BBB (I’ve got a 9600 baud GPS device sending data to P9.11) first set the RX pin to the correct pin mode. I running Debian on the BBB by the way.
config-pin P9.11 uart
Then view the streaming data with
cat /dev/ttyO4
and view the serial port speed and other settings with
stty -F /dev/tty04
I use Notepad++ to write Python scripts on the BBB. The NppFTP plugin lets me connect remotely over the network and edit my Python scripts. To find the IP address of the BBB on my network I run
nmap -p 22 --open -sV 10.0.0.0/24
and look for the device that has a Texas Instruments MAC address and is running Debian.
Here is the Python code I use to get the GPS time from the serial port:
import serial
run(['config-pin', 'P9.11', 'uart'])
ser = serial.Serial('/dev/ttyO4') # open serial port
ser.baudrate = 9600
ser.timeout = 1
print(ser.name) # check which port was really used
message = ser.readline()
message = str(message)
message = message.split(',')
mtype = message[0].split('$')[1]
if mtype == 'GPRMC':
time = message[1]
if len(time)<9:
time = '0' + time
hours = int(time[0:2])
minutes = int(time[2:4])
seconds = int(time[4:6])