diff --git a/AirISP/BasicOperation.cs b/AirISP/BasicOperation.cs index d577846..03cc9a6 100644 --- a/AirISP/BasicOperation.cs +++ b/AirISP/BasicOperation.cs @@ -75,7 +75,7 @@ public static bool Begin() catch (Exception ex) { ColorfulConsole.WarnLine($"{(Tool.IsZh() ? "打开串口失败" : "Failed to open serial port")}: {ex.Message}"); - Environment.Exit(0); + Environment.Exit(2); return false; } return true; @@ -239,7 +239,7 @@ public static bool ResetBootloader() "你可以尝试手动进入boot模式:\r\n" + "拔掉USB、按住BOOT按键不要松开、插入USB,重新尝试下载操作。\r\n" + "下载完成后,再松开松开BOOT按键,此时再按一下RST复位即可。" : "fail to reset device to boot status, timeout, exit..."); - Environment.Exit(0); + Environment.Exit(1); return false; } diff --git a/AirISP/WriteFlash.cs b/AirISP/WriteFlash.cs index 8fba74f..37cf4ac 100644 --- a/AirISP/WriteFlash.cs +++ b/AirISP/WriteFlash.cs @@ -44,7 +44,7 @@ public static bool WriteFlash() break; default: ColorfulConsole.WarnLine($"Please enter the correct filename."); - Environment.Exit(0); + Environment.Exit(3); return false; } @@ -87,7 +87,7 @@ public static bool WriteFlash() if (BasicOperation.Write(command, 500) == false) { ColorfulConsole.WarnLine($"prepare writing to address 0x{now:X} failed."); - return false; + Environment.Exit(4); } var addrBytes = new byte[5] { (byte)(now/256/256/256), @@ -103,7 +103,7 @@ public static bool WriteFlash() if (BasicOperation.Write(addrBytes) == false) { ColorfulConsole.WarnLine($"set write address 0x{now:X} failed."); - return false; + Environment.Exit(4); } var flashData = new byte[1 + 128 + 1]; @@ -118,7 +118,7 @@ public static bool WriteFlash() if (BasicOperation.Write(flashData, 500) == false) { ColorfulConsole.WarnLine($"writing to address 0x{now:X} failed."); - return false; + Environment.Exit(4); } now += 0x80; diff --git a/exitcode.txt b/exitcode.txt new file mode 100644 index 0000000..09009d7 --- /dev/null +++ b/exitcode.txt @@ -0,0 +1,5 @@ +0 - normal +1 - no ACK recieved. see https://wiki.luatos.com/chips/air001/mcu.html#id4 +2 - Failed to open serial port +3 - file does not exit +4 - writing failed. \ No newline at end of file