@@ -59,6 +59,7 @@ def __init__(self, mpstate, name, description, **args):
59
59
60
60
def gui_menu_items (self ):
61
61
return [
62
+ MPMenuItem ('FTP' , 'FTP' , '# %s ftp' % self .command_name ()),
62
63
MPMenuItem ('Clear' , 'Clear' , '# %s clear' % self .command_name ()),
63
64
MPMenuItem ('List' , 'List' , '# %s list' % self .command_name ()),
64
65
MPMenuItem (
@@ -863,6 +864,8 @@ def commands(self):
863
864
print ("%s module not available; use old compat modules" % str (self .itemtype ()))
864
865
return
865
866
return {
867
+ "ftp" : self .wp_ftp_download ,
868
+ "ftpload" : self .wp_ftp_upload ,
866
869
"clear" : self .cmd_clear ,
867
870
"list" : self .cmd_list ,
868
871
"load" : (self .cmd_load , ["(FILENAME)" ]),
@@ -962,7 +965,7 @@ def request_list_send(self):
962
965
mission_type = self .mav_mission_type ())
963
966
964
967
def wp_ftp_download (self , args ):
965
- '''Download wpts from vehicle with ftp'''
968
+ '''Download items from vehicle with ftp'''
966
969
ftp = self .mpstate .module ('ftp' )
967
970
if ftp is None :
968
971
print ("Need ftp module" )
@@ -971,7 +974,7 @@ def wp_ftp_download(self, args):
971
974
ftp .cmd_get ([self .mission_ftp_name ()], callback = self .ftp_callback , callback_progress = self .ftp_callback_progress )
972
975
973
976
def ftp_callback_progress (self , fh , total_size ):
974
- '''progress callback from ftp fetch of mission'''
977
+ '''progress callback from ftp fetch of mission items '''
975
978
if self .ftp_count is None and total_size >= 10 :
976
979
ofs = fh .tell ()
977
980
fh .seek (0 )
@@ -987,18 +990,18 @@ def ftp_callback_progress(self, fh, total_size):
987
990
self .mpstate .console .set_status ('Mission' , 'Mission %u/%u' % (done , self .ftp_count ))
988
991
989
992
def ftp_callback (self , fh ):
990
- '''callback from ftp fetch of mission'''
993
+ '''callback from ftp fetch of mission items '''
991
994
if fh is None :
992
995
print ("mission: failed ftp download" )
993
996
return
994
997
magic = 0x763d
995
998
data = fh .read ()
996
999
magic2 , dtype , options , start , num_items = struct .unpack ("<HHHHH" , data [0 :10 ])
997
1000
if magic != magic2 :
998
- print ("mission : bad magic 0x%x expected 0x%x" % (magic2 , magic ))
1001
+ print ("%s : bad magic 0x%x expected 0x%x" % (self . itemtype (), magic2 , magic ))
999
1002
return
1000
- if dtype != mavutil . mavlink . MAV_MISSION_TYPE_MISSION :
1001
- print ("mission : bad data type %u" % dtype )
1003
+ if dtype != self . mav_mission_type () :
1004
+ print ("%s : bad data type %u" % ( self . itemtype (), dtype ) )
1002
1005
return
1003
1006
1004
1007
self .wploader .clear ()
@@ -1051,11 +1054,11 @@ def wp_ftp_upload(self, args):
1051
1054
except Exception as msg :
1052
1055
print ("Unable to load %s - %s" % (filename , msg ))
1053
1056
return
1054
- print ("Loaded %u waypoints from %s" % (self .wploader .count (), filename ))
1055
- print ("Sending mission with ftp" )
1057
+ print ("Loaded %u %s from %s" % (self .wploader .count (), self . itemstype (), filename ))
1058
+ print ("Sending %s with ftp" % self . itemstype () )
1056
1059
1057
1060
fh = SIO ()
1058
- fh .write (struct .pack ("<HHHHH" , 0x763d , mavutil . mavlink . MAV_MISSION_TYPE_MISSION , 0 , 0 , self .wploader .count ()))
1061
+ fh .write (struct .pack ("<HHHHH" , 0x763d , self . mav_mission_type () , 0 , 0 , self .wploader .count ()))
1059
1062
mavmsg = mavutil .mavlink .MAVLink_mission_item_int_message
1060
1063
for i in range (self .wploader .count ()):
1061
1064
w = self .wploader .wp (i )
@@ -1074,18 +1077,18 @@ def wp_ftp_upload(self, args):
1074
1077
fh = fh , callback = self .ftp_upload_callback , progress_callback = self .ftp_upload_progress )
1075
1078
1076
1079
def ftp_upload_progress (self , proportion ):
1077
- '''callback from ftp put of mission '''
1080
+ '''callback from ftp put of items '''
1078
1081
if proportion is None :
1079
1082
self .mpstate .console .set_status ('Mission' , 'Mission ERR' )
1080
1083
else :
1081
1084
count = self .wploader .count ()
1082
1085
self .mpstate .console .set_status ('Mission' , 'Mission %u/%u' % (int (proportion * count ), count ))
1083
1086
1084
1087
def ftp_upload_callback (self , dlen ):
1085
- '''callback from ftp put of mission '''
1088
+ '''callback from ftp put of items '''
1086
1089
if dlen is None :
1087
- print ("Failed to send waypoints" )
1090
+ print ("Failed to send %s" % self . itemstype () )
1088
1091
else :
1089
1092
mavmsg = mavutil .mavlink .MAVLink_mission_item_int_message
1090
1093
item_size = mavmsg .unpacker .size
1091
- print ("Sent mission of length %u in %.2fs" % ((dlen - 10 ) // item_size , time .time () - self .upload_start ))
1094
+ print ("Sent %s of length %u in %.2fs" % (self . itemtype (), (dlen - 10 ) // item_size , time .time () - self .upload_start ))
0 commit comments