forked from mattvenn/machinekit-bipod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.py
More file actions
executable file
·51 lines (41 loc) · 1.14 KB
/
control.py
File metadata and controls
executable file
·51 lines (41 loc) · 1.14 KB
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
#!/usr/bin/python
import socket
import argparse
HOST = 'localhost'
PORT = 10001
def send(cmd):
# Connect to the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(True)
s.settimeout(2)
s.connect((HOST, PORT))
len_sent = s.send(cmd)
# Receive a response
response = s.recv(1024)
print('received [%s]' % response)
# Clean up
s.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="control bipod process")
parser.add_argument('--start',
action='store_const', const=True)
parser.add_argument('--quit',
action='store_const', const=True)
parser.add_argument('--skip',
action='store_const', const=True)
parser.add_argument('--programs',
action='store_const', const=True)
parser.add_argument('--halt',
action='store_const', const=True)
args = parser.parse_args()
# Send the message
if args.start:
send('start')
elif args.quit:
send('quit')
elif args.skip:
send('skip')
elif args.programs:
send('programs')
elif args.halt:
send('halt')