Go to the documentation of this file.00001
00002
00003 '''
00004 test mavlink messages
00005 '''
00006
00007 import sys, struct, time, os
00008 from curses import ascii
00009
00010 from pymavlink import mavtest, mavutil
00011
00012 from argparse import ArgumentParser
00013 parser = ArgumentParser(description=__doc__)
00014
00015 parser.add_argument("--baudrate", type=int,
00016 help="master port baud rate", default=115200)
00017 parser.add_argument("--device", required=True, help="serial device")
00018 parser.add_argument("--source-system", dest='SOURCE_SYSTEM', type=int,
00019 default=255, help='MAVLink source system for this GCS')
00020 args = parser.parse_args()
00021
00022 def wait_heartbeat(m):
00023 '''wait for a heartbeat so we know the target system IDs'''
00024 print("Waiting for APM heartbeat")
00025 msg = m.recv_match(type='HEARTBEAT', blocking=True)
00026 print("Heartbeat from APM (system %u component %u)" % (m.target_system, m.target_system))
00027
00028
00029 master = mavutil.mavlink_connection(args.device, baud=args.baudrate, source_system=args.SOURCE_SYSTEM)
00030
00031
00032 wait_heartbeat(master)
00033
00034 print("Sending all message types")
00035 mavtest.generate_outputs(master.mav)
00036