From d0f7c4e411eaf16fece4295864148e7deecd81d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 26 Sep 2017 15:52:09 +0100 Subject: [PATCH 1/2] Improvements for deployment and reboot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - remove Disconnect from RebootDeviceAsync() - add optional parameter to GetDeviceInfoAsync() so the retrieval of the device information can be forced - remove backing field of NanoFrameworkDeviceInfo.Valid - bump NuGet package to 0.4.0-preview024 Signed-off-by: José Simões --- .../nanoFramework.Tools.DebugLibrary.Net.csproj | 2 +- .../MFDeployTool/NanoFrameworkDeviceInfo.cs | 13 ++++++------- .../NFDevice/NanoDeviceBase.cs | 10 ++++++++-- .../WireProtocol/Engine.cs | 2 -- .../nanoFramework.Tools.DebugLibrary.UWP.csproj | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj b/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj index 2ae22dd0..9d2a94c6 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj +++ b/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj @@ -16,7 +16,7 @@ nanoFramework.Tools.Debugger.Net - 0.4.0-preview023 + 0.4.0-preview024 This .NET library provides a debug client for nanoFramework devices using USB or Serial connection to a board. nanoFramework project contributors nanoFramework debug library for .NET diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs index 58974784..f5d7e2c7 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs @@ -16,7 +16,6 @@ namespace nanoFramework.Tools.Debugger class NanoFrameworkDeviceInfo : INanoFrameworkDeviceInfo { private NanoDeviceBase m_self; - private bool m_fValid; private List m_Domains = new List(); private List m_AssemblyInfos = new List(); @@ -25,7 +24,7 @@ public NanoFrameworkDeviceInfo(NanoDeviceBase device) { m_self = device; - m_fValid = false; + Valid = false; } public async Task GetDeviceInfo() @@ -42,7 +41,7 @@ public async Task GetDeviceInfo() // get assemblies from device await GetAssembliesAsync(cancelTSource.Token); - m_fValid = true; + Valid = true; return true; } @@ -52,14 +51,14 @@ private async Task GetAppDomainsAsync(CancellationToken cancellationToken) if (Dbg.Capabilities.AppDomains) { Commands.Debugging_TypeSys_AppDomains.Reply domainsReply = await Dbg.GetAppDomainsAsync(); - // TODO add cancelation token code + // TODO add cancellation token code if (domainsReply != null) { foreach (uint id in domainsReply.Data) { Commands.Debugging_Resolve_AppDomain.Reply reply = await Dbg.ResolveAppDomainAsync(id); - // TODO add cancelation token code + // TODO add cancellation token code if (reply != null) { m_Domains.Add(new AppDomainInfo(id, reply)); @@ -92,7 +91,7 @@ private async Task GetAssembliesAsync(CancellationToken cancellationToken) private Engine Dbg { get { return m_self.DebugEngine; } } - public bool Valid { get { return m_fValid; } } + public bool Valid { get; internal set; } public System.Version HalBuildVersion { @@ -170,7 +169,7 @@ public IAssemblyInfo[] Assemblies public override string ToString() { - if (m_fValid) + if (Valid) { try { diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs index fae59b58..dd140a04 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs @@ -108,10 +108,16 @@ public void StopCountdownForDispose() SuicideTimer.Change(Timeout.Infinite, Timeout.Infinite); } - public async Task GetDeviceInfoAsync() + /// + /// Get from device. + /// If the device information has been retrieved before this method returns the cached data, unless the force argument is true. + /// + /// Force retrieving the information from the device. + /// Return the for this device. + public async Task GetDeviceInfoAsync(bool force = true) { // start by checking if we already have this available - if (!DeviceInfo.Valid) + if (!DeviceInfo.Valid || force) { // seems to be invalid so get it from device var mfDeviceInfo = new NanoFrameworkDeviceInfo(this); diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs index 8eb196c4..439e2c8a 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs @@ -686,8 +686,6 @@ public async Task RebootDeviceAsync(RebootOption option = RebootOption.NormalReb await PerformRequestAsync(Commands.c_Monitor_Reboot, Flags.c_NoCaching, cmd, 0, 100); - Disconnect(); - if (option != RebootOption.NoReconnect) { //int timeout = 1000; diff --git a/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj b/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj index e4f040ca..9395b318 100644 --- a/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj +++ b/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj @@ -17,7 +17,7 @@ 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} nanoFramework.Tools.Debugger.UWP - 0.4.0-preview023 + 0.4.0-preview024 This UWP library provides a debug client for nanoFramework devices using USB or Serial connection to a board. nanoFramework project contributors nanoFramework debug library for UWP From 37053ac92b12a72302e4d563ac35c599c25e8292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Thu, 28 Sep 2017 11:10:36 +0100 Subject: [PATCH 2/2] Improve detection of device in initialized state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change return type of `IsDeviceInInitializeStateAsync()` to `Task<>` - Bump NuGet to 0.4.0-preview026 Signed-off-by: José Simões --- appveyor.yml | 2 +- .../nanoFramework.Tools.DebugLibrary.Net.csproj | 2 +- .../Extensions/DebuggerExtensions.cs | 5 +++-- .../nanoFramework.Tools.DebugLibrary.UWP.csproj | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8cc25e28..be173f93 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.25.{build} +version: 0.26.{build} pull_requests: do_not_increment_build_number: true diff --git a/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj b/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj index 4b5f4d27..9e5ee4bb 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj +++ b/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj @@ -16,7 +16,7 @@ nanoFramework.Tools.Debugger.Net - 0.4.0-preview025 + 0.4.0-preview026 This .NET library provides a debug client for nanoFramework devices using USB or Serial connection to a board. nanoFramework project contributors nanoFramework debug library for .NET diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs index 1cadb2e5..59d4ffb9 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs @@ -14,13 +14,14 @@ public static class DebuggerExtensions /// /// /// - public static async ValueTask IsDeviceInInitializeStateAsync(this Engine debugEngine) + public static async Task IsDeviceInInitializeStateAsync(this Engine debugEngine) { var result = await debugEngine.SetExecutionModeAsync(0, 0); if (result.success) { - return ((result.currentExecutionMode & WireProtocol.Commands.Debugging_Execution_ChangeConditions.c_State_Mask) == WireProtocol.Commands.Debugging_Execution_ChangeConditions.c_State_Initialize); + var currentState = (result.currentExecutionMode & WireProtocol.Commands.Debugging_Execution_ChangeConditions.c_State_Mask); + return (currentState != WireProtocol.Commands.Debugging_Execution_ChangeConditions.c_State_ProgramRunning); } else { diff --git a/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj b/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj index dfa9ee31..d0b3a9e3 100644 --- a/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj +++ b/source/nanoFramework.Tools.DebugLibrary.UWP/nanoFramework.Tools.DebugLibrary.UWP.csproj @@ -17,7 +17,7 @@ 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} nanoFramework.Tools.Debugger.UWP - 0.4.0-preview025 + 0.4.0-preview026 This UWP library provides a debug client for nanoFramework devices using USB or Serial connection to a board. nanoFramework project contributors nanoFramework debug library for UWP