Skip to content

Commit a52bf43

Browse files
authored
Fix JLink error codes (#182)
***NO_CI***
1 parent 22b13b6 commit a52bf43

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

nanoFirmwareFlasher.Library/ExitCodes.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public enum ExitCodes
225225
E8000 = 8000,
226226

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

239+
/// <summary>
240+
/// Path of BIN file contains spaces or diacritic characters.
241+
/// </summary>
242+
[Display(Name = "Path of BIN file contains spaces or diacritic characters.")]
243+
E8003 = 8003,
244+
239245
////////////////////////////////
240246
// Application general Errors //
241247
////////////////////////////////

nanoFirmwareFlasher.Library/JLinkCli.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,23 @@ public ExitCodes ExecuteFlashBinFiles(
178178

179179
Console.ForegroundColor = ConsoleColor.White;
180180

181-
return ExitCodes.E5004;
181+
return ExitCodes.E8003;
182+
}
183+
184+
if (binFile.Contains(' '))
185+
{
186+
Console.ForegroundColor = ConsoleColor.Red;
187+
188+
Console.WriteLine("");
189+
Console.WriteLine("************************* WARNING **************************");
190+
Console.WriteLine("Binary file path contains spaces!");
191+
Console.WriteLine("J-Link can't handle those, please use a path without spaces.");
192+
Console.WriteLine("************************************************************");
193+
Console.WriteLine("");
194+
195+
Console.ForegroundColor = ConsoleColor.White;
196+
197+
return ExitCodes.E8003;
182198
}
183199
}
184200

@@ -196,12 +212,12 @@ public ExitCodes ExecuteFlashBinFiles(
196212
DoMassErase = false;
197213
}
198214

199-
if (Verbosity == VerbosityLevel.Normal)
215+
if (Verbosity < VerbosityLevel.Normal)
200216
{
201217
Console.ForegroundColor = ConsoleColor.White;
202218
Console.Write("Flashing device...");
203219
}
204-
else if (Verbosity >= VerbosityLevel.Detailed)
220+
else
205221
{
206222
Console.ForegroundColor = ConsoleColor.White;
207223
Console.WriteLine("Flashing device...");
@@ -211,7 +227,7 @@ public ExitCodes ExecuteFlashBinFiles(
211227
int index = 0;
212228
foreach (string binFile in files)
213229
{
214-
if (Verbosity >= VerbosityLevel.Detailed)
230+
if (Verbosity > VerbosityLevel.Normal)
215231
{
216232
Console.ForegroundColor = ConsoleColor.Cyan;
217233
Console.WriteLine($"{Path.GetFileName(binFile)} @ {addresses.ElementAt(index)}");
@@ -239,12 +255,12 @@ public ExitCodes ExecuteFlashBinFiles(
239255
}
240256
}
241257

242-
if (Verbosity == VerbosityLevel.Normal)
258+
if (Verbosity < VerbosityLevel.Normal)
243259
{
244260
Console.ForegroundColor = ConsoleColor.Green;
245261
Console.WriteLine(" OK");
246262
}
247-
else if (Verbosity >= VerbosityLevel.Detailed)
263+
else
248264
{
249265
Console.ForegroundColor = ConsoleColor.Green;
250266
Console.WriteLine("Flashing completed...");

nanoFirmwareFlasher.Tool/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
12821282
// no J-Link device found
12831283

12841284
// done here, this command has no further processing
1285-
_exitCode = ExitCodes.E5001;
1285+
_exitCode = ExitCodes.E8001;
12861286

12871287
return;
12881288
}
@@ -1318,7 +1318,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
13181318
catch (CantConnectToJLinkDeviceException)
13191319
{
13201320
// done here, this command has no further processing
1321-
_exitCode = ExitCodes.E5002;
1321+
_exitCode = ExitCodes.E8002;
13221322
}
13231323
}
13241324
else if (!string.IsNullOrEmpty(o.TargetName))

0 commit comments

Comments
 (0)