-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharduino2.py
executable file
·122 lines (92 loc) · 3.03 KB
/
arduino2.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import serial
import time
from auto_invoke_demos import classify
import subprocess
import os
# from window import w
# import tkinter
# windowCreated = False
# try: mainWindow
# except NameError: mainWindow = None
# if mainWindow is None:
# mainWindow = tkinter.Tk()
# windowCreated = True
#
# v = tkinter.StringVar()
DETACHED_PROCESS = 0x00000008
DETACHED_PROCESS2 = 0x00000009
DETACHED_PROCESS3 = 0x00000007
"""
1. // Yellow button
2. A: void move_one()
3. // Green button
4. A: void move_all()
5. A: void send_kinect()
6. A: void start_platform()
7. Py: collect_data()
8. A: void send_classify()
9. Py: kill_kinect_data_collection()
10. Py: classify()
11. A: void put_the_item_in_the_right_slot()
12. RESET
"""
# port = '/dev/cu.
ports = []
# class Window():
#
# def __init__(self):
# global label2
# v.set('nothing...')
# label = tkinter.Label(mainWindow, text='Current Activity: ')
# label.pack()
# label2 = tkinter.Label(mainWindow, textvariable=v)
# label2.pack()
# mainWindow.mainloop()
#
#
# def changeActivity(self, mess):
# global v
# v.set(mess)
def send_plastic():
arduinoSerialData = serial.Serial('COM4', 9600)
arduinoSerialData.write("rsdl")
# def createWindow():
# global label2
# v.set('nothing...')
# label = tkinter.Label(mainWindow, text='Current Activity: ')
# label.pack()
# label2 = tkinter.Label(mainWindow, textvariable=v)
# label2.pack()
# mainWindow.mainloop()
# def changeActivity(message):
# global v
# v.set(message)
if __name__ == '__main__':
# Starting the main window
# p3 = subprocess.Popen(['python', 'window.py'], creationflags=DETACHED_PROCESS).pid
port = 'COM4'
arduinoSerialData = serial.Serial(port, 9600)
ports.append(arduinoSerialData)
while True:
if arduinoSerialData.in_waiting > 0:
mySignal = arduinoSerialData.readline()
mySignal = mySignal.decode('utf-8')
# print(mySignal)
if 'k_on' in mySignal:
print("Turning on Kinect V2...")
# changeActivity('Turning Kinect V2 on...')
p = subprocess.Popen(['python', '-i', 'start_kinect.py'], creationflags=DETACHED_PROCESS).pid
# p_stdout = p.communicate()[0]
elif 'class' in mySignal:
print("Starting classification...")
# window.Window('Received: class')
# changeActivity('Starting the motor and data collection')
# p2 = subprocess.Popen(['python', '-i', 'classify.py'], creationflags=DETACHED_PROCESS2).pid
p2 = subprocess.Popen(['python', '-i', 'classification_main.py'])
# p2_stdout = p2.communicate()[0]
elif 'hitme' in mySignal:
print("Arduino is waiting for results...")
# window.Window('Received: hit me')
# changeActivity('Sending results to Arduino')
# print("Replying...")
# arduinoSerialData.write(2)