Skip to content

Commit

Permalink
Python example10.py and param reset
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Jul 7, 2020
1 parent 97918e3 commit dcad7dd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Scripts/example10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import clr
import MissionPlanner
clr.AddReference("MAVLink")
from System import Func, Action
import MAVLink

def OtherMethod(message):
print "got HB";
return True

def MyMethod(message):
print("STATUSTEXT from MAV.SubscribeToPacketType")
print(message.data.text)
return True

def MyPacketHandler(o, message):
try:
if message.msgid == MAVLink.MAVLINK_MSG_ID.STATUSTEXT.value__:
print "STATUSTEXT from MyPacketHandler " + str(message.sysid) + " " + str(message.compid)
print dir(message)
print(bytes(message.data.text))
except Exception as inst:
print inst

sub = MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.HEARTBEAT.value__, Func[MAVLink.MAVLinkMessage, bool] (OtherMethod))
sub2 = MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.STATUSTEXT, Func[MAVLink.MAVLinkMessage,
bool] (MyMethod))
sub3 = MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.STATUSTEXT_LONG, Func[MAVLink.MAVLinkMessage,
bool] (MyMethod))

MAV.OnPacketReceived += MyPacketHandler

import time
while True:
time.sleep(1)
24 changes: 24 additions & 0 deletions Scripts/wipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# cs.???? = currentstate, any variable on the status tab in the planner can be used.
# Script = options are
# Script.Sleep(ms)
# Script.ChangeParam(name,value)
# Script.GetParam(name)
# Script.ChangeMode(mode) - same as displayed in mode setup screen 'AUTO'
# Script.WaitFor(string,timeout)
# Script.SendRC(channel,pwm,sendnow)
#

print 'Start Script'

mrev = Script.GetParam("SYSID_SW_MREV")
fmtv = Script.GetParam("FORMAT_VERSION")
if mrev > 0:
print Script.ChangeParam("SYSID_SW_MREV",0)
if fmtv > 0:
print Script.ChangeParam("FORMAT_VERSION",0)

Script.Sleep(1)

MAV.doReboot()

print 'Reset complete'

0 comments on commit dcad7dd

Please sign in to comment.