Skip to content

Commit aa3569c

Browse files
author
Daniel Campora
committed
cc3200: Add factory smoke test as part of the tools.
1 parent 8cd9fed commit aa3569c

2 files changed

Lines changed: 164 additions & 0 deletions

File tree

cc3200/tools/smoke.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import pyb
2+
import os
3+
4+
"""
5+
Execute it like this:
6+
7+
python3 run-tests --target wipy --device 192.168.1.1 ../cc3200/tools/smoke.py
8+
"""
9+
10+
pin_map = [2, 1, 23, 24, 11, 12, 13, 14, 15, 16, 17, 22, 28, 10, 9, 8, 7, 6, 30, 31, 3, 0, 4, 5]
11+
test_bytes = os.urandom(2048)
12+
13+
def test_pin_read (type):
14+
# enable the pull resistor on all pins, then read the value
15+
for p in pin_map:
16+
pin = pyb.Pin('GP' + str(p), af= 0, mode=pyb.Pin.IN, type=type)
17+
# read the pin value
18+
print (pin.value())
19+
20+
def test_pin_shorts (type):
21+
if type == pyb.Pin.STD_PU:
22+
type_inverted = pyb.Pin.STD_PD
23+
else:
24+
type_inverted = pyb.Pin.STD_PU
25+
# enable all pulls of the specified type
26+
for p in pin_map:
27+
pin = pyb.Pin('GP' + str(p), af= 0, mode=pyb.Pin.IN, type=type_inverted)
28+
# then change the pull one pin at a time and read its value
29+
i = 0
30+
while i < len(pin_map):
31+
pin = pyb.Pin('GP' + str(pin_map[i]), af= 0, mode=pyb.Pin.IN, type=type)
32+
pyb.Pin('GP' + str(pin_map[i - 1]), af= 0, mode=pyb.Pin.IN, type=type_inverted)
33+
i += 1
34+
# read the pin value
35+
print (pin.value())
36+
37+
test_pin_read(pyb.Pin.STD_PU)
38+
test_pin_read(pyb.Pin.STD_PD)
39+
test_pin_shorts(pyb.Pin.STD_PU)
40+
test_pin_shorts(pyb.Pin.STD_PD)
41+
42+
# create a test directory
43+
os.mkdir('/flash/test')
44+
os.chdir('/flash/test')
45+
print(os.getcwd())
46+
# create a new file
47+
f = open ('test.txt', 'w')
48+
n_w = f.write (test_bytes)
49+
print (n_w == len(test_bytes))
50+
f.close()
51+
f = open('test.txt', 'r')
52+
r = bytes(f.readall(), 'ascii')
53+
# check that we can write and read it correctly
54+
print (r == test_bytes)
55+
f.close()
56+
os.remove('test.txt')
57+
os.chdir('..')
58+
os.rmdir('test')
59+
60+
ls = os.listdir()
61+
print('test' not in ls)
62+
print(ls)
63+

cc3200/tools/smoke.py.exp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
1
2+
1
3+
1
4+
1
5+
1
6+
1
7+
1
8+
1
9+
1
10+
1
11+
1
12+
1
13+
1
14+
1
15+
1
16+
1
17+
1
18+
1
19+
1
20+
1
21+
1
22+
1
23+
1
24+
1
25+
0
26+
0
27+
0
28+
0
29+
0
30+
0
31+
0
32+
0
33+
0
34+
0
35+
0
36+
0
37+
0
38+
0
39+
0
40+
0
41+
0
42+
0
43+
0
44+
0
45+
0
46+
0
47+
0
48+
0
49+
1
50+
1
51+
1
52+
1
53+
1
54+
1
55+
1
56+
1
57+
1
58+
1
59+
1
60+
1
61+
1
62+
1
63+
1
64+
1
65+
1
66+
1
67+
1
68+
1
69+
1
70+
1
71+
1
72+
1
73+
0
74+
0
75+
0
76+
0
77+
0
78+
0
79+
0
80+
0
81+
0
82+
0
83+
0
84+
0
85+
0
86+
0
87+
0
88+
0
89+
0
90+
0
91+
0
92+
0
93+
0
94+
0
95+
0
96+
0
97+
/flash
98+
True
99+
True
100+
True
101+
['main.py', 'sys', 'lib', 'cert', 'boot.py']

0 commit comments

Comments
 (0)