Skip to content

Commit

Permalink
Merge pull request #578 from WildernessLabs/fix-profiler-output-file-ref
Browse files Browse the repository at this point in the history
Fix profiler output file refs
  • Loading branch information
adrianstevens authored Jun 16, 2024
2 parents 5bd23cc + c042144 commit 684ff08
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public UartProfilerEnableCommand(MeadowConnectionManager connectionManager, ILog
: base(connectionManager, loggerFactory)
{ }

private void StartNewFile(string outputPath, FileStream? outputFile, byte[] header, ref int headerIndex, ref int totalBytesWritten, ref int headerFileCount)
private void StartNewFile(string outputPath, ref FileStream? outputFile, byte[] header, ref int headerIndex, ref int totalBytesWritten, ref int headerFileCount)
{
if (outputFile != null)
{
Expand All @@ -41,7 +41,7 @@ private void StartNewFile(string outputPath, FileStream? outputFile, byte[] head
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
// according to the Mono Profiler LOG_VERSION_MAJOR 3 LOG_VERSION_MINOR 0 LOG_DATA_VERSION 17
var header = new byte[] { 0x01, 0x5A, 0x50, 0x4D };
var headerIndex = 0;
var totalBytesWritten = 0;
Expand Down Expand Up @@ -74,7 +74,7 @@ private void ReadAndSaveSerialData()
if (headerIndex == header.Length)
{
Logger?.LogInformation($"Profiling data header found! Writing to {outputPath}...");
StartNewFile(outputPath, outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
StartNewFile(outputPath, ref outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
}
}
else
Expand All @@ -96,10 +96,10 @@ private void ReadAndSaveSerialData()
if (headerIndex == header.Length)
{
// Close the current file, start writing to a new file, and reset counters
// to avoid corrupted profiling data (e.g. device reset while profiling)
var newOutputPath = outputDirectory + "output_" + headerFileCount + ".mlpd";
// to avoid corrupted profiling data (e.g. device reset while profiling)
var newOutputPath = Path.Combine(outputDirectory, "output_" + headerFileCount + ".mlpd");
Logger?.LogInformation($"New profiling data header found! Writing to {newOutputPath}...");
StartNewFile(newOutputPath, outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
StartNewFile(newOutputPath, ref outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
}
}
else
Expand Down

0 comments on commit 684ff08

Please sign in to comment.