Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/autotest/logger_metadata/emit_md.py
9824 views
1
'''
2
AP_FLAKE8_CLEAN
3
'''
4
5
import os
6
import time
7
import emitter
8
9
10
class MDEmitter(emitter.Emitter):
11
def preface(self):
12
if os.getenv('BRDOC') is not None:
13
now = time.strftime('%Y-%m-%dT%H:%M:%S%z')
14
now = now[:-2] + ':' + now[-2:]
15
return '\n'.join((
16
'+++',
17
'title = "Onboard Log Messages"',
18
'description = "Message listing for DataFlash autopilot logs."',
19
f'date = {now}',
20
'template = "docs/page.html"',
21
'sort_by = "weight"',
22
'weight = 30',
23
'draft = false',
24
'[extra]',
25
'toc = true',
26
'top = false',
27
'+++\n',
28
'<!-- Dynamically generated using Tools/autotest/logger_metadata/parse.py',
29
'DO NOT EDIT -->',
30
'This is a list of log messages which may be present in DataFlash (`.bin`) '
31
'logs produced and stored onboard ArduSub vehicles (see [Log Parameters]'
32
'(../parameters/#log-parameters) for creation details). '
33
'It is possible to [add a new message]'
34
'(https://ardupilot.org/dev/docs/code-overview-adding-a-new-log-message.html) '
35
'by modifying the firmware.\n',
36
'DataFlash logs can be downloaded and analysed '
37
'[from a computer](http://www.ardusub.com/reference/data-logging.html#downloading) '
38
'or [through BlueOS]'
39
'(@/software/onboard/BlueOS-1.1/advanced-usage/index.md#log-browser).\n'
40
))
41
42
return """<!-- Dynamically generated list of Logger Messages
43
This page was generated using Tools/autotest/logger_metdata/parse.py
44
45
DO NOT EDIT
46
-->
47
48
49
<h3 style="text-align: center">Onboard Message Log Messages</h3>
50
<hr />
51
52
<p>This is a list of log messages which may be present in logs produced and stored onboard ArduPilot vehicles.</p>
53
54
<!-- add auto-generated table of contents with "Table of Contents Plus" plugin -->
55
[toc exclude="Onboard Message Log Messages"]
56
57
"""
58
59
def postface(self):
60
return ""
61
62
def start(self):
63
self.fh = open("LogMessages.md", mode='w')
64
print(self.preface(), file=self.fh)
65
66
def emit(self, doccos, enumerations=None):
67
self.start()
68
for docco in doccos:
69
print(f'## {docco.name}', file=self.fh)
70
desc = ''
71
if docco.description is not None:
72
desc += docco.description
73
if docco.url is not None:
74
desc += f' ([Read more...]({docco.url}))'
75
print(desc, file=self.fh)
76
print("\n|FieldName|Units/Type|Description|\n|---|---|---|", file=self.fh)
77
for f in docco.fields_order:
78
if "description" in docco.fields[f]:
79
fdesc = docco.fields[f]["description"]
80
else:
81
fdesc = ""
82
if "units" in docco.fields[f] and docco.fields[f]["units"] != "":
83
ftypeunits = docco.fields[f]["units"]
84
elif "fmt" in docco.fields[f] and "char" in docco.fields[f]["fmt"]:
85
ftypeunits = docco.fields[f]["fmt"]
86
elif "bitmaskenum" in docco.fields[f]:
87
ftypeunits = "bitmask"
88
elif "valueenum" in docco.fields[f]:
89
ftypeunits = "enum"
90
else:
91
ftypeunits = ""
92
print(f'|{f}|{ftypeunits}|{fdesc}|', file=self.fh)
93
print("", file=self.fh)
94
self.stop()
95
96
def stop(self):
97
print(self.postface(), file=self.fh)
98
self.fh.close()
99
100