-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.py
executable file
·100 lines (84 loc) · 2.31 KB
/
interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python3
import argparse
import os
import pathlib
import subprocess
project_path = pathlib.Path(__file__).parent.absolute()
parser = argparse.ArgumentParser(
description="Interface script to execute various commands for the PIO project."
)
parser.add_argument(
"-m",
"--monitor",
nargs="?",
type=int,
const=115200,
help="Serial monitor with a default baud rate of 115200",
)
parser.add_argument(
"-b",
"--build",
action="store_true",
help="Build project for all environments specified in platformio.ini",
)
parser.add_argument(
"-bn",
"--build_nucleo",
action="store_true",
help="Build firmware for NUCLEO-F411RE",
)
parser.add_argument(
"-un",
"--upload_nucleo",
action="store_true",
help="Build and upload firmware to NUCLEO-F411RE",
)
parser.add_argument(
"-bf",
"--build_feather",
action="store_true",
help="Build firmware for Feather F405",
)
parser.add_argument(
"-uf",
"--upload_feather",
action="store_true",
help="Build and upload firmware to Feather F405",
)
parser.add_argument(
"-bh",
"--build_haloship",
action="store_true",
help="Build firmware for Haloship F405",
)
parser.add_argument(
"-uh",
"--upload_haloship",
action="store_true",
help="Build and upload firmware to Haloship F405",
)
args = parser.parse_args()
if args.monitor:
print("Starting serial monitor at {baud}...".format(baud=args.monitor))
os.system("pio device monitor --baud {baud}".format(baud=args.monitor))
elif args.build:
print("Building for all specified environments...")
os.system("pio run")
elif args.build_nucleo:
print("Building for Nucleo-F411RE...")
os.system("pio run -e nucleo")
elif args.build_feather:
print("Building for Feather F405...")
os.system("pio run -e feather")
elif args.build_haloship:
print("Building for Haloship F405...")
os.system("pio run -e haloship")
elif args.upload_nucleo:
print("Building and uploading to Nucleo-F411RE...")
os.system("pio run -e nucleo -t upload")
elif args.upload_feather:
print("Building and uploading to Feather F405...")
os.system("pio run -e feather -t upload")
elif args.upload_haloship:
print("Building and uploading to Haloship F405...")
os.system("pio run -e haloship -t upload")