-
Notifications
You must be signed in to change notification settings - Fork 2
/
mainTestbed.py
128 lines (97 loc) · 3.59 KB
/
mainTestbed.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
121
122
123
124
125
126
127
128
import RPi.GPIO as GPIO
import csv, os, time, RpiInit, subprocess
from datetime import datetime
from Tah_Testing import Tah
from lcd import HD44780
#GPIO.setmode(GPIO.BOARD)
#GPIO.setup(22, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
prev_state = 0
testbed = Tah()
lcd = HD44780()
lcd.__init__()
lcd.clear()
lcd.message('Begin Testing')
datestamp = "%s-%s-%s" % (datetime.now().year,datetime.now().month, datetime.now().day)
datestamp = 'logs/'+datestamp + '.csv'
f = open(datestamp, 'a+')
writer = csv.writer(f)
writer.writerow( ('Sr.No', 'Start Time', 'End Time','Elapsed Time','Remark') )
row =5
col =0
count =0
val =0
i=0
try :
while True:
RpiInit.init()
val =val+1
# Switch input
startTest = GPIO.input(11) #Read Start pulse from Switch S1
print startTest
if((not prev_state) and startTest): #switch press
GPIO.output(23,GPIO.HIGH) #Buzzer ON
time.sleep(0.5)
GPIO.output(23,GPIO.LOW) # OFF Buzzer
#Change port
# os.system("sudo python /home/pi/Tah_Testbed/testbedpatch.py")
os.chdir('/dev') # change this to /dev eventually
ls = subprocess.Popen('ls', stdout=subprocess.PIPE)
grep = subprocess.check_output(('grep','ACM[0-9]'), stdin=ls.stdout)
ls.wait()
port = grep.rstrip()
print port
#Test Start Time Log
lcd.__init__()
StartTime = datetime.now()
# Now test for Analog HIGH states
lcd.__init__()
lcd.message('Analog Testing')
os.chdir("/home/pi/Tah_Testbed/"+port+"/setAnalogHigh/")
os.system("make")
os.system("make upload")
time.sleep(1)
AH = testbed.testAnalogHigh()
print AH
lcd.__init__()
lcd.message('GPIO Testing...')
os.chdir("/home/pi/Tah_Testbed/"+port+"/setGPIOHigh/")
os.system("make")
os.system("make upload")
time.sleep(1)
DH = testbed.testGPIOHigh()
print DH
print "Done Testing"
if(AH==6 and DH >=10):
'''lcd.__init__()
lcd.message('Uploading ArdSCL')'''
os.chdir("/home/pi/Tah_Testbed/"+port+"/ArdSCL/") # Upload ArdSCL sketche
# os.system("make")
os.system("make upload")
EndTime = datetime.now()
ElapsedTime = EndTime - StartTime
print "ElapsedTime:",ElapsedTime
#print "Start Time:",StartTime
writer.writerow((i+1, StartTime, EndTime,ElapsedTime,'PASS'))
print 'PASS'
i=i+1
GPIO.output(23,GPIO.HIGH)
time.sleep(1)
GPIO.output(23,GPIO.LOW)
lcd.__init__()
lcd.message('Tested OK!')
else:
EndTime = datetime.now()
ElapsedTime = EndTime - StartTime
print "ElapsedTime:",ElapsedTime
writer.writerow((i+1, StartTime, EndTime,ElapsedTime,'Failed'))
i=i+1
GPIO.output(23,GPIO.HIGH)
time.sleep(0.5)
GPIO.output(23,GPIO.LOW)
lcd.__init__()
lcd.message('Failed !')
else:
print "Start Test"
except KeyboardInterrupt:
print "Done testing"
f.close()