diff --git a/Source/v2/Meadow.Cli/Meadow.CLI.csproj b/Source/v2/Meadow.Cli/Meadow.CLI.csproj index b1d62523..45677ed3 100644 --- a/Source/v2/Meadow.Cli/Meadow.CLI.csproj +++ b/Source/v2/Meadow.Cli/Meadow.CLI.csproj @@ -10,7 +10,7 @@ Wilderness Labs, Inc Wilderness Labs, Inc true - 2.0.61.0 + 2.0.62.0 AnyCPU http://developer.wildernesslabs.co/Meadow/Meadow.CLI/ https://github.com/WildernessLabs/Meadow.CLI diff --git a/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs b/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs index e84673a6..7f5af5a6 100644 --- a/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs +++ b/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs @@ -6,5 +6,5 @@ namespace Meadow.CLI; public static class Constants { - public const string CLI_VERSION = "2.0.61.0"; + public const string CLI_VERSION = "2.0.62.0"; } \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Properties/launchSettings.json b/Source/v2/Meadow.Cli/Properties/launchSettings.json index f512d1f5..26163f9e 100644 --- a/Source/v2/Meadow.Cli/Properties/launchSettings.json +++ b/Source/v2/Meadow.Cli/Properties/launchSettings.json @@ -153,7 +153,7 @@ }, "Firmware Write version": { "commandName": "Project", - "commandLineArgs": "firmware write -v 1.9.1.8" + "commandLineArgs": "firmware write -v 2.0.0.2" }, "Firmware Write runtime": { "commandName": "Project", diff --git a/Source/v2/Meadow.HCom/Connections/SerialConnection.ListenerProc.cs b/Source/v2/Meadow.HCom/Connections/SerialConnection.ListenerProc.cs index 0f438efe..1b449d9c 100644 --- a/Source/v2/Meadow.HCom/Connections/SerialConnection.ListenerProc.cs +++ b/Source/v2/Meadow.HCom/Connections/SerialConnection.ListenerProc.cs @@ -1,4 +1,4 @@ -namespace Meadow.Hcom +namespace Meadow.Hcom { public partial class SerialConnection { @@ -8,7 +8,7 @@ public partial class SerialConnection public override async Task WaitForMeadowAttach(CancellationToken? cancellationToken) { - var timeout = 50; + var timeout = 500; while (timeout-- > 0) { @@ -26,7 +26,7 @@ public override async Task WaitForMeadowAttach(CancellationToken? cancellationTo return; } - await Task.Delay(100); + await Task.Delay(20); if (!_port.IsOpen) { @@ -52,34 +52,6 @@ private async Task ListenerProc() var delimiter = new byte[] { 0x00 }; var receivedLength = 0; - async Task ReOpen() // local function - { - Debug.WriteLine($"Device reset detected"); - - var timeout = 20; - try { _port.Close(); } catch { } // Swallow any exceptions on close - there is nothing we can do about it - - while (!_port.IsOpen) - { - await Task.Delay(500); - - if (timeout-- < 0) - { - return; - } - - try - { - Open(); - Debug.WriteLine($"Port re-opened"); - } - catch - { - Debug.WriteLine($"Failed to re-open port"); - } - } - } - while (!_isDisposed) { if (_port.IsOpen) @@ -92,20 +64,32 @@ async Task ReOpen() // local function try { receivedLength = _port.Read(readBuffer, 0, readBuffer.Length); - if (receivedLength == 0) - { - Debug.WriteLine($"Received 0 bytes"); - throw new OperationCanceledException(); - } } catch (OperationCanceledException) { - await ReOpen(); - goto read; - } - catch (InvalidOperationException) - { - await ReOpen(); + Debug.WriteLine($"Device reset detected"); + + var timeout = 20; + + while (!_port.IsOpen) + { + await Task.Delay(500); + + if (timeout-- < 0) + { + return; + } + + try + { + Open(); + Debug.WriteLine($"Port re-opened"); + } + catch + { + Debug.WriteLine($"Failed to re-open port"); + } + } goto read; }