From f25a698483d34c0069236a8235b6af4c51ef5edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Sun, 19 Jul 2026 14:58:23 +0300 Subject: [PATCH] scripts: add test script for reading mavlink messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- .gitignore | 3 +++ scripts/read-mavlink.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 scripts/read-mavlink.py diff --git a/.gitignore b/.gitignore index ad67955..9393706 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ target # These are backup files generated by rustfmt **/*.rs.bk +# Python bytecode caches +__pycache__/ + # MSVC Windows builds of rustc generate these, which store debugging information *.pdb diff --git a/scripts/read-mavlink.py b/scripts/read-mavlink.py new file mode 100755 index 0000000..674d1d0 --- /dev/null +++ b/scripts/read-mavlink.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +# NixOS: nix-shell -p 'python313.withPackages (ps: [ ps.pymavlink ps.pyserial ])' --run './scripts/read-mavlink.py /dev/ttyUSB0' + +import sys + +from pymavlink import mavutil + +if len(sys.argv) != 2: + sys.exit(f"usage: {sys.argv[0]} ") + +connection = mavutil.mavlink_connection(sys.argv[1], baud=115200) +while message := connection.recv_match(blocking=True): + print(message)