Skip to content

Commit

Permalink
AvrDude Wrapper should bypass non Serial events
Browse files Browse the repository at this point in the history
  • Loading branch information
eried committed Sep 29, 2012
1 parent c281c8b commit 62aef09
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions erw/csharp/AvrDudeReset/Program.cs
Expand Up @@ -29,37 +29,37 @@ static void Main(string[] args)
}

// Check if port is available
if (port != -1 && bauds != -1)
if (!PortIsOk(port, bauds))
{

if (!PortIsOk(port, bauds))
{
// Can't be opened
var p = Process.Start("avrdudefix.exe", "-parent" + ParentProc.FindParentProcess().MainWindowHandle);
p.WaitForExit();

// Can't be opened
var p = Process.Start("avrdudefix.exe", "-parent" + ParentProc.FindParentProcess().MainWindowHandle);
p.WaitForExit();
switch (p.ExitCode)
{
case 2:
Console.Error.WriteLine("Serial port 'COM{0}' already in use. Check your board or Click fix on next upload.", port);
break;
case 9:
var timer = Stopwatch.StartNew();

switch (p.ExitCode)
{
case 2:
Console.Error.WriteLine("Serial port 'COM{0}' already in use. Check your board or Click fix on next upload.", port);
break;
case 9:
var timer = Stopwatch.StartNew();

do
{
if (timer.ElapsedMilliseconds > 10000)
do
{
Environment.Exit(1);
}
Thread.Sleep(1000);
} while (!PortIsOk(port, bauds));
break;
default:
Console.WriteLine("Nothing was uploaded to the board. Upload was cancelled.");
Environment.Exit(0);
break;
if (timer.ElapsedMilliseconds > 10000)
{
Environment.Exit(1);
}
Thread.Sleep(1000);
} while (!PortIsOk(port, bauds));
break;
default:
Console.WriteLine("Nothing was uploaded to the board. Upload was cancelled.");
Environment.Exit(0);
break;
}
}
}

_p = new Process { StartInfo = new ProcessStartInfo("avrdude2.exe", "\"" + String.Join("\" \"", args) + "\"") { RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow=true } , EnableRaisingEvents = true };
_p.OutputDataReceived += p_OutputDataReceived;
Expand Down

0 comments on commit 62aef09

Please sign in to comment.