Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • skyward-addons
  • dependabot/npm_and_yarn/generator/javascript/async-2.6.4
  • dependabot/npm_and_yarn/generator/javascript_stable/async-2.6.4
  • dependabot/npm_and_yarn/generator/javascript_stable/minimist-1.2.6
  • dependabot/npm_and_yarn/generator/javascript/minimist-1.2.6
  • pr-instance-vars2
  • davidbuzz-leapsecondsfix-1
  • OBC-2018
  • pr-improve-MAV_CMD-parameters
  • release
  • pr-gitignore
  • 2.4.29
  • 2.4.28
  • 2.4.27
  • 2.4.26
  • 2.4.25
  • 2.4.24
  • 2.4.23
  • 2.4.22
20 results

mavtest.py

Blame
    • Nik Langrind's avatar
      207212d8
      mavgen_python.py: fix sending of signed messages · 207212d8
      Nik Langrind authored
      Modified that method's python3 detection to check for
      class 'bytearray' as well as class 'bytes'. This fixes python3
      decoding of signed messages.
      
      Also changed examples/mavtest.py to pass a bytearray for the
      secret key instead of a string. This is required to send
      a signed message using python3.
      207212d8
      History
      mavgen_python.py: fix sending of signed messages
      Nik Langrind authored
      Modified that method's python3 detection to check for
      class 'bytearray' as well as class 'bytes'. This fixes python3
      decoding of signed messages.
      
      Also changed examples/mavtest.py to pass a bytearray for the
      secret key instead of a string. This is required to send
      a signed message using python3.
    apmsetrate.py NaN GiB
    #!/usr/bin/env python
    
    '''
    set stream rate on an APM
    '''
    from __future__ import print_function
    from builtins import range
    
    import sys
    
    from argparse import ArgumentParser
    parser = ArgumentParser(description=__doc__)
    
    parser.add_argument("--baudrate", type=int,
                      help="master port baud rate", default=115200)
    parser.add_argument("--device", required=True, help="serial device")
    parser.add_argument("--rate", default=4, type=int, help="requested stream rate")
    parser.add_argument("--source-system", dest='SOURCE_SYSTEM', type=int,
                      default=255, help='MAVLink source system for this GCS')
    parser.add_argument("--showmessages", action='store_true',
                      help="show incoming messages", default=False)
    args = parser.parse_args()
    
    from pymavlink import mavutil
    
    def wait_heartbeat(m):
        '''wait for a heartbeat so we know the target system IDs'''
        print("Waiting for APM heartbeat")
        m.wait_heartbeat()
        print("Heartbeat from APM (system %u component %u)" % (m.target_system, m.target_system))
    
    def show_messages(m):
        '''show incoming mavlink messages'''
        while True:
            msg = m.recv_match(blocking=True)
            if not msg:
                return
            if msg.get_type() == "BAD_DATA":
                if mavutil.all_printable(msg.data):
                    sys.stdout.write(msg.data)
                    sys.stdout.flush()
            else:
                print(msg)
    
    # create a mavlink serial instance
    master = mavutil.mavlink_connection(args.device, baud=args.baudrate)
    
    # wait for the heartbeat msg to find the system ID
    wait_heartbeat(master)
    
    print("Sending all stream request for rate %u" % args.rate)
    for i in range(0, 3):
        master.mav.request_data_stream_send(master.target_system, master.target_component,
                                            mavutil.mavlink.MAV_DATA_STREAM_ALL, args.rate, 1)
    if args.showmessages:
        show_messages(master)