Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
add exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
UID163844189 authored and chenxuuu committed Sep 26, 2023
1 parent 914c259 commit cd1158e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions AirISP/BasicOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions AirISP/WriteFlash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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),
Expand All @@ -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];
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions exitcode.txt
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit cd1158e

Please sign in to comment.