From 50fb3b23db4704065ca1553bee0cd8a5e63192cd Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Wed, 7 Aug 2024 19:51:39 -0700 Subject: [PATCH] Wait code for debugging --- Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs | 9 +++++++++ .../Debugging/DebuggingServer.ActiveClient.cs | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs b/Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs index 6e9bbd42..d3342d42 100755 --- a/Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs +++ b/Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs @@ -62,8 +62,17 @@ protected void RaiseConnectionMessage(string message) ConnectionMessage?.Invoke(this, message); } + bool firstRun = true; + protected void RaiseDebuggerMessage(byte[] data) { + if (firstRun) + { + Thread.Sleep(2000); + firstRun = false; + } + + Debug.WriteLine($"*************************** RaiseDebuggerMessage: {data.Length}"); DebuggerMessageReceived?.Invoke(this, data); } diff --git a/Source/v2/Meadow.Hcom/Debugging/DebuggingServer.ActiveClient.cs b/Source/v2/Meadow.Hcom/Debugging/DebuggingServer.ActiveClient.cs index 2708217a..ce6cb7a2 100644 --- a/Source/v2/Meadow.Hcom/Debugging/DebuggingServer.ActiveClient.cs +++ b/Source/v2/Meadow.Hcom/Debugging/DebuggingServer.ActiveClient.cs @@ -80,6 +80,9 @@ private async Task SendToMeadowAsync() .ToLowerInvariant()); await _connection.SendDebuggerData(meadowBuffer, 0, _cts.Token); + + Debug.WriteLine($"ToMeadow: {BitConverter.ToString(meadowBuffer)}"); + meadowBuffer = Array.Empty(); } while (_networkStream.DataAvailable); } @@ -115,7 +118,7 @@ private async Task SendToVisualStudio() { if (_networkStream != null && _networkStream.CanWrite) { - _vsDebugDataReady.WaitOne(1000); + _vsDebugDataReady.WaitOne(500); while (_debuggerMessages.Count > 0) { @@ -130,6 +133,8 @@ private async Task SendToVisualStudio() await _networkStream.WriteAsync(byteData, 0, byteData.Length, _cts.Token); _logger?.LogTrace("Forwarded {count} bytes to VS", byteData.Length); + + Debug.WriteLine($"ToVisStu: {BitConverter.ToString(byteData)}"); } } else