Skip to content

Commit

Permalink
attempt at porting debug from v1 to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke committed Mar 7, 2024
1 parent 0e2cccd commit d26117b
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 312 deletions.
6 changes: 6 additions & 0 deletions Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public abstract class ConnectionBase : IMeadowConnection, IDisposable
public event EventHandler<(string fileName, long completed, long total)> FileWriteProgress = default!;
public event EventHandler<string> ConnectionMessage = default!;
public event EventHandler FileWriteFailed = default!;
public event EventHandler<byte[]> DebuggerMessage;

public abstract string Name { get; }

Expand Down Expand Up @@ -58,6 +59,11 @@ protected void RaiseConnectionMessage(string message)
ConnectionMessage?.Invoke(this, message);
}

protected void RaiseDebuggerMessage(byte[] data)
{
DebuggerMessage?.Invoke(this, data);
}

protected void RaiseFileWriteProgress(string fileName, long progress, long total)
{
FileWriteProgress?.Invoke(this, (fileName, progress, total));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ private async Task ListenerProc()
{
RaiseFileWriteFailed();
}
else if (response is DebuggingDataResponse ddr)
{
RaiseDebuggerMessage(ddr.Data);
}
else
{
Debug.WriteLine($"{response?.GetType().Name} for: {response?.RequestType}");
Expand Down
2 changes: 1 addition & 1 deletion Source/v2/Meadow.Hcom/Connections/SerialConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ public override async Task<DebuggingServer> StartDebuggingSession(int port, ILog
await ReInitializeMeadow(cancellationToken); */

var endpoint = new IPEndPoint(IPAddress.Loopback, port);
var debuggingServer = new DebuggingServer(Device, endpoint, logger);
var debuggingServer = new DebuggingServer(this, Device, endpoint, logger);

logger?.LogDebug("Tell the Debugging Server to Start Listening");
await debuggingServer.StartListening(cancellationToken);
Expand Down
Loading

0 comments on commit d26117b

Please sign in to comment.