From 27a1a1b3b9244856f80a0198f1603615a94f0d31 Mon Sep 17 00:00:00 2001 From: edleno2 Date: Fri, 7 May 2021 21:39:17 -0700 Subject: [PATCH] Fix initialization of Expires to use DateTimeOffset.MaxValue Logic was using DateTime.MaxValue which could establish a value that is later adjusted for time zone. DateTimeOffset.MaxValue is already set to UTC which is the default for DateTimeOffset. Additional problem was in Engine.cs - there are a couple of of commands that are used in the test harness that need to be declared as public so they can be tested. Added some comments in PortSerialManager.cs about the possibility of eating non-serial problems in the try/catch block. Fix #742 --- .../PortSerial/PortSerialManager.cs | 2 +- .../WireProtocol/Engine.cs | 4 ++-- .../WireProtocol/WireProtocolRequest.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/PortSerialManager.cs b/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/PortSerialManager.cs index 0fb3063b..a60bde89 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/PortSerialManager.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/PortSerialManager.cs @@ -611,7 +611,7 @@ private bool CheckValidNanoFrameworkSerialDevice(NanoDevice de } } } - catch + catch (Exception /* ex */) // we could eat simple programming errors here - like a bad cast or other problem when changing code { // "catch all" required because the device open & check calls might fail for a number of reasons // if there is a deviceID, remove it from cache, just in case diff --git a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs index d00a4c4e..e50a0f17 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs @@ -1388,7 +1388,7 @@ internal WireProtocolRequest AsyncRequest(OutgoingMessage message, int timeout) #region Commands implementation - private List GetMemoryMap() + public List GetMemoryMap() { Commands.Monitor_MemoryMap cmd = new Commands.Monitor_MemoryMap(); @@ -1461,7 +1461,7 @@ public TargetInfo GetMonitorTargetInfo() return null; } - private List GetFlashSectorMap() + public List GetFlashSectorMap() { IncomingMessage reply = PerformSyncRequest(Commands.c_Monitor_FlashSectorMap, 0, null); diff --git a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs index 146262d1..d0acd4dc 100644 --- a/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs +++ b/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs @@ -19,7 +19,7 @@ public class WireProtocolRequest public CancellationToken CancellationToken { get; } public TaskCompletionSource TaskCompletionSource { get; } - public DateTimeOffset Expires { get; private set; } = DateTime.MaxValue; + public DateTimeOffset Expires { get; private set; } = DateTimeOffset.MaxValue; public DateTime RequestTimestamp { get; private set; }