diff --git a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs index 9a0ef98a..1936f006 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs @@ -59,7 +59,7 @@ internal set public bool IsIdle() { - return (DateTime.UtcNow - _lastActivity).TotalMilliseconds > 100; + return (DateTime.UtcNow - _lastActivity).TotalMilliseconds > 50; } public bool Send(MessageRaw raw) diff --git a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs index 1ec8e913..356700e8 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs @@ -453,10 +453,7 @@ public bool UpdateDebugFlags() stateFlagsToSet |= Commands.DebuggingExecutionChangeConditions.State.DebuggerQuiet; } - SetExecutionMode(stateFlagsToSet, 0); - - // done here - return true; + return SetExecutionMode(stateFlagsToSet, 0); } // device isn't connected diff --git a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs index ac967b1b..8e289f0f 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs @@ -40,10 +40,23 @@ public WireProtocolRequest(OutgoingMessage outgoingMessage, int millisecondsTime internal bool PerformRequest(IController controller) { + const int sleepTimeMs = 10; + int attemptsCount = 10000 / sleepTimeMs; + // wait for controller to be idle - while(!controller.IsIdle()) + while ( + !controller.IsIdle() && + attemptsCount > 0) { Thread.Sleep(10); + + attemptsCount--; + } + + if(attemptsCount == 0) + { + // timeout waiting for idle controller + return false; } Debug.WriteLine($"Performing request"); @@ -67,6 +80,9 @@ internal bool PerformRequest(IController controller) return true; } + // store start time + RequestTimestamp = DateTime.Now; + return false; }