boards/kakute-f7-mini-v3: add selectable motor outputs

Signed-off-by: Onur Özkan <work@onurozkan.dev>
This commit is contained in:
Onur Özkan committed 2026-07-25 21:55:07 +03:00
1 parent 4a5d0313ca
commit 117e1abe97
12 files changed
+987 -88

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
"""Small MAVLink command-line debugger for a Kaptan flight controller."""
import argparse
import os
import sys
import time
def parse_arguments():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("serial_device", help="serial device connected to the flight controller")
parser.add_argument("command", choices=("arm", "disarm", "read"))
parser.add_argument("--baud", type=int, default=115200, help="serial baud rate (default: 115200)")
parser.add_argument("--system-id", type=int, default=1, help="target MAVLink system ID (default: 1)")
parser.add_argument(
"--component-id", type=int, default=1, help="target MAVLink component ID (default: 1)"
)
return parser.parse_args()
def print_messages(connection, timeout):
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
message = connection.recv_match(blocking=True, timeout=deadline - time.monotonic())
if message is None:
return None
print(message)
yield message
def send_arm_command(connection, mavutil, arguments, armed):
for _ in range(3):
connection.mav.command_long_send(
arguments.system_id,
arguments.component_id,
mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
0,
1.0 if armed else 0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
)
for message in print_messages(connection, timeout=1.0):
if (
message.get_type() == "COMMAND_ACK"
and message.command == mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM
):
return
action = "arm" if armed else "disarm"
raise SystemExit(f"timed out waiting for {action} acknowledgement")
def read_messages(connection):
try:
while True:
message = connection.recv_match(blocking=True, timeout=1.0)
if message is not None:
print(message)
except KeyboardInterrupt:
pass
def main():
arguments = parse_arguments()
# Kaptan currently accepts MAVLink 2 frames only.
os.environ["MAVLINK20"] = "1"
from pymavlink import mavutil
connection = mavutil.mavlink_connection(arguments.serial_device, baud=arguments.baud)
if arguments.command == "read":
read_messages(connection)
else:
send_arm_command(connection, mavutil, arguments, armed=arguments.command == "arm")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
sys.exit(130)
-35
View File
@@ -1,35 +0,0 @@
#!/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)