-
Notifications
You must be signed in to change notification settings - Fork 1
/
execer.py
52 lines (33 loc) · 898 Bytes
/
execer.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
import argparse
import time
from serial import Serial
def main():
parser = argparse.ArgumentParser(
description='Load application software via UART'
)
parser.add_argument(
'-t', '--target',
dest='target', type=str, required=True,
help='Address to begin executing from. Supply in hexadecimal format. '
'Minimum 0x0000, maximum 0xFFFF.'
)
args = parser.parse_args()
target = int(args.target, 16)
if not (0 <= target <= 0xFFFF):
raise ValueError(
'Target has invalid value. Minimum 0x0000, maximum 0xFFFF.'
)
data = bytes([
4,
(target & 0xFF), (target & 0xFF00) >> 8
])
ser = Serial(
'/dev/cu.usbserial-FT94JP1H',
baudrate=57600
)
ser.write(data)
ser.flush()
ser.close()
return
if __name__ == '__main__':
main()