Last active
February 19, 2025 21:26
-
-
Save heathhenley/33bc0ebf656ed93263eeb5f2e00da5e8 to your computer and use it in GitHub Desktop.
Check bauds until it looks like it might be good nmea data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
import serial.tools.list_ports | |
import sys | |
# Common NMEA baud rates | |
BAUD_RATES = [4800, 9600, 38400, 115200] | |
def main(): | |
# Find available COM ports | |
ports = [port.device for port in serial.tools.list_ports.comports()] | |
print("Available COM Ports:", ports) | |
# Check if there are any ports | |
if not ports: | |
print("❌ No COM ports found.") | |
input("Press ENTER to Exit...") | |
return 0 | |
valid_combos = [] | |
for port in ports: | |
print(f"Checking {port}...") | |
for baud in BAUD_RATES: | |
try: | |
with serial.Serial(port, baud, timeout=2) as ser: | |
line = ser.readline().decode(errors="ignore").strip() | |
if line.startswith("$"): # NMEA sentences start with "$" | |
print(f" ✅ NMEA Stream detected on {port} at {baud} baud - data: {line}") | |
valid_combos.append((port, baud)) | |
except Exception: | |
pass # Ignore errors and keep scanning | |
if valid_combos: | |
print("✅ Valid NMEA Streams Found:") | |
for port, baud in valid_combos: | |
print(f" - {port} at {baud} baud") | |
else: | |
print("❌ No NMEA stream detected.") | |
# Pause for user to see the results if they clicked the icon to run | |
input("Press ENTER to Exit...") | |
return 0 | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment