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

Improve output during backup/flash process #281

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 12 additions & 8 deletions nanoFirmwareFlasher.Library/Esp32Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,6 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(

if (operationResult == ExitCodes.OK)
{
Console.ForegroundColor = ConsoleColor.White;

if (verbosity >= VerbosityLevel.Normal)
{
Console.Write($"Flashing firmware...");
}

int configPartitionAddress = 0;
int configPartitionSize = 0;
string configPartitionBackup = Path.GetRandomFileName();
Expand All @@ -513,7 +506,11 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
if (File.Exists(Path.Combine(firmware.LocationPath, $"partitions_nanoclr_{Esp32DeviceInfo.GetFlashSizeAsString(esp32Device.FlashSize).ToLowerInvariant()}.csv")))
{
// can't do this without a partition table

if (verbosity >= VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write($"Backup configuration...");
}

// compose path to partition file
string partitionCsvFile = Path.Combine(firmware.LocationPath, $"partitions_nanoclr_{Esp32DeviceInfo.GetFlashSizeAsString(esp32Device.FlashSize).ToLowerInvariant()}.csv");
Expand Down Expand Up @@ -543,6 +540,13 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
}
}

Console.ForegroundColor = ConsoleColor.White;

if (verbosity >= VerbosityLevel.Normal)
{
Console.Write($"Flashing firmware...");
}

// write to flash
operationResult = espTool.WriteFlash(firmware.FlashPartitions);

Expand Down
8 changes: 4 additions & 4 deletions nanoFirmwareFlasher.Library/EspTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ internal ExitCodes BackupConfigPartition(
false,
true,
false,
null,
(char)8,
out string messages))
{
throw new ReadEsp32FlashException(messages);
Expand Down Expand Up @@ -745,12 +745,12 @@ private bool RunEspTool(

// try to find a progress message
string progress = FindProgress(messageBuilder, progressTestChar.Value);
if (progress != null && Verbosity >= VerbosityLevel.Detailed)
if (progress != null && Verbosity >= VerbosityLevel.Normal)
CoryCharlton marked this conversation as resolved.
Show resolved Hide resolved
{
if (!progressStarted)
{
// need to print the first line of the progress message
Console.Write("\r");
Console.WriteLine();
CoryCharlton marked this conversation as resolved.
Show resolved Hide resolved

progressStarted = true;
}
Expand All @@ -764,7 +764,7 @@ private bool RunEspTool(
}
else
{
if (Verbosity >= VerbosityLevel.Detailed)
if (Verbosity >= VerbosityLevel.Normal)
{
// need to clear all progress lines
for (int i = 0; i < messageBuilder.Length; i++)
Expand Down