|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
def main():
|
|
2
|
2
|
import subprocess
|
|
3
|
3
|
import glob
|
|
|
4
|
+ import sys # Import sys to access command line arguments
|
|
4
|
5
|
|
|
5
|
6
|
# 获取当前目录中的所有 .out 文件
|
|
6
|
7
|
out_files = glob.glob('*.out')
|
|
|
@@ -16,19 +17,23 @@ def main():
|
|
16
|
17
|
|
|
17
|
18
|
out_file = out_files[0] # 使用找到的第一个 .out 文件
|
|
18
|
19
|
|
|
19
|
|
- # 获取用户的多行输入
|
|
20
|
|
- print("Enter the input for mcu_coredump.exe (Ctrl-Z then Enter to finish):")
|
|
21
|
|
- user_input = []
|
|
22
|
|
- while True:
|
|
23
|
|
- try:
|
|
24
|
|
- line = input()
|
|
25
|
|
- except EOFError:
|
|
26
|
|
- break
|
|
27
|
|
- user_input.append(line)
|
|
28
|
|
-
|
|
29
|
|
- # 将输入写入文件
|
|
30
|
|
- with open('dump.txt', 'w') as file:
|
|
31
|
|
- file.write('\n'.join(user_input))
|
|
|
20
|
+ # 检查是否已提供 dump.txt 作为第一个参数
|
|
|
21
|
+ if len(sys.argv) > 1 and sys.argv[1] == 'dump.txt':
|
|
|
22
|
+ print("Using provided dump.txt file.")
|
|
|
23
|
+ else:
|
|
|
24
|
+ # 获取用户的多行输入
|
|
|
25
|
+ print("Enter the input for mcu_coredump.exe (Ctrl-Z then Enter to finish):")
|
|
|
26
|
+ user_input = []
|
|
|
27
|
+ while True:
|
|
|
28
|
+ try:
|
|
|
29
|
+ line = input()
|
|
|
30
|
+ except EOFError:
|
|
|
31
|
+ break
|
|
|
32
|
+ user_input.append(line)
|
|
|
33
|
+
|
|
|
34
|
+ # 将输入写入文件
|
|
|
35
|
+ with open('dump.txt', 'w') as file:
|
|
|
36
|
+ file.write('\n'.join(user_input))
|
|
32
|
37
|
|
|
33
|
38
|
# 运行 mcu_coredump.exe
|
|
34
|
39
|
subprocess.run(['mcu_coredump.exe', 'dump.txt', 'core'])
|