/// <summary> /// Creates a new authorization module /// </summary> /// <param name="Shell">Shell to bind to</param> public Auth(ShellCore Shell) { // Sets some default values this.Retries = 3; this.TimeToLogin = 0; this._Shell = Shell; // Binds to the shell Shell.OnConnected += new ShellCore.ConnectionStateChange(this._Shell_OnConnected); Shell.OnCommandReceived += new ShellCore.CommandReceived(this._Shell_OnCommandReceived); }
/// <summary> /// New connection has been made /// </summary> /// <param name="Shell"></param> /// <param name="RemoteAddress"></param> /// <param name="Time"></param> private void _Shell_OnConnected(ShellCore Shell, string RemoteAddress, DateTime Time) { if (this.OnAuthorize == null) { Shell.TelnetServer.Print("Auth.OnAuthorize is not defined, so authorization is inactive"); return; } // Resets the current login this._Authorized = false; this._Username = ""; // Adds the timer to check for a login timeout if (this.TimeToLogin > 0) { new Timer(this._LoginTimedout, null, this.TimeToLogin * 1000, 0); } for (int i = 0; i < Retries; ++i) { // Asks for the username Shell.TelnetServer.Print("Username: "******"") { continue; } // Asks for the password (with echoing disabled!) Shell.TelnetServer.Print("Password: "******""); // Verifies the details if (this.OnAuthorize(Shell, Username, Password, RemoteAddress)) { this._Username = Username; this._Authorized = true; return; } Shell.TelnetServer.Print("Username and/or password incorrect", false, true); Shell.TelnetServer.Print(""); } // No valid login has been given Shell.TelnetServer.Print("Closing the connection"); Thread.Sleep(100); Shell.TelnetServer.Close(); }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "SERIAL": if (Arguments.Length == 1) { throw new ArgumentException("COM-port required, see HELP SERIAL for more."); } else if (Arguments.Length == 2) { Serial.Start(Shell.TelnetServer, Arguments[1]); } else if (Arguments.Length == 3) { Serial.Start(Shell.TelnetServer, Arguments[1], Arguments[2]); } else if (Arguments.Length == 4) { Serial.Start(Shell.TelnetServer, Arguments[1], Arguments[2], Arguments[3]); } else if (Arguments.Length == 5) { Serial.Start(Shell.TelnetServer, Arguments[1], Arguments[2], Arguments[3], Arguments[4]); } else { Serial.Start(Shell.TelnetServer, Arguments[1], Arguments[2], Arguments[3], Arguments[4], Arguments[5]); } SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) { PageFound = DoHelp(Shell.TelnetServer, ""); } else { PageFound = DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); } if (PageFound) { SuspressError = true; } break; } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "CD": if (Arguments.Length == 1) Shell.TelnetServer.Print(Directory.GetCurrentDirectory()); else ChangeDir(Shell.TelnetServer, Shell.LastCommandline.Substring(3).Trim()); Shell.Prompt = Directory.GetCurrentDirectory() + ">"; SuspressError = true; break; case "MKDIR": if (Arguments.Length == 1) throw new ArgumentException("Specify a directory name. See also HELP MKDIR"); CreateDir(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; break; case "RMDIR": if (Arguments.Length == 1) throw new ArgumentException("Specify a directory name. See also HELP RMDIR"); RemoveDir(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; break; case "TOUCH": if (Arguments.Length == 1) throw new ArgumentException("Specify a filename. See also HELP TOUCH"); CreateFile(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; break; case "DEL": if (Arguments.Length == 1) throw new ArgumentException("Specify a filename. See also HELP DEL"); RemoveFile(Shell.TelnetServer, Shell.LastCommandline.Substring(4).Trim()); SuspressError = true; break; case "TYPE": if (Arguments.Length == 1) throw new ArgumentException("Specify a filename. See also HELP TYPE"); DisplayFile(Shell.TelnetServer, Shell.LastCommandline.Substring(5).Trim()); SuspressError = true; break; case "DIR": if (Arguments.Length != 1) throw new ArgumentException("DIR has no valid arguments"); ListDir(Shell.TelnetServer); SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) PageFound = FileSystem.DoHelp(Shell.TelnetServer, ""); else PageFound = FileSystem.DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); if (PageFound) SuspressError = true; break; } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { if (Arguments[0].ToUpper() == "NETDUINOPLUS") { SuspressError = true; NetduinoPlus.Start(Shell.TelnetServer); } if (Arguments[0].ToUpper() == "HELP") { if (Arguments.Length == 1 || Arguments[1].ToUpper() == "NETDUINOPLUS") { Shell.TelnetServer.Print("NETDUINOPLUS An interactive Netduino Plus demo"); SuspressError = true; } } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { if (Arguments[0].ToUpper() == "NETWORKINFO") { NetworkInfo.Start(Shell.TelnetServer); SuspressError = true; } if (Arguments[0].ToUpper() == "HELP") { if (Arguments.Length == 1 || Arguments[1].ToUpper() == "NETWORKINFO") { Shell.TelnetServer.Print("NETWORKINFO Shows details about all network interfaces"); SuspressError = true; } } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private void _Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { if (Arguments[0].ToUpper() == "WHOAMI") { Shell.TelnetServer.Print("Logged in as " + this._Username); SuspressError = true; } if (Arguments[0].ToUpper() == "HELP") { if (Arguments.Length == 1 || Arguments[1].ToUpper() == "WHOAMI") { Shell.TelnetServer.Print("WHOAMI Returns the current username"); SuspressError = true; } } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { if (Arguments[0].ToUpper() == "COLORDEMO") { ColorDemo.Start(Shell.TelnetServer); SuspressError = true; } if (Arguments[0].ToUpper() == "HELP") { if (Arguments.Length == 1 || Arguments[1].ToUpper() == "COLORDEMO") { Shell.TelnetServer.Print("COLORDEMO Shows an ANSI Color demo"); SuspressError = true; } } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "TIME": if (Arguments.Length == 1) { Shell.TelnetServer.Print("Current time: " + DisplayTime()); } else { ChangeTime(Shell.TelnetServer, Arguments[1]); } SuspressError = true; break; case "DATE": if (Arguments.Length == 1) { Shell.TelnetServer.Print("Current date: " + DisplayDate()); } else { ChangeDate(Shell.TelnetServer, Arguments[1]); } SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) { PageFound = DoHelp(Shell.TelnetServer, ""); } else { PageFound = DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); } if (PageFound) { SuspressError = true; } break; } }
/// <summary> /// New connection has been made /// </summary> /// <param name="Shell"></param> /// <param name="RemoteAddress"></param> /// <param name="Time"></param> private void _Shell_OnConnected(ShellCore Shell, string RemoteAddress, DateTime Time) { if (this.OnAuthorize == null) { Shell.TelnetServer.Print("Auth.OnAuthorize is not defined, so authorization is inactive"); return; } // Resets the current login this._Authorized = false; this._Username = ""; // Adds the timer to check for a login timeout if (this.TimeToLogin > 0) new Timer(this._LoginTimedout, null, this.TimeToLogin * 1000, 0); for (int i = 0; i < Retries; ++i) { // Asks for the username Shell.TelnetServer.Print("Username: "******"") continue; // Asks for the password (with echoing disabled!) Shell.TelnetServer.Print("Password: "******""); // Verifies the details if (this.OnAuthorize(Shell, Username, Password, RemoteAddress)) { this._Username = Username; this._Authorized = true; return; } Shell.TelnetServer.Print("Username and/or password incorrect", false, true); Shell.TelnetServer.Print(""); } // No valid login has been given Shell.TelnetServer.Print("Closing the connection"); Thread.Sleep(100); Shell.TelnetServer.Close(); }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "NTPSYNC": if (Arguments.Length != 2) throw new ArgumentException("Need 1 parameter, see HELP NTPSYNC for more info."); else Ntp.Sync(Shell.TelnetServer, Arguments[1]); SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) PageFound = Ntp.DoHelp(Shell.TelnetServer, ""); else PageFound = Ntp.DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); if (PageFound) SuspressError = true; break; } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "TIME": if (Arguments.Length == 1) Shell.TelnetServer.Print("Current time: " + DisplayTime()); else ChangeTime(Shell.TelnetServer, Arguments[1]); SuspressError = true; break; case "DATE": if (Arguments.Length == 1) Shell.TelnetServer.Print("Current date: " + DisplayDate()); else ChangeDate(Shell.TelnetServer, Arguments[1]); SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) PageFound = DoHelp(Shell.TelnetServer, ""); else PageFound = DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); if (PageFound) SuspressError = true; break; } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { if (Arguments[0].ToUpper() == "EDLIN") { if (Arguments.Length == 1) throw new ArgumentException("Missing filename. See HELP EDLIN for more"); EditFile(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; } if (Arguments[0].ToUpper() == "HELP") { if (Arguments.Length == 1) { Shell.TelnetServer.Print("EDLIN [FILE] Edits a text file"); SuspressError = true; } else if (Arguments[1] == "EDLIN") { Shell.TelnetServer.Print("EDLIN [FILE] Edits a text file"); Shell.TelnetServer.Print("- [FILE] The file to edit"); SuspressError = true; } } }
/// <summary> /// Binds to the Shell Core /// </summary> /// <param name="Shell">The ShellCore object</param> /// <param name="ONBOARD_SW1">Reference to the onboard button</param> /// <param name="ONBOARD_LED">Reference to the onboard LED</param> public static void Bind(ShellCore Shell, Cpu.Pin ONBOARD_SW1, Cpu.Pin ONBOARD_LED) { NetduinoPlus.ONBOARD_SW1 = ONBOARD_SW1; NetduinoPlus.ONBOARD_LED = ONBOARD_LED; Shell.OnCommandReceived += new ShellCore.CommandReceived(Shell_OnCommandReceived); }
/// <summary> /// Binds to the Shell Core /// </summary> /// <param name="Shell">The ShellCore object</param> /// <param name="PinCount">The amount of broken out pins</param> public static void Bind(ShellCore Shell, int PinCount) { _PinLabels = new string[PinCount]; _Pins = new MultiPort[PinCount]; Shell.OnCommandReceived += new ShellCore.CommandReceived(Shell_OnCommandReceived); }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "LISTPINS": string RetVal = ""; for (int i = 0; i < _PinLabels.Length; ++i) RetVal += _PinLabels[i] + " "; Shell.TelnetServer.Print(RetVal); SuspressError = true; break; case "CONFIGPIN": if (Arguments.Length != 3) throw new ArgumentException("Need 2 parameters, see HELP CONFIGPIN for more info."); else _ConfigPin(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper()); SuspressError = true; break; case "READPIN": if (Arguments.Length != 2) throw new ArgumentException("Need 1 parameter, see HELP READPIN for more info."); else _ReadPin(Shell.TelnetServer, Arguments[1].ToUpper()); SuspressError = true; break; case "GETPINTYPE": if (Arguments.Length != 2) throw new ArgumentException("Need 1 parameter, see HELP GETPINTYPE for more info."); else _Type(Shell.TelnetServer, Arguments[1].ToUpper()); SuspressError = true; break; case "WRITEPIN": if (Arguments.Length != 3) throw new ArgumentException("Need 2 parameters, see HELP WRITEPIN for more info."); else _WritePin(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper()); SuspressError = true; break; case "DUTYCYCLE": if (Arguments.Length != 3) throw new ArgumentException("Need 2 parameters, see HELP DUTYCYCLE for more info."); else _DutyCycle(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper()); SuspressError = true; break; case "SETPULSE": if (Arguments.Length < 4) throw new ArgumentException("Need 3 parameters, see HELP SETPULSE for more info."); else _SetPulse(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper(), Arguments[3].ToUpper()); SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) PageFound = DoHelp(Shell.TelnetServer, ""); else PageFound = DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); if (PageFound) SuspressError = true; break; } }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "CLS": Shell.TelnetServer.ClearScreen(); SuspressError = true; break; case "MOTD": _SendMotd(Shell.TelnetServer); SuspressError = true; break; case "ECHO": Shell.TelnetServer.Print(Shell.LastCommandline.Substring(5)); SuspressError = true; break; case "REBOOT": Shell.TelnetServer.Print("Rebooting..."); Thread.Sleep(100); Shell.TelnetServer.Close(); PowerState.RebootDevice(false); SuspressError = true; break; case "QUIT": Shell.TelnetServer.Print("Bye!"); Thread.Sleep(100); Shell.TelnetServer.Close(); SuspressError = true; break; case "INFO": Shell.TelnetServer.Print("Manufacturer: " + SystemInfo.OEMString); Shell.TelnetServer.Print("Firmware version: " + SystemInfo.Version.ToString()); Shell.TelnetServer.Print("Memory available: " + Tools.MetricPrefix(Debug.GC(false), true) + "B"); if (PowerState.Uptime.Days == 0) { Shell.TelnetServer.Print("Uptime: " + PowerState.Uptime.ToString()); } else { Shell.TelnetServer.Print("Uptime: " + PowerState.Uptime.Days.ToString() + " days, " + PowerState.Uptime.ToString()); } Shell.TelnetServer.Print("Hardware provider: " + Tools.HardwareProvider); Shell.TelnetServer.Print("System clock: " + Tools.MetricPrefix(Cpu.SystemClock) + "hz"); Shell.TelnetServer.Print("Endianness: " + (SystemInfo.IsBigEndian ? "Big Endian" : "Little Endian")); Shell.TelnetServer.Print("Debugger: " + (System.Diagnostics.Debugger.IsAttached ? "attached" : "not attached")); SuspressError = true; break; case "VER": System.Reflection.Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < Assemblies.Length; ++i) { Shell.TelnetServer.Print(Assemblies[i].FullName); } SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) { PageFound = DoHelp(Shell.TelnetServer, ""); } else { PageFound = DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); } if (PageFound) { SuspressError = true; } break; } }
/// <summary> /// Triggered when the connection has been made /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="RemoteAddress">Hostname of the user</param> /// <param name="Time">Timestamp of the event</param> private static void Shell_OnConnected(ShellCore Shell, string RemoteAddress, DateTime Time) { Shell.TelnetServer.Color(TelnetServer.Colors.White, TelnetServer.Colors.Black); Shell.TelnetServer.ClearScreen(); _SendMotd(Shell.TelnetServer); }
/// <summary> /// Unbinds from the Shell Core /// </summary> /// <param name="Shell">The ShellCore object</param> public static void Unbind(ShellCore Shell) { Shell.OnConnected -= new ShellCore.ConnectionStateChange(Shell_OnConnected); Shell.OnCommandReceived -= new ShellCore.CommandReceived(Shell_OnCommandReceived); }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "CD": if (Arguments.Length == 1) { Shell.TelnetServer.Print(Directory.GetCurrentDirectory()); } else { ChangeDir(Shell.TelnetServer, Shell.LastCommandline.Substring(3).Trim()); } Shell.Prompt = Directory.GetCurrentDirectory() + ">"; SuspressError = true; break; case "MKDIR": if (Arguments.Length == 1) { throw new ArgumentException("Specify a directory name. See also HELP MKDIR"); } CreateDir(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; break; case "RMDIR": if (Arguments.Length == 1) { throw new ArgumentException("Specify a directory name. See also HELP RMDIR"); } RemoveDir(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; break; case "TOUCH": if (Arguments.Length == 1) { throw new ArgumentException("Specify a filename. See also HELP TOUCH"); } CreateFile(Shell.TelnetServer, Shell.LastCommandline.Substring(6).Trim()); SuspressError = true; break; case "DEL": if (Arguments.Length == 1) { throw new ArgumentException("Specify a filename. See also HELP DEL"); } RemoveFile(Shell.TelnetServer, Shell.LastCommandline.Substring(4).Trim()); SuspressError = true; break; case "TYPE": if (Arguments.Length == 1) { throw new ArgumentException("Specify a filename. See also HELP TYPE"); } DisplayFile(Shell.TelnetServer, Shell.LastCommandline.Substring(5).Trim()); SuspressError = true; break; case "DIR": if (Arguments.Length != 1) { throw new ArgumentException("DIR has no valid arguments"); } ListDir(Shell.TelnetServer); SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) { PageFound = FileSystem.DoHelp(Shell.TelnetServer, ""); } else { PageFound = FileSystem.DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); } if (PageFound) { SuspressError = true; } break; } }
/// <summary> /// Binds to the Shell Core /// </summary> /// <param name="Shell">The ShellCore object</param> public static void Bind(ShellCore Shell) { Shell.OnCommandReceived += new ShellCore.CommandReceived(Shell_OnCommandReceived); Shell.Prompt = Directory.GetCurrentDirectory() + ">"; }
/// <summary> /// Triggered when a command has been given /// </summary> /// <param name="Shell">Reference to the shell</param> /// <param name="Arguments">Command line arguments</param> /// <param name="SuspressError">Set to 'true' if you could do anything with the command</param> /// <param name="Time">Current timestamp</param> private static void Shell_OnCommandReceived(ShellCore Shell, string[] Arguments, ref bool SuspressError, DateTime Time) { switch (Arguments[0].ToUpper()) { case "LISTPINS": string RetVal = ""; for (int i = 0; i < _PinLabels.Length; ++i) { RetVal += _PinLabels[i] + " "; } Shell.TelnetServer.Print(RetVal); SuspressError = true; break; case "CONFIGPIN": if (Arguments.Length != 3) { throw new ArgumentException("Need 2 parameters, see HELP CONFIGPIN for more info."); } else { _ConfigPin(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper()); } SuspressError = true; break; case "READPIN": if (Arguments.Length != 2) { throw new ArgumentException("Need 1 parameter, see HELP READPIN for more info."); } else { _ReadPin(Shell.TelnetServer, Arguments[1].ToUpper()); } SuspressError = true; break; case "GETPINTYPE": if (Arguments.Length != 2) { throw new ArgumentException("Need 1 parameter, see HELP GETPINTYPE for more info."); } else { _Type(Shell.TelnetServer, Arguments[1].ToUpper()); } SuspressError = true; break; case "WRITEPIN": if (Arguments.Length != 3) { throw new ArgumentException("Need 2 parameters, see HELP WRITEPIN for more info."); } else { _WritePin(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper()); } SuspressError = true; break; case "DUTYCYCLE": if (Arguments.Length != 3) { throw new ArgumentException("Need 2 parameters, see HELP DUTYCYCLE for more info."); } else { _DutyCycle(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper()); } SuspressError = true; break; case "SETPULSE": if (Arguments.Length < 4) { throw new ArgumentException("Need 3 parameters, see HELP SETPULSE for more info."); } else { _SetPulse(Shell.TelnetServer, Arguments[1].ToUpper(), Arguments[2].ToUpper(), Arguments[3].ToUpper()); } SuspressError = true; break; case "HELP": bool PageFound = false; if (Arguments.Length == 1) { PageFound = DoHelp(Shell.TelnetServer, ""); } else { PageFound = DoHelp(Shell.TelnetServer, Arguments[1].ToUpper()); } if (PageFound) { SuspressError = true; } break; } }
/// <summary> /// Unbinds from the Shell Core /// </summary> /// <param name="Shell">The ShellCore object</param> public static void Unbind(ShellCore Shell) { Shell.OnCommandReceived -= new ShellCore.CommandReceived(Shell_OnCommandReceived); }