Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More cleanup and version bump #521

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
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
2 changes: 1 addition & 1 deletion Source/v2/Meadow.Cli/Meadow.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<Company>Wilderness Labs, Inc</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2.0.21.0</PackageVersion>
<PackageVersion>2.0.22.0</PackageVersion>
<Platforms>AnyCPU</Platforms>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.CLI/</PackageProjectUrl>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.CLI</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Meadow.CLI
{
public static class Constants
{
public const string CLI_VERSION = "2.0.21.0";
public const string CLI_VERSION = "2.0.22.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ public static async Task<IList<string>> GetMeadowSerialPortsForLinux()
_ = proc?.WaitForExit(1000);
var output = proc?.StandardOutput.ReadToEnd();

if (output == null)
{
return Array.Empty<string>();
}

return output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.Where(x => x.Contains("Wilderness_Labs"))
.Select(
Expand Down
Loading