diff --git a/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs b/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs index 7f6933789..d057a0bf3 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs +++ b/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs @@ -410,13 +410,13 @@ namespace Cosmos.Debug.Common { } protected void PacketTracePoint(byte[] aPacket) { - // Seems to need to be ebfore CmdTrace call - have to dig why by moving it breaks things + // Moving it after the cmd causes a lockup.. not sure why... need to check WaitForMessage(); CmdTrace(mCurrentMsgType, GetUInt32(aPacket, 0)); } protected void PacketText(byte[] aPacket) { - // Seems to need to be ebfore CmdTrace call - have to dig why by moving it breaks things + // Moving it after the cmd causes a lockup.. not sure why... need to check WaitForMessage(); CmdText(ASCIIEncoding.ASCII.GetString(aPacket)); } diff --git a/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs b/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs index 76ca7d82c..449a7c3af 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs +++ b/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs @@ -55,17 +55,22 @@ namespace Cosmos.Debug.Common { base.Dispose(); } - protected Action mCompleted; // Action to call after size received + protected Action mCompletedAfterSize; // Action to call after size received protected void SizePacket(byte[] aPacket) { int xSize = aPacket[0] + (aPacket[1] << 8); - Next(xSize, mCompleted); + Next(xSize, mCompletedAfterSize); } protected override void Next(int aPacketSize, Action aCompleted) { var xIncoming = new Incoming(); - if (aPacketSize == -1) { + if (aPacketSize == 0) { + // Can occur with variable size packets for exampmle. + // Dont call read, becuase that will close the stream. + // So we just call the Completed directly + aCompleted(new byte[0]); + } else if (aPacketSize == -1) { // Variable size packet, split into two reads - mCompleted = aCompleted; + mCompletedAfterSize = aCompleted; aPacketSize = 2; xIncoming.Completed = SizePacket; } else {