Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
a4004 committed Oct 30, 2021
1 parent 8c04fc9 commit f69b164
Show file tree
Hide file tree
Showing 41 changed files with 7,608 additions and 95 deletions.
Binary file modified src/.vs/N2D22/v16/.suo
Binary file not shown.
188 changes: 94 additions & 94 deletions src/N2D22/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,138 +166,138 @@ private async void Flash()

WaitFm.Title("Getting ready");
await Task.Delay(1000);
}
else
throw new Exception($"The selection could not be determined due to an invalid value. {option}");

CreateRequest("Flash Operation", "The program is about to install software to your Espressif device. " +
CreateRequest("Flash Operation", "The program is about to install software to your Espressif device. " +
"Existing data on the device will be PERMANENTLY DELETED, are you sure?", "Allow software installation",
"Cancel flash operation, no changes will be made", out int result);

if (result == 2)
{
WaitFm.Debug("User cancelled the flash operation.", Event.Critical);
await CreateMessage("Software installation aborted", "You've chosen to cancel the installation " +
"of software to your Espressif device. No changes have been made. You can close this window.");
if (result == 2)
{
WaitFm.Debug("User cancelled the flash operation.", Event.Critical);
await CreateMessage("Software installation aborted", "You've chosen to cancel the installation " +
"of software to your Espressif device. No changes have been made. You can close this window.");

WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();
WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();

return;
}
else if (result == 1)
{
WaitFm.Debug("Flash operation started.");
WaitFm.Title("Installing software");
return;
}
else if (result == 1)
{
WaitFm.Debug("Flash operation started.");
WaitFm.Title("Installing software");

WaitFm.Caption("Checking device connection");
WaitFm.Debug("Checking device connection...");
WaitFm.Caption("Checking device connection");
WaitFm.Debug("Checking device connection...");

if (!Program.Settings.PortFix)
WaitFm.Debug($"Connecting to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}...");
if (!Program.Settings.PortFix)
WaitFm.Debug($"Connecting to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}...");

string output = string.Empty;
string output = string.Empty;

if (!Program.Portable)
if (!Program.Portable)
{
if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} read_mac"))
{
if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} read_mac"))
{
if (!Program.Settings.PortFix)
WaitFm.Debug($"Connected to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}", Event.Success);
WaitFm.Debug($"Espressif device MAC: {output.Substring(output.IndexOf("MAC:") + 5, 17).ToUpper()}", Event.Success);
if (!Program.Settings.PortFix)
WaitFm.Debug($"Connected to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}", Event.Success);
WaitFm.Debug($"Espressif device MAC: {output.Substring(output.IndexOf("MAC:") + 5, 17).ToUpper()}", Event.Success);

WaitFm.Caption("Connection was successful");
}
else
throw new Exception("Could not connect to the device.");
WaitFm.Caption("Connection was successful");
}
else
throw new Exception("Could not connect to the device.");
}
else
{
if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} read_mac"))
{
if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} read_mac"))
{
if (!Program.Settings.PortFix)
WaitFm.Debug($"Connected to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}", Event.Success);
WaitFm.Debug($"Espressif device MAC: {output.Substring(output.IndexOf("MAC:") + 5, 17).ToUpper()}", Event.Success);
if (!Program.Settings.PortFix)
WaitFm.Debug($"Connected to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}", Event.Success);
WaitFm.Debug($"Espressif device MAC: {output.Substring(output.IndexOf("MAC:") + 5, 17).ToUpper()}", Event.Success);

WaitFm.Caption("Connection was successful");
}
else
throw new Exception("Could not connect to the device.");
WaitFm.Caption("Connection was successful");
}

WaitFm.Caption("Erasing flash memory");
WaitFm.Debug("Erasing flash memory chip...");
else
throw new Exception("Could not connect to the device.");
}

if (!Program.Portable)
WaitFm.Caption("Erasing flash memory");
WaitFm.Debug("Erasing flash memory chip...");

if (!Program.Portable)
{
if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} erase_flash"))
{
if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} erase_flash"))
{
WaitFm.Debug("Erase successful!", Event.Success);
WaitFm.Caption("Erased.");
}
else
throw new Exception("Failed to erase the device.");
WaitFm.Debug("Erase successful!", Event.Success);
WaitFm.Caption("Erased.");
}
else
throw new Exception("Failed to erase the device.");
}
else
{
if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} erase_flash"))
{
if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} erase_flash"))
{
WaitFm.Debug("Erase successful!", Event.Success);
WaitFm.Caption("Erased.");
}
else
throw new Exception("Failed to erase the device.");
WaitFm.Debug("Erase successful!", Event.Success);
WaitFm.Caption("Erased.");
}
else
throw new Exception("Failed to erase the device.");
}

WaitFm.Caption("Writing new software image");
WaitFm.Debug("Writing new software image...");
WaitFm.Caption("Writing new software image");
WaitFm.Debug("Writing new software image...");

if (!Program.Portable)
if (!Program.Portable)
{
if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} write_flash 0x0 \"{Program.Settings.Bin}\""))
{
if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} write_flash 0x0 \"{Program.Settings.Bin}\""))
{
WaitFm.Debug("Flash complete!", Event.Success);
WaitFm.Caption("Installed.");
}
else
throw new Exception("Failed to flash the device.");
WaitFm.Debug("Flash complete!", Event.Success);
WaitFm.Caption("Installed.");
}
else
throw new Exception("Failed to flash the device.");
}
else
{
if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} write_flash 0x0 \"{Program.Settings.Bin}\""))
{
if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} write_flash 0x0 \"{Program.Settings.Bin}\""))
{
WaitFm.Debug("Erase successful!", Event.Success);
WaitFm.Caption("Erased.");
}
else
throw new Exception("Failed to flash the device.");
WaitFm.Debug("Erase successful!", Event.Success);
WaitFm.Caption("Erased.");
}
else
throw new Exception("Failed to flash the device.");
}


await Task.Delay(500);
await Task.Delay(500);

await CreateMessage("Installation complete", $"The software package {Program.Settings.Bin} has been successfully" +
$" installed on your device. You can close this window.");
await CreateMessage("Installation complete", $"The software package {Program.Settings.Bin} has been successfully" +
$" installed on your device. You can close this window.");

WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();
WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();

return;
}
else
{
WaitFm.Debug("Failsafe: the selection was invalid.", Event.Critical);
await CreateMessage("Software installation aborted", "A problem was encountered with the selection. " +
"No changes have been made to your Espressif device. You can close this window.");
return;
}
else
{
WaitFm.Debug("Failsafe: the selection was invalid.", Event.Critical);
await CreateMessage("Software installation aborted", "A problem was encountered with the selection. " +
"No changes have been made to your Espressif device. You can close this window.");

WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();
WaitFm.Host.CloseTask();
WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
TaskManager.ReleaseFLock();

return;
}
return;
}
else
throw new Exception($"The selection could not be determined due to an invalid value. {option}");
}
private async void Search()
{
Expand Down
2 changes: 1 addition & 1 deletion src/N2D22/Window/SelectFm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private async Task ListSoftwareOptions(string option)
if (availableFiles == null || availableFiles.Length < 1)
{
MessageBox.Show("The version you selected does not have any precompiled binaries available for it, to use this version you will" +
"need build the software from source and flash it as a local image from this PC.", "No Files Available", MessageBoxButtons.OK,
" need to build the software from source and flash it as a local image from this PC.", "No Files Available", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
Expand Down

0 comments on commit f69b164

Please sign in to comment.