Skip to content
Open
Changes from all commits
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
46 changes: 44 additions & 2 deletions J-Runner/Classes/Mtx-Usb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,33 @@ public void writeNand(int size, string filename, int mode = 0, int startblock =
else process.StartInfo.Arguments = "usb: -w" + size + " \"" + filename + "\"" + slArg;
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = Path.Combine(variables.rootfolder, "common/mtx-tools");
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;

AutoResetEvent outputWaitHandle = new AutoResetEvent(false);
process.OutputDataReceived += (sender, e) =>
{
if (e.Data == null)
{
outputWaitHandle.Set();
}
else
{
Console.WriteLine(e.Data);
}
};

NandX.InUse = true;
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();


if (process.HasExited)
{
process.CancelOutputRead();
}

inUseTimer.Enabled = false;
inUseCount = 0;
NandX.InUse = false;
Expand Down Expand Up @@ -166,14 +187,35 @@ public void flashXsvf(string filename)
process.StartInfo.Arguments = "\"" + filename + "\"";
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = variables.rootfolder;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;

AutoResetEvent outputWaitHandle = new AutoResetEvent(false);
process.OutputDataReceived += (sender, e) =>
{
if (e.Data == null)
{
outputWaitHandle.Set();
}
else
{
Console.WriteLine(e.Data.Replace("\b\b\b\b\b"," ["));
}
};

NandX.InUse = true;
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();

if (process.HasExited)
{
process.CancelOutputRead();
}

NandX.InUse = false;
Console.WriteLine("Xsvf: Completed!");
Console.WriteLine("");
}
catch (Exception ex)
{
Expand Down