static void Main(string[] aArgs) { HelperVolkano helper = new HelperVolkano(aArgs); OptionParser optParser = helper.OptionParser; optParser.Usage = "usage: FacDef.exe [options] [target ugly name]"; OptionParser.OptionBool optNoExec = new OptionParser.OptionBool(null, "--noexec", "Do not reboot target after reprogramming"); OptionParser.OptionBool optWait = new OptionParser.OptionBool("-w", "--wait", "Wait to discover rebooted target after reprogramming (ignored with --noexec)"); optParser.AddOption(optNoExec); optParser.AddOption(optWait); helper.Start(); if (optParser.PosArgs.Count != 1) { Console.WriteLine(optParser.Help()); System.Environment.Exit(1); } string uglyname = optParser.PosArgs[0]; // create the console IConsole console = new FlashInfoConsole(); // create the reprogrammer FactoryDefaulter defaulter = new FactoryDefaulter(helper.IpAddress, console, uglyname); defaulter.NoExec = optNoExec.Value; defaulter.Wait = optWait.Value; if (!defaulter.Execute()) { defaulter.Close(); System.Environment.Exit(1); } defaulter.Close(); }
public FactoryDefaulterHelper(IPAddress aAdapterAddress, string aUglyname, ChangedHandler aHandler) { iHandler = aHandler; iMessage = "Restoring To Factory Defaults..."; iProgress = 0; iRebooting = false; iSettingDefaults = false; iCount = 0; iCountMax = kSettingDefaultsCount + kRebootCount; if (iHandler != null) { iHandler(iMessage, iProgress); } FactoryDefaulter defaulter = new FactoryDefaulter(aAdapterAddress, this, aUglyname); defaulter.NoExec = false; defaulter.Wait = true; // wait to discover device after reprogramming string failMessage; bool result = defaulter.Execute(out failMessage); defaulter.Close(); iProgress = 100; if (!result) { iMessage = "Resetting To Factory Defaults Failed"; } if (iHandler != null) { iHandler(iMessage, iProgress); } }