Skip to content

Commit

Permalink
Wait code for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Aug 8, 2024
1 parent 863ee6b commit 50fb3b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte>();
} while (_networkStream.DataAvailable);
}
Expand Down Expand Up @@ -115,7 +118,7 @@ private async Task SendToVisualStudio()
{
if (_networkStream != null && _networkStream.CanWrite)
{
_vsDebugDataReady.WaitOne(1000);
_vsDebugDataReady.WaitOne(500);

while (_debuggerMessages.Count > 0)
{
Expand All @@ -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
Expand Down

0 comments on commit 50fb3b2

Please sign in to comment.