-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendCMD.py
44 lines (31 loc) · 1.26 KB
/
sendCMD.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
#!/usr/bin/env python
"""1boards.py: Threaded Script to launch read and save data from one MultiWii board and UDP."""
"""University of Glasgow's Micro Air Systems Technologies Laboratory."""
__author__ = "Aldo Vargas"
__copyright__ = "Copyright 2014 Aldux.net & MAST Lab"
__license__ = "GPL"
__version__ = "1"
__maintainer__ = "Aldo Vargas"
__email__ = "alduxvm@gmail.com"
__status__ = "Development"
import serial, struct, time, threading
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
from modules import cfg, optiUDP
from modules.multiwii import MultiWii
if __name__ == "__main__":
try:
if cfg.DRONE:
#flightController = MultiWii("/dev/tty.usbserial-AM016WP4")
flightController = MultiWii("/dev/ttyUSB0")
readThread = threading.Thread(target=flightController.getDataInf, args=(MultiWii.ATTITUDE,))
readThread.start()
if cfg.PRINT:
printThread = threading.Thread(target=cfg.manageData, args=(flightController.attitude,))
printThread.start()
if cfg.TWIS:
optiUDP.startTwisted()
except Exception,error:
print "Error: "+str(error)
flightController.ser.close()
file.close()