bash-gps-logger.sh
Bash script reading the GPS serial port and filtering GGA messages for local storage.
The GNSS receiver is connected via USB or internal UART. Identify the correct tty device. The script filters GGA frames (global position). Ensure the GPS service is not already locked by RouterOS.
bash-gps-logger.sh
#!/bin/bash
# Assumes GPS is on /dev/ttyUSB2 or similar
DEVICE="/dev/ttyUSB2"
LOGFILE="/tmp/gps.log"
echo "Starting GPS Logger..."
# Configure baud rate if needed
stty -F $DEVICE 9600 cs8 -cstopb -parenb
while true; do
read -r line < $DEVICE
if [[ $line == \$GPGGA* ]]; then
echo "$(date): $line" >> $LOGFILE
echo "Logged: $line"
fi
done