Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke committed Mar 8, 2024
2 parents d26117b + 0389c6b commit 1f17af7
Show file tree
Hide file tree
Showing 79 changed files with 858 additions and 918 deletions.
7 changes: 6 additions & 1 deletion Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ internal static async Task DisableRuntimeIfEnabled(IMeadowConnection connection,
internal static async Task<bool> TrimApplication(string path,
IPackageManager packageManager,
string? configuration,
IEnumerable<string>? noLinkAssemblies,
ILogger? logger,
IConsole? console,
CancellationToken cancellationToken)
Expand Down Expand Up @@ -80,8 +81,12 @@ internal static async Task<bool> TrimApplication(string path,
}

logger?.LogInformation($"Trimming application {file.FullName}...");
if (noLinkAssemblies != null && noLinkAssemblies.Count() > 0)
{
logger?.LogInformation($"Skippping assemblies: {string.Join(", ", noLinkAssemblies)}");
}

await packageManager.TrimApplication(file, false, null, cancellationToken);
await packageManager.TrimApplication(file, false, noLinkAssemblies, cancellationToken);
cts.Cancel();

// illink returns before all files are written - attempt a delay of 1s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ public UartProfilerEnableCommand(MeadowConnectionManager connectionManager, ILog
: base(connectionManager, loggerFactory)
{ }

private void StartNewFile(string outputPath, ref FileStream outputFile, byte[] header, ref int headerIndex, ref int totalBytesWritten, ref int headerFileCount)
private void StartNewFile(string outputPath, FileStream? outputFile, byte[] header, ref int headerIndex, ref int totalBytesWritten, ref int headerFileCount)
{
if (outputFile != null)
{
outputFile.Close();
outputFile.Dispose();
}

outputFile = new FileStream(outputPath, FileMode.Create);
totalBytesWritten = 0;
headerIndex = 0;
headerFileCount++;

foreach (var headerByte in header)
{
outputFile.WriteByte(headerByte);
Expand All @@ -50,7 +52,7 @@ private void ReadAndSaveSerialData()
var outputPath = Path.Combine(outputDirectory, "output.mlpd");

SerialPort port = new SerialPort(SerialInterface, SerialConnection.DefaultBaudRate);
FileStream outputFile = null;
FileStream? outputFile = null;

try
{
Expand All @@ -72,7 +74,7 @@ private void ReadAndSaveSerialData()
if (headerIndex == header.Length)
{
Logger?.LogInformation($"Profiling data header found! Writing to {outputPath}...");
StartNewFile(outputPath, ref outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
StartNewFile(outputPath, outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
}
}
else
Expand All @@ -84,7 +86,7 @@ private void ReadAndSaveSerialData()
else
{
// Writing to file after a header is found
outputFile.WriteByte((byte)data);
outputFile?.WriteByte((byte)data);
totalBytesWritten++;

// Check for a new header while writing to a file
Expand All @@ -97,7 +99,7 @@ private void ReadAndSaveSerialData()
// to avoid corrupted profiling data (e.g. device reset while profiling)
var newOutputPath = outputDirectory + "output_" + headerFileCount + ".mlpd";
Logger?.LogInformation($"New profiling data header found! Writing to {newOutputPath}...");
StartNewFile(newOutputPath, ref outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
StartNewFile(newOutputPath, outputFile, header, ref headerIndex, ref totalBytesWritten, ref headerFileCount);
}
}
else
Expand Down
148 changes: 0 additions & 148 deletions Source/v2/Meadow.Cli/AppManager.cs

This file was deleted.

4 changes: 3 additions & 1 deletion Source/v2/Meadow.Cli/Commands/Current/App/AppBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AppBuildCommand(IPackageManager packageManager, ILoggerFactory loggerFact
_packageManager = packageManager;
}

protected override async ValueTask ExecuteCommand()
protected override ValueTask ExecuteCommand()
{
var path = AppTools.ValidateAndSanitizeAppPath(Path);

Expand All @@ -39,5 +39,7 @@ protected override async ValueTask ExecuteCommand()
{
Logger?.LogInformation($"Build successful");
}

return default;
}
}
5 changes: 4 additions & 1 deletion Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class AppRunCommand : BaseDeviceCommand<AppRunCommand>
[CommandParameter(0, Description = Strings.PathMeadowApplication, IsRequired = false)]
public string? Path { get; init; }

[CommandOption("nolink", Description = Strings.NoLinkAssemblies, IsRequired = false)]
public string[]? NoLink { get; private set; }

public AppRunCommand(IPackageManager packageManager, MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory)
: base(connectionManager, loggerFactory)
{
Expand All @@ -46,7 +49,7 @@ protected override async ValueTask ExecuteCommand()
throw new CommandException("Application build failed", CommandExitCode.GeneralError);
}

if (!await AppTools.TrimApplication(path, _packageManager, Configuration, Logger, Console, CancellationToken))
if (!await AppTools.TrimApplication(path, _packageManager, Configuration, NoLink, Logger, Console, CancellationToken))
{
throw new CommandException("Application trimming failed", CommandExitCode.GeneralError);
}
Expand Down
5 changes: 4 additions & 1 deletion Source/v2/Meadow.Cli/Commands/Current/App/AppTrimCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class AppTrimCommand : BaseCommand<AppTrimCommand>
[CommandParameter(0, Description = Strings.PathToMeadowProject, IsRequired = false)]
public string? Path { get; init; }

[CommandOption("nolink", Description = Strings.NoLinkAssemblies, IsRequired = false)]
public string[]? NoLink { get; private set; }

public AppTrimCommand(IPackageManager packageManager, ILoggerFactory loggerFactory)
: base(loggerFactory)
{
Expand All @@ -34,7 +37,7 @@ protected override async ValueTask ExecuteCommand()
}
}

await AppTools.TrimApplication(path, _packageManager, Configuration, Logger, Console, CancellationToken);
await AppTools.TrimApplication(path, _packageManager, Configuration, NoLink, Logger, Console, CancellationToken);
Logger.LogInformation("Application trimmed successfully");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ConfigCommand : BaseSettingsCommand<ConfigCommand>
[CommandParameter(0, Name = "Settings", IsRequired = false)]
public string[]? Settings { get; init; }

public ConfigCommand(ISettingsManager settingsManager, ILoggerFactory? loggerFactory)
public ConfigCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory)
: base(settingsManager, loggerFactory)
{ }

Expand Down
Loading

0 comments on commit 1f17af7

Please sign in to comment.