/// <summary> /// 程序入口 /// </summary> /// <param name="args">用户输入的参数</param> public void Run(string[] args) { this.args = args; if (IsBaseCommand()) { Next(); } else if (!Uart.HasPort()) { Console.WriteLine("没有可用端口"); Next(); } else { UartCommand(); Next(); } }
public App(bool runOnce = false) { if (Uart.HasPort()) { port = Uart.GetPort(); } this.runOnce = runOnce; if (!runOnce) { Console.WriteLine("输入help获取帮助信息"); } // 设置工作目录 this.workDir = Directory.GetCurrentDirectory(); string execFile = System.Reflection.Assembly.GetExecutingAssembly().Location; this.execDir = Directory.GetParent(execFile).FullName; // 加载基础配置 this.config = Config.Load(); uart.sp.BaudRate = this.config.BaudRate; // 加载用户配置 if (UserConfig.Exists()) { this.hasUserConfig = true; this.userConfig = UserConfig.Load(); // 设置串口参数 this.uart.sp.BaudRate = this.userConfig.BaudRate; } else { // 设置串口参数 this.uart.sp.BaudRate = config.BaudRate; } }