CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/scripts/frame_sizes.py
Views: 1798
1
#!/usr/bin/env python
2
3
import re, sys, operator, os
4
5
code_line = re.compile("^\s*\d+:/")
6
frame_line = re.compile("^\s*\d+\s+/\* frame size = (\d+) \*/")
7
8
class frame(object):
9
def __init__(self, code, frame_size):
10
self.code = code
11
self.frame_size = int(frame_size)
12
13
frames = []
14
15
def process_lst(filename):
16
'''process one lst file'''
17
last_code = ''
18
h = open(filename, mode='r')
19
for line in h:
20
if code_line.match(line):
21
last_code = line.strip()
22
elif frame_line.match(line):
23
frames.append(frame(last_code, frame_line.match(line).group(1)))
24
h.close()
25
26
if len(sys.argv) > 1:
27
dname = sys.argv[1]
28
else:
29
dname = '.'
30
31
for root, dirs, files in os.walk(dname):
32
for f in files:
33
if f.endswith(".lst"):
34
process_lst(os.path.join(root, f))
35
36
sorted_frames = sorted(frames,
37
key=operator.attrgetter('frame_size'),
38
reverse=True)
39
40
print("FrameSize Code")
41
for frame in sorted_frames:
42
if frame.frame_size > 0:
43
print("%9u %s" % (frame.frame_size, frame.code))
44
45
46