Skip to content

Commit b16c8dc

Browse files
committed
MAVFtp: dont override size on requests #2784
1 parent 1341c0f commit b16c8dc

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

ExtLibs/ArduPilot/Mavlink/MAVFtp.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,8 @@ public MemoryStream kCmdReadFile(string file, int size, CancellationTokenSource
14781478
Progress?.Invoke(file, 100);
14791479
_mavint.UnSubscribeToPacketType(sub);
14801480
answer.Position = 0;
1481+
if (!timeout.Complete)
1482+
return null;
14811483
if (ex != null)
14821484
throw ex;
14831485
return answer;
@@ -2182,8 +2184,14 @@ public struct FTPPayloadHeader
21822184
static public implicit operator byte[](FTPPayloadHeader value)
21832185
{
21842186
if (value.data == null)
2187+
{
21852188
value.data = new byte[251 - 12];
2186-
value.size = (byte) (value.data.Length);
2189+
}
2190+
else
2191+
{
2192+
value.size = (byte)(value.data.Length);
2193+
}
2194+
21872195
value.data = value.data.MakeSize(251 - 12);
21882196
return MavlinkUtil.StructureToByteArray(value);
21892197
}

ExtLibs/ArduPilot/Mavlink/MAVLinkInterface.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ public async Task<MAVLinkParamList> getParamListMavftpAsync(byte sysid, byte com
17021702
frmProgressReporter.UpdateProgressAndStatus(i, $"Getting Param MAVFTP {sysid}-{compid}");
17031703
};
17041704
return ftp.GetFile(
1705-
"@PARAM/param.pck", cancel, false, 110);
1705+
"@PARAM/param.pck", cancel, true, 110);
17061706
});
17071707
while (!paramfileTask.IsCompleted)
17081708
{

Log/MavlinkLog.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,13 @@ private async void BUT_convertcsv_Click(object sender, EventArgs e)
10411041
string text = "";
10421042
mine.DebugPacket(packet, ref text, false, ",");
10431043

1044+
if(packet.data is MAVLink.mavlink_file_transfer_protocol_t)
1045+
{
1046+
var msg = (MAVLink.mavlink_file_transfer_protocol_t)packet.data;
1047+
ArduPilot.Mavlink.MAVFtp.FTPPayloadHeader ftphead = msg.payload;
1048+
text = text.TrimEnd() + ", " + ftphead.ToString() + Environment.NewLine;
1049+
}
1050+
10441051
if (!String.IsNullOrEmpty(text))
10451052
sw.Write(mine.lastlogread.ToString("yyyy-MM-ddTHH:mm:ss.fff") + "," + text);
10461053
}

0 commit comments

Comments
 (0)