Skip to content

Commit

Permalink
Fix JLink error codes (#182)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes authored Dec 13, 2022
1 parent 22b13b6 commit a52bf43
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
8 changes: 7 additions & 1 deletion nanoFirmwareFlasher.Library/ExitCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public enum ExitCodes
E8000 = 8000,

/// <summary>
/// No JTAG device found
/// No J-Link device found
/// </summary>
[Display(Name = "No J-Link device found. Make sure it's connected.")]
E8001 = 8001,
Expand All @@ -236,6 +236,12 @@ public enum ExitCodes
[Display(Name = "Error executing silink CLI command.")]
E8002 = 8002,

/// <summary>
/// Path of BIN file contains spaces or diacritic characters.
/// </summary>
[Display(Name = "Path of BIN file contains spaces or diacritic characters.")]
E8003 = 8003,

////////////////////////////////
// Application general Errors //
////////////////////////////////
Expand Down
28 changes: 22 additions & 6 deletions nanoFirmwareFlasher.Library/JLinkCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,23 @@ public ExitCodes ExecuteFlashBinFiles(

Console.ForegroundColor = ConsoleColor.White;

return ExitCodes.E5004;
return ExitCodes.E8003;
}

if (binFile.Contains(' '))
{
Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine("");
Console.WriteLine("************************* WARNING **************************");
Console.WriteLine("Binary file path contains spaces!");
Console.WriteLine("J-Link can't handle those, please use a path without spaces.");
Console.WriteLine("************************************************************");
Console.WriteLine("");

Console.ForegroundColor = ConsoleColor.White;

return ExitCodes.E8003;
}
}

Expand All @@ -196,12 +212,12 @@ public ExitCodes ExecuteFlashBinFiles(
DoMassErase = false;
}

if (Verbosity == VerbosityLevel.Normal)
if (Verbosity < VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Flashing device...");
}
else if (Verbosity >= VerbosityLevel.Detailed)
else
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Flashing device...");
Expand All @@ -211,7 +227,7 @@ public ExitCodes ExecuteFlashBinFiles(
int index = 0;
foreach (string binFile in files)
{
if (Verbosity >= VerbosityLevel.Detailed)
if (Verbosity > VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"{Path.GetFileName(binFile)} @ {addresses.ElementAt(index)}");
Expand Down Expand Up @@ -239,12 +255,12 @@ public ExitCodes ExecuteFlashBinFiles(
}
}

if (Verbosity == VerbosityLevel.Normal)
if (Verbosity < VerbosityLevel.Normal)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(" OK");
}
else if (Verbosity >= VerbosityLevel.Detailed)
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Flashing completed...");
Expand Down
4 changes: 2 additions & 2 deletions nanoFirmwareFlasher.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
// no J-Link device found

// done here, this command has no further processing
_exitCode = ExitCodes.E5001;
_exitCode = ExitCodes.E8001;

return;
}
Expand Down Expand Up @@ -1318,7 +1318,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
catch (CantConnectToJLinkDeviceException)
{
// done here, this command has no further processing
_exitCode = ExitCodes.E5002;
_exitCode = ExitCodes.E8002;
}
}
else if (!string.IsNullOrEmpty(o.TargetName))
Expand Down

0 comments on commit a52bf43

Please sign in to comment.