File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ """Test uploading firmware"""
2+
3+ import time
4+ import unittest
5+ from multiprocessing import Process
6+
7+ from gpiozero import DigitalOutputDevice
8+
9+ RESET_GPIO_NUMBER = 4
10+ BOOT0_GPIO_NUMBER = 22
11+
12+
13+ def resethat ():
14+ """Reset the HAT"""
15+ reset = DigitalOutputDevice (RESET_GPIO_NUMBER )
16+ boot0 = DigitalOutputDevice (BOOT0_GPIO_NUMBER )
17+ boot0 .off ()
18+ reset .off ()
19+ time .sleep (0.01 )
20+ reset .on ()
21+ time .sleep (0.01 )
22+ boot0 .close ()
23+ reset .close ()
24+ time .sleep (0.5 )
25+
26+
27+ def reboot ():
28+ """Reboot hat"""
29+ from buildhat import Hat
30+ resethat ()
31+ h = Hat (debug = True )
32+ print (h .get ())
33+
34+
35+ class TestFirmware (unittest .TestCase ):
36+ """Test firmware uploading functions"""
37+
38+ def test_upload (self ):
39+ """Test uploading firmware"""
40+ for _ in range (200 ):
41+ p = Process (target = reboot )
42+ p .start ()
43+ p .join ()
44+
45+
46+ if __name__ == '__main__' :
47+ unittest .main ()
You can’t perform that action at this time.
0 commit comments