Servers by jDrones

Want to learn more about using "BaseStream" .read/.write

So been fiddling around with the command BaseStream with mission planner script cabability with a simulated copter inside mission planner. What I want to succed with is to write a python script that is able to read all messages seperatelly and trigger phyton code based on the data that comes in.

Not been able to test BaseStream.write but I’m guessing it sends whatever data you specify to or from the drone.

What I’m having issues with is that sometimes I will use and get some data that is not following the correct format. I was guessing that I might need to wait for a heartbeat or some kind of timing to know when to read and that I will just read garbage if I read when the drone might not send any data.

This is the script that I made based on some of the example scripts that came with Mission planner. I’m very new in python so qritique would be nice <3 . This code will with no hesitation create a big array with 1001 bytes (as I cannot find any data on how big these blocks(?) that .read will read) and populate it with whatever will give out. I then print out the messages inside this data dump as I belive the format should look like. Start with 253 for MAVLink V.2 and then the lenght of the payload +11 bytes for non payload data. It seems to be able to isolate most messages, but sometimes I get messages that do not start with 253 or 254 (MAVLink V.1/V.2). Would also be nice to know if I’m getting all messages through this method or if this might miss a ton of them. This code should work on a new copy of Mission Planner.

import clr
import MissionPlanner
import time
from System import Byte
from System import Array

import MAVLink

fail = 0

while 1 == 1:
    index = 0
    amount = 0
    print '\n'
    while a[index] != 0:
        print a[index:index+a[1]+12]
        index = index+a[index+1]+12

Why do you want to reinvent the wheel?. Just subscribe the packet types that you need or use MAV.OnPacketReceived callback.
Here is the example MissionPlanner/ at master · ArduPilot/MissionPlanner (

? :grinning:


Seems Example 10 is not included in the scripts for Mission planner stable version and there is no other script example with the “Subscribe to package type” function. Will look into it though ^^

What I wanna do is to have a seperate Python script running on the drone that will look at the MAV messages and trigger a GStreamer pipeline to take photos of two cameras at the same time.

But making a seperate message and using that might be the better way to do it. However there does not seem to be a good tutorial for this for less knowledgebal people.

Well it seems Michael forgot to add those to the build script :frowning:
If you want to add separate message then you have to touch the Flight Controller code, which is normally not an easy thing.
What kind of trigger messages do you look for ?

Also, If you know c# then you can write a plugin for Mission planner which can access everything instead of the perl script.

I’m using a Navio 2 so the autopilot is run on a raspberry pi if that makes it simpler, all traffic is also sent over the internet and not through a radio. Was trying to add a simple message to the mission planner source and then building it but getting a lot of errors (not related to the edit I made) >.<

I know very little in the ways of coding at all.

Servers by jDrones