View difference between Paste ID: kQjTBxgn and y0d8BeiR
SHOW: | | - or go back to the newest paste.
1
import os
2
import time
3
import serial
4
5
# Open port and wait for a reboot
6
print "Opening ttyACM0"
7
arduino = serial.Serial("/dev/ttyACM0", 9600)
8
print "Opened, flushing"
9
arduino.flushInput()
10
time.sleep(1)
11
12
print "Opening tempfile"
13
tempFile = open("/root/lammot.dat", 'w');
14
print "tempfile opened"
15
16
print "sending request"
17
arduino.write("r")
18
ch = -1
19
while (ch != 255){
20
	if arduino.inWaiting():
21
		print ch
22
		ch = arduino.read()
23
		tempFile.write(ch)
24
25-
os.system("/root/valo/lue_ja_paivita_kuvat")
25+
print "Done. closing file and arduino port"
26
arduino.close()
27
tempFile.close()
28
29
print "Moving temp file and updating graphs"
30
os.system("cp /root/lammot.dat /root/arvot.dat")
31
os.system("/root/lue_ja_paivita_kuvat")
32
os.system("/root/kosteus/lue_ja_paivita_kuvat")
33
os.system("/root/valo/lue_ja_paivita_kuvat")
34
print "Done. exiting."