-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroundSystemsData.py
73 lines (59 loc) · 1.63 KB
/
GroundSystemsData.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
# Connect usb to serial converter
# Run using python3 AvionicsMockData.py
# Enter serial port name
import binascii
import serial
import time
def launch(ser):
ser.write(b'\x20\x00')
time.sleep(1)
print('Launch Command Sent\n')
def arm(ser):
ser.write(b'\x21\x00')
time.sleep(1)
print('Arm Command Sent\n')
def heartbeat(ser):
ser.write(b'\x46\x00')
time.sleep(1)
def openINJ(ser):
ser.write(b'\x2A\x00')
time.sleep(1)
print('INJ Opened\n')
def closeINJ(ser):
ser.write(b'\x2B\x00')
time.sleep(1)
print('INJ Closed\n')
def abort(ser):
ser.write(b'\x2F\x00')
time.sleep(1)
print('Abort Command Sent\n')
def reset(ser):
ser.write(b'\x4F\x00')
time.sleep(1)
print('Reset Command Sent\n')
def receive(ser):
print(binascii.hexlify(ser.read(256)))
def help():
print('Commands:')
print('launch')
print('arm')
print('openINJ')
print('closeINJ')
print('abort')
print('reset')
print('receive\n')
if __name__ == "__main__":
port = input('Enter a Serial Port to connect to:') #Linux: /dev/ttyUSBx, Windows: COMx
ser = serial.Serial(port, 9600, timeout=0)
while(True):
heartbeat(ser)
comm = input("Enter command (enter help for list of commands):")
if(comm == 'launch'): launch(ser)
elif(comm == 'arm'): arm(ser)
elif(comm == 'openINJ'): openINJ(ser)
elif(comm == 'closeINJ'): closeINJ(ser)
elif(comm == 'abort'): abort(ser)
elif(comm == 'reset'): reset(ser)
elif(comm == 'help'): help()
elif(comm == 'receive'): receive(ser)
time.sleep(1.0)