@@ -35,11 +35,10 @@ public class JLinkCli
3535 private const string FlashFileCommandTemplate = $@ "
3636USB
3737speed auto
38- Reset
3938Halt
40- LoadFile { FilePathToken } ,{ FlashAddressToken }
41- Sleep 1000
39+ LoadFile { FilePathToken } { FlashAddressToken }
4240Reset
41+ Go
4342Exit
4443" ;
4544
@@ -276,9 +275,14 @@ public void ShowCLIOutput(string cliOutput)
276275 // show CLI output, if verbosity is diagnostic
277276 if ( Verbosity == VerbosityLevel . Diagnostic )
278277 {
278+ Console . ForegroundColor = ConsoleColor . Yellow ;
279+
280+ Console . WriteLine ( ) ;
279281 Console . WriteLine ( ">>>>>>>>" ) ;
280282 Console . WriteLine ( $ "{ cliOutput } ") ;
281283 Console . WriteLine ( ">>>>>>>>" ) ;
284+
285+ Console . ForegroundColor = ConsoleColor . White ;
282286 }
283287 }
284288
@@ -314,18 +318,19 @@ internal static string RunJLinkCLI(string cmdFile, string arguments = null)
314318 RedirectStandardError = true ,
315319 RedirectStandardOutput = true
316320 } ;
321+
317322 if ( ! jlinkExe_ . Start ( ) )
318323 {
319- throw new EspToolExecutionException ( "Error changing permissions for J-Link executable!" ) ;
324+ throw new InvalidOperationException ( "Error changing permissions for J-Link executable!" ) ;
320325 }
321326
322- while ( ! jlinkExe_ . HasExited )
327+ if ( ! jlinkExe_ . WaitForExit ( 250 ) )
323328 {
324- Thread . Sleep ( 10 ) ;
329+ throw new InvalidOperationException ( "Error changing permissions for J-Link executable!" ) ;
325330 }
326331 }
327332
328- Process jlinkCli = new Process ( ) ;
333+ Process jlinkCli = new ( ) ;
329334 string parameter = $ " -nogui 1 -device default -si swd -CommandFile { cmdFilesDir } ";
330335
331336 jlinkCli . StartInfo = new ProcessStartInfo ( Path . Combine ( appDir , appName ) , parameter )
@@ -340,8 +345,8 @@ internal static string RunJLinkCLI(string cmdFile, string arguments = null)
340345 // start J-Link Programmer CLI and...
341346 jlinkCli . Start ( ) ;
342347
343- // ... wait for exit (1 min max!)
344- jlinkCli . WaitForExit ( ( int ) TimeSpan . FromMinutes ( 1 ) . TotalMilliseconds ) ;
348+ // ... wait for exit (30secs max!)
349+ jlinkCli . WaitForExit ( ( int ) TimeSpan . FromSeconds ( 30 ) . TotalMilliseconds ) ;
345350
346351 return jlinkCli . StandardOutput . ReadToEnd ( ) ;
347352 }
0 commit comments