Skip to content

Commit

Permalink
Enhance profiler CLI command logs
Browse files Browse the repository at this point in the history
  • Loading branch information
duduita committed Feb 19, 2024
1 parent 41ac4d5 commit a54ea3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ protected override async ValueTask ExecuteCommand()
return;
}

connection.DeviceMessageReceived += (s, e) =>
{
Logger?.LogInformation(e.message);
};

Logger?.LogInformation("Setting UART to application use...");
Logger?.LogInformation("Disabling UART output for profiling data...");

await connection.Device.UartProfilerDisable(CancellationToken);

Logger?.LogInformation("Reseting Meadow device...");

await connection.ResetDevice();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ private void ReadAndSaveSerialData()
// Define the equivalent header bytes sequence to the 32-bit representation of 0x4D505A01
// according to the Mono Profiler LOG_VERSION_MAJOR 3 LOG_VERSION_MINOR 0 LOG_DATA_VERSION 17
byte[] header = { 0x01, 0x5A, 0x50, 0x4D };
byte[] buffer = new byte[header.Length];
int headerIndex = 0;
string defaultDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
outputDirectory ??= defaultDirectory;
Expand Down Expand Up @@ -53,7 +52,6 @@ private void ReadAndSaveSerialData()
// Check if the received data matches the header sequence
if (data == header[headerIndex])
{
buffer[headerIndex] = (byte)data;
headerIndex++;
// If the entire header sequence is found, start writing to a file
if (headerIndex == header.Length)
Expand All @@ -67,7 +65,6 @@ private void ReadAndSaveSerialData()
writingToFile = true;
totalBytesWritten += 4;
headerIndex = 0;
buffer = new byte[header.Length];
headerFoundTimes++;
}
}
Expand Down Expand Up @@ -104,7 +101,6 @@ private void ReadAndSaveSerialData()
outputFile.WriteByte((byte)headerByte);
}
totalBytesWritten = 4;
buffer = new byte[header.Length];
}
}
else
Expand Down Expand Up @@ -144,7 +140,7 @@ protected override async ValueTask ExecuteCommand()
return;
}

Logger?.LogInformation("Setting UART to output profiling data...");
Logger?.LogInformation("Setting UART to only output profiling data...");

await connection.Device.UartProfilerEnable(CancellationToken);

Expand Down
4 changes: 2 additions & 2 deletions Source/v2/Meadow.Hcom/SerialRequests/RequestType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public enum RequestType : ushort
HCOM_MDOW_REQUEST_MONO_FLASH = 0x19 | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE,
HCOM_MDOW_REQUEST_SEND_TRACE_TO_UART = 0x1a | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE,
HCOM_MDOW_REQUEST_NO_TRACE_TO_UART = 0x1b | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE,
HCOM_MDOW_REQUEST_SEND_PROFILER_TO_UART = 0x23 | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE, // TODO: Check if this is a good value
HCOM_MDOW_REQUEST_NO_PROFILER_TO_UART = 0x24 | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE, // TODO: Check if this is a good value
HCOM_MDOW_REQUEST_SEND_PROFILER_TO_UART = 0x23 | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE,
HCOM_MDOW_REQUEST_NO_PROFILER_TO_UART = 0x24 | ProtocolType.HCOM_PROTOCOL_HEADER_ONLY_TYPE,
// >>> Breaking protocol change.
// ToDo: This message is miscategorized should be ProtocolType.HCOM_PROTOCOL_HEADER_FILE_START_TYPE
// like HCOM_MDOW_REQUEST_START_FILE_TRANSFER.
Expand Down

0 comments on commit a54ea3b

Please sign in to comment.