scripts: rename read-mavlink -> test-mavlink with writings
Signed-off-by: Onur Özkan <work@onurozkan.dev>
This commit is contained in:
1 parent
18eb01fb3a
commit
2d35d935b4
2 files changed
+35
-14
No files matched your search
@@ -1,14 +0,0 @@
|
||||
#!/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]} <serial-device>")
|
||||
|
||||
connection = mavutil.mavlink_connection(sys.argv[1], baud=115200)
|
||||
while message := connection.recv_match(blocking=True):
|
||||
print(message)
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
from pymavlink import mavutil
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(f"usage: {sys.argv[0]} <serial-device>")
|
||||
|
||||
connection = mavutil.mavlink_connection(sys.argv[1], baud=115200)
|
||||
next_timesync = 0.0
|
||||
next_ping = 0.0
|
||||
ping_sequence = 0
|
||||
|
||||
while True:
|
||||
now = time.monotonic()
|
||||
if now >= next_timesync:
|
||||
connection.mav.timesync_send(0, time.monotonic_ns() // 1_000)
|
||||
next_timesync = now + 0.2
|
||||
|
||||
if now >= next_ping:
|
||||
connection.mav.ping_send(
|
||||
int(time.time_ns() // 1_000),
|
||||
ping_sequence,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
ping_sequence = (ping_sequence + 1) & 0xFFFFFFFF
|
||||
next_ping = now + 0.1
|
||||
|
||||
while message := connection.recv_match(blocking=False):
|
||||
print(message)
|
||||
|
||||
time.sleep(0.01)
|
||||
Reference in new issue
Block a user