From a1d9df3bb1ac6ba0d36abb4c24a9212c6646b534 Mon Sep 17 00:00:00 2001 From: josesimoes Date: Thu, 12 Mar 2020 15:46:53 +0000 Subject: [PATCH] Improve UpdateConfiguration command - Add "Done" field to signal target that the packet is the last one in the sequence. Signed-off-by: josesimoes --- .../WireProtocol/Commands.cs | 7 ++++--- .../WireProtocol/Engine.cs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs index a72c8500..c0126170 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs @@ -390,9 +390,10 @@ public class Monitor_UpdateConfiguration { public uint Configuration; public uint BlockIndex; - public uint Length = 0; - public uint Offset = 0; - public byte[] Data = null; + public uint Length; + public uint Offset; + public uint Done; + public byte[] Data; public class Reply { diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs index 36613954..d0874594 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs @@ -3589,6 +3589,19 @@ public bool UpdateDeviceConfiguration(DeviceConfiguration configuration) // get packet length, either the maximum allowed size or whatever is still available to TX int packetLength = Math.Min((int)WireProtocolPacketSize, count); + // check if this is the last chunk + if(count <= packetLength && + packetLength <= WireProtocolPacketSize) + { + // yes, signal that by setting the Done field + cmd.Done = 1; + } + else + { + // no, more data is coming after this one + cmd.Done = 0; + } + cmd.PrepareForSend(configurationSerialized, packetLength, position); IncomingMessage reply = PerformSyncRequest(Commands.c_Monitor_UpdateConfiguration, 0, cmd);