Skip to content

Commit 85bcec2

Browse files
committed
Test uploading firmware
1 parent 9443434 commit 85bcec2

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/firmware.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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()

0 commit comments

Comments
 (0)