-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpio.py
executable file
·108 lines (86 loc) · 2.51 KB
/
gpio.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
#!/usr/bin/python
# Banco di Test per NetusG20 e FOX Board G20
# Software lato FOX
# Author: Sergio Tanzilli - [email protected]
import time
import fox
import urllib2
# Test GPIO
print "Test GPIO"
test = {
"J6" : [
["3","4"],
["5","6"],
["7","8"],
["9","10"],
["13","14"],
["15","16"],
["17","18"],
["19","20"],
["21","22"],
["24","36"],
["25","26"],
["27","28"],
["29","30"],
["31","32"],
["37","38"],
["24","36"],
],
"J7" : [
["3", "4"],
["5", "6"],
["7", "8"],
["9", "10"],
["11","12"],
["13","14"],
["15","16"],
["17","18"],
["21","22"],
["31","32"],
["33","34"],
["35","36"],
["37","38"],
],
}
for connector_index, connector_item in enumerate(test):
#print connector_index, connector_item, test[connector_item]
for test_index, test_item in enumerate(test[connector_item]):
#for pin_index, pin_item in enumerate(test[connector_item][test_index]):
#print "Test %s.%s - %s.%s" % (connector_item,test_item[0],connector_item,test_item[1])
while True:
error_counter=0
pin_out = fox.Pin(connector_item,test_item[0],'low')
pin_in = fox.Pin(connector_item,test_item[1],'in')
if pin_in.get_value()<>0:
print "gpio error %s.%s = low -> %s.%s" % (connector_item,test_item[0],connector_item,test_item[1])
error_counter = error_counter + 1
pin_out = fox.Pin(connector_item,test_item[0],'high')
pin_in = fox.Pin(connector_item,test_item[1],'in')
if pin_in.get_value()<>1:
print "gpio error %s.%s = high -> %s.%s" % (connector_item,test_item[0],connector_item,test_item[1])
error_counter = error_counter + 1
pin_out = fox.Pin(connector_item,test_item[1],'low')
pin_in = fox.Pin(connector_item,test_item[0],'in')
if pin_in.get_value()<>0:
print "gpio error %s.%s = low -> %s.%s" % (connector_item,test_item[1],connector_item,test_item[0])
error_counter = error_counter + 1
pin_out = fox.Pin(connector_item,test_item[1],'high')
pin_in = fox.Pin(connector_item,test_item[0],'in')
if pin_in.get_value()<>1:
print "gpio error %s.%s = high -> %s.%s" % (connector_item,test_item[1],connector_item,test_item[0])
error_counter = error_counter + 1
if error_counter==0:
break
else:
print "Sistema le strip..."
time.sleep(1)
print "GPIO test OK"
for i in range(1,5):
try:
contents = urllib2.urlopen("http://192.168.1.242/index.html").read()
print "LAN test OK (try %d)" % i
break
except:
print "LAN error (try %d)" % i
time.sleep(1)
continue