Repository navigation
Expand file tree
/
Copy pathtrrRob.py
More file actions
316 lines (261 loc) · 8.19 KB
/
Copy pathtrrRob.py
File metadata and controls
316 lines (261 loc) · 8.19 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
from time import sleep
import acmepins
import sys
import os
import subprocess
print "test roadrunner 2.0"
# aggiungere test uscita caratteri da porta seriale PD3 (UTXD1) e ingresso su PD2 (URXD1) e Bu_RxD.
# aggiungere ADC in DTS e test PD29 (AD10) e PD30 (AD11)
# pag 459 datasheet SAMA5D2 for configuration registers
# segnali PD14 .. PD18 sono assegnati con fuse a Periph A (JTAG)
# per assegnarli a GPIO senza riprogrammare i fusibili:
# mem2io -w -i fc0380c0,7c000
# mem2io -w -i fc0380c4,200
# PA30 e' settato 0x405 cioe' pull down e peripheral E cioe' SDMMC1_CD
## provo a metterlo come GPIO con: mem2io -w -i fc038000,40000000 e mem2io -w -i fc038004,200
# put PD14..PD18 as normal gpios with pullup
os.system("mem2io -w -i fc0380c0,7c000")
os.system("mem2io -w -i fc0380c4,200")
# put PA30 as normal gpio with pullup
os.system("mem2io -w -i fc038000,40000000")
os.system("mem2io -w -i fc038004,200")
color_warning = "\x1B[30;41m"
color_pass = "\x1B[30;42m"
color_normal = "\x1B[0m"
color_check = "\x1B[31m"
numerrors = 0
step = 0
#print "This is the name of the script: ", sys.argv[0]
#print "Number of arguments: ", len(sys.argv)
#print "The arguments are: " , str(sys.argv)
#Roadrunner example
#led = acmepins.GPIO(sys.argv[1],'OUTPUT')
if False:
while True:
led.on()
print "ON"
sleep(3)
led.off()
print "OFF"
sleep(3)
testlistpullup = [
["PA30","PA14"],
["PC9","PB7"],
["PC11","PC21"],
["PC23","PD18"],
["PD5","PD14"],
["PD17","PD15"],
["PD16","PD11"],
["PD6","PD11"],
["PD24","PD28"],
["PB6","PB10"],
["PD23","PD31"],
["PC8", "PA7"],
["PA2", "PA4"],
["PA26","PA29"],
["PA3", "PA10"],
["PA1", "PA23"],
["PA15","PA27"],
["PB0", "PA24"],
["PA31","PA25"],
["PB31","PB29"],
["PB27","PB25"],
["PB30","PB28"],
["PB26","PB24"],
["PD25","PD27"],
["PD26","PC5"],
["PC7", "PC4"],
["PC3", "PA5"],
["PC6", "PA0"],
["PA9", "PA16"],
["PA12","PA16"],
["PC2", "PC1"],
["PC0", "PA6"],
["PA8", "PA11"],
["PA13","PA17"],
["PB11","PB4"],
["PB3", "PB2"],
["PD4", "PC30"],
["PC15","PC13"],
["PC19","PC17"],
["PC27","PC25"],
["PB13","PB12"],
["PB5","PB1"],
["PC31","PC14"],
["PC12","PC10"],
["PC20","PC18"],
["PC16","PC26"],
["PC24","PC22"],
["PD19","PD20"],
["PD21","PD22"],
["PB8","PB9"],
["PC28","PC29"],
["PD1","PD0"],
["PD12","PD9"],
["PD13","PD8"],
["PD10","PD7"],
]
#***********************************************************************
# Test ADC
#***********************************************************************
os.system("cp /sys/bus/iio/devices/iio\:device0/in_voltage10_raw ad10")
adc10 = subprocess.check_output(["cat", "ad10"])
test = [int(s) for s in adc10.split() if s.isdigit()][0] #estrae il numero
#print "adc10 = %s" % test
if test<1200 or test>2000:
print (color_warning + "Error AD10! %s (1200..2000)" + color_normal) % (test)
numerrors = numerrors+1
else:
print (color_pass + "AD10 OK! %s (1200..2000)" + color_normal) % (test)
os.system("cp /sys/bus/iio/devices/iio\:device0/in_voltage11_raw ad11")
adc11 = subprocess.check_output(["cat", "ad11"])
test = [int(s) for s in adc11.split() if s.isdigit()][0] #estrae il numero
#print "adc11 = %s" % test
if test<420 or test>1220:
print (color_warning + "Error AD11! %s (420..1220)" + color_normal) % (test)
numerrors = numerrors+1
else:
print (color_pass + "AD11 OK! %s (420..1220)" + color_normal) % (test)
#***********************************************************************
# Test GPIO
#***********************************************************************
print "Test GPIO"
# Ciclo di scansione e test dei GPIO
myIN = False
error_counter=0
for test in testlistpullup:
testpinOUT = acmepins.GPIO(test[0],'OUTPUT')
testpinIN = acmepins.GPIO(test[1], 'INPUT')
testpinOUT.on()
# sleep(0.05)
myIN = testpinIN.get_value()
if step > 0:
print "%s -> %s" % (test[0],test[1])
print "test0=1 -> test1=%s " % myIN
if myIN==False:
print (color_warning + "%s=1 --> %s==1 ?" + color_normal) % (test[0],test[1]),
print (color_warning + "Errore ! %s in corto verso massa" + color_normal) % (test[1])
error_counter = error_counter + 1
if step > 0:
raw_input(" Press Enter")
if step > 1:
raw_input(" Press Enter")
testpinOUT.off()
# sleep(0.05)
myIN = testpinIN.get_value()
if step > 0:
print "test0=0 -> test1=%s " % myIN
if myIN==False:
print (color_warning + "%s=0 --> %s==1 ? " + color_normal) % (test[0],test[1]),
print (color_warning + "Errore ! Corto tra %s e %s" + color_normal) % (test[0],test[1])
error_counter = error_counter + 1
if step > 0:
raw_input(" Press Enter")
if step > 1:
raw_input(" Press Enter")
testpinOUT = acmepins.GPIO(test[1],'OUTPUT')
testpinIN = acmepins.GPIO(test[0], 'INPUT')
testpinOUT.on()
# sleep(0.05)
myIN = testpinIN.get_value()
if step > 0:
print "test1=1 -> test0=%s " % myIN
if myIN==False:
print (color_warning + "%s==1 ? <-- %s=1" + color_normal) % (test[0],test[1]),
print (color_warning + "Error ! %s in corto verso massa" + color_normal) % (test[0])
error_counter = error_counter + 1
if step > 0:
raw_input(" Press Enter")
if step > 1:
raw_input(" Press Enter")
testpinOUT.off()
# sleep(0.05)
myIN = testpinIN.get_value()
if step > 0:
print "test1=0 -> test0=%s " % myIN
if myIN==True:
print (color_warning + "%s==0 ? <-- %s=0 " + color_normal) % (test[0],test[1]),
print (color_warning + "Errore ! %s o %s a circuito aperto oppure %s a 3.3v" + color_normal) % (test[0],test[1],test[0])
error_counter = error_counter + 1
if step > 0:
raw_input(" Press Enter")
if step > 1:
raw_input(" Press Enter")
testpinOUT = acmepins.GPIO(test[0], 'INPUT')
testpinIN = acmepins.GPIO(test[1], 'INPUT')
# sleep(0.05)
if error_counter==0:
print color_pass + "GPIO pullup test OK" + color_normal
else:
print (color_warning + "Errors pullup: %d" + color_normal) % error_counter
numerrors = numerrors + 1
sleep(0.1)
#error_counter = 0
#print "fine test gpio : while True ..."
#while True:
# sleep(1)
sleep(0.1)
os.system("date")
sleep(1.0)
#***********************************************************************
# Test USB
#***********************************************************************
#os.system("dmesg")
os.system("ls /dev | grep 'ttyUSB0' > testusb")
testusb = subprocess.check_output(["cat", "testusb"])
print "testusb = %s" % (testusb)
if (testusb != ""):
print color_pass + "USB OK" + color_normal
else:
numerrors = numerrors + 1
print (color_warning + "USB ERROR" + color_normal)
#os.system("dmesg | grep 'CDC' > testusb")
#testusb = subprocess.check_output(["cat", "testusb"])
#print "testusb = %s" % (testusb)
#if (testusb != ""):
# print color_pass + "USB CDC Gadget OK" + color_normal
#else:
# numerrors = numerrors + 1
# print (color_warning + "USB CDC GADGET ERROR" + color_normal)
#***********************************************************************
# Test RAM
#***********************************************************************
print "Test RAM"
print "DDR2 RAM Test"
if os.system("memtester 10k 1 > null")==0:
print color_pass + "Memory OK" + color_normal
else:
print color_warning + "Memory ERROR !" + color_normal
numerrors = numerrors + 1
print ""
#***********************************************************************
# Test Ethernet
#***********************************************************************
print "Test Ethernet"
if os.system("ping -c 2 192.168.16.1")==0:
print color_pass + "ETH test OK" + color_normal
error_eth = 0
else:
print color_warning + "ERRORE DI RETE" + color_normal
numerrors = numerrors+1
error_eth = 1
#***********************************************************************
# Test Mantenimento data
#***********************************************************************
if (numerrors == 0):
print "Test Mantenimento data"
if os.system("date -s '04/13/2020 09:30:00'")==0:
print color_pass + "Date set OK" + color_normal
error_eth = 0
else:
print color_warning + "Date set NOK" + color_normal
numerrors = numerrors+1
if os.system("hwclock -w")==0:
print color_pass + "hwclock OK" + color_normal
else:
print color_warning + "hwclock NOK" + color_normal
numerrors = numerrors+1
os.system("date")
os.system("echo `date '+%s' -d '+ 9 seconds'` > /sys/class/rtc/rtc0/wakealarm")
os.system("shutdown -h now")
print "fine test."