-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_test.py
executable file
·86 lines (65 loc) · 1.89 KB
/
tree_test.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
#!/usr/bin/python
# testing for tree structures
from boneless.arch.opcode import Instr
from boneless.arch.opcode import *
from spork.firmware.base import *
from spork.lib.uartIO import UART
from spork.lib.tree import Tree, ShowTree
from spork.firmware.firmware import Firmware
from spork.logger import logger
log = logger(__name__)
def descend_children():
pass
class TreeTest(Firmware):
"Take the firmware registers and make them into tree"
" WORKS!!! 20220410 "
def setup(self):
self.w.req(["temp", "counter", "wait", "depth"])
# Create the tree structures
m = self.m = Tree("reg")
reg = self.reg
def recurse(item, m):
if type(item) == int:
return
# if type(item) == type(int):
# return
for i, j in item._children.items():
sub = m.add(i)
recurse(j, sub)
recurse(reg, m)
# sub = m.add("hello", None)
# un2 = m.add("two", None)
# for i in range(20):
# un2.add('added'+str(i))
# m.add("three", None)
# m.add("four",None)
# sub.add("test", None)
# un = sub.add("fnord", None)
# for i in range(10):
# un2.add("again" + str(i ), None)
# un.add("longer")
def prelude(self):
return []
# def extra(self):
# return self.m.code()
def instr(self):
w = self.w
reg = self.reg
ll = LocalLabels()
uart = UART()
sm = ShowTree()
ll = LocalLabels()
return [
self.m(w.temp),
MOVI(w.depth, 0),
sm(w.temp, w.depth),
ll("again"),
J(ll.again),
]
firmware = TreeTest
if __name__ == "__main__":
from spork.upload import Uploader
import fwtest
spork = fwtest.build(firmware)
up = Uploader()
up.upload(spork)