@@ -3087,6 +3087,109 @@ def all_log_format_ids(self):
3087
3087
3088
3088
return ids
3089
3089
3090
+ def LoggerDocumentation_greylist(self):
3091
+ '''returns a set of messages should should be documented but
3092
+ are currently known as undocumented'''
3093
+ return set([
3094
+ "FENC", # fence
3095
+ "FTN3", # gyrofft
3096
+ "GEN", # generator
3097
+ "IE24", # generator
3098
+ "IEFC", # generator
3099
+ "IREG", # INS something
3100
+ "ISBD", # InertialSensor batch logging
3101
+ "ISBH", # InertialSensor batch logging
3102
+ "RELY", # relay
3103
+ "RTCM", # GPS
3104
+ "SBRE", # septentrio
3105
+
3106
+ "SAF1", # blimp-sim
3107
+ "SAN1", # blimp-sim
3108
+ "SAN2", # blimp-sim
3109
+ "SBA1", # blimp-sim
3110
+ "SBLM", # blimp-sim
3111
+ "SCTL", # glider-sim
3112
+ "SFA1", # blimp-sim
3113
+ "SFAN", # blimp-sim
3114
+ "SFN", # blimp-sim
3115
+ "SFT", # blimp-sim
3116
+ "SFV1", # blimp-sim
3117
+ "SMGC", # blimp-sim
3118
+ "SRT1", # blimp-sim
3119
+ "SRT2", # blimp-sim
3120
+ "SRT3", # blimp-sim
3121
+ "SSAN", # blimp-sim
3122
+
3123
+ "GLT", # glider sim
3124
+ "SL2", # glider-sim
3125
+ "SLD", # glider-sim
3126
+
3127
+ "SMVZ", # Sim-Volz
3128
+
3129
+ "SORC", # Soaring
3130
+ "VAR", # soaring
3131
+
3132
+ "TCLR", # tempcal
3133
+ "TEMP", # temperature sensor library
3134
+
3135
+ "ARHS", # autorotation
3136
+ "AROT", # autorotation
3137
+ "ARSC", # autorotation
3138
+ "ATDH", # heli autotune
3139
+ "ATNH", # heli autotune
3140
+ "ATSH", # heli autotune
3141
+ "CC", # AC_CustomControl
3142
+ "FWDT", # quadplane
3143
+ "GMB1", # sologimbal
3144
+ "GMB2", # sologimbal
3145
+ "QBRK", # quadplane
3146
+ "SURF", # surface-tracking
3147
+ "ATUN", # Copter autotune
3148
+ ])
3149
+
3150
+ def LoggerDocumentation_whitelist(self):
3151
+ '''returns a set of messages which we do not want to see
3152
+ documentation for'''
3153
+
3154
+ # we allow for no docs for replay messages, as these are not for end-users. They are
3155
+ # effectively binary blobs for replay
3156
+ # Documenting these is still useful! -pb
3157
+ REPLAY_MSGS = ['RFRH', 'RFRF', 'REV2', 'RSO2', 'RWA2', 'REV3', 'RSO3', 'RWA3', 'RMGI',
3158
+ 'REY3', 'RFRN', 'RISH', 'RISI', 'RISJ', 'RBRH', 'RBRI', 'RRNH', 'RRNI',
3159
+ 'RGPH', 'RGPI', 'RGPJ', 'RASH', 'RASI', 'RBCH', 'RBCI', 'RVOH', 'RMGH',
3160
+ 'ROFH', 'REPH', 'REVH', 'RWOH', 'RBOH', 'RSLL']
3161
+
3162
+ ret = set(REPLAY_MSGS)
3163
+
3164
+ # messages not expected to be on particular vehicles. Nothing
3165
+ # needs fixing below this point, unless you can come up with a
3166
+ # better way to avoid this list!
3167
+
3168
+ # We extract all message that need to be documented from the
3169
+ # code, but we don't pay attention to which vehicles will use
3170
+ # those messages. We *do* care about the documented messages
3171
+ # for a vehicle as we follow the tree created by the
3172
+ # documentation (eg. @Path:
3173
+ # ../libraries/AP_LandingGear/AP_LandingGear.cpp).
3174
+ vinfo_key = self.vehicleinfo_key()
3175
+ if vinfo_key != 'ArduPlane':
3176
+ ret.update([
3177
+ "TECS", # only Plane has TECS
3178
+ "TEC2", # only Plane has TECS
3179
+ "TEC3", # only Plane has TECS
3180
+ "SOAR", # only Planes can truly soar
3181
+ "SORC", # soaring is pure magic
3182
+ "QBRK", # quadplane
3183
+ "FWDT", # quadplane
3184
+ ])
3185
+ if vinfo_key == 'ArduCopter':
3186
+ ret.update([
3187
+ "CC", # only Copter has the CustomController
3188
+ ])
3189
+ # end not-expected-to-be-fixed block
3190
+
3191
+ return ret
3192
+
3090
3193
def LoggerDocumentation(self):
3091
3194
'''Test Onboard Logging Generation'''
3092
3195
xml_filepath = os.path.join(self.buildlogs_dirpath(), "LogMessages.xml")
@@ -3127,12 +3230,8 @@ def LoggerDocumentation(self):
3127
3230
objectify.enable_recursive_str()
3128
3231
tree = objectify.fromstring(xml)
3129
3232
3130
- # we allow for no docs for replay messages, as these are not for end-users. They are
3131
- # effectively binary blobs for replay
3132
- REPLAY_MSGS = ['RFRH', 'RFRF', 'REV2', 'RSO2', 'RWA2', 'REV3', 'RSO3', 'RWA3', 'RMGI',
3133
- 'REY3', 'RFRN', 'RISH', 'RISI', 'RISJ', 'RBRH', 'RBRI', 'RRNH', 'RRNI',
3134
- 'RGPH', 'RGPI', 'RGPJ', 'RASH', 'RASI', 'RBCH', 'RBCI', 'RVOH', 'RMGH',
3135
- 'ROFH', 'REPH', 'REVH', 'RWOH', 'RBOH', 'RSLL']
3233
+ whitelist = self.LoggerDocumentation_whitelist()
3234
+ greylist = self.LoggerDocumentation_greylist()
3136
3235
3137
3236
docco_ids = {}
3138
3237
for thing in tree.logformat:
@@ -3142,7 +3241,7 @@ def LoggerDocumentation(self):
3142
3241
"labels": [],
3143
3242
}
3144
3243
if getattr(thing.fields, 'field', None) is None:
3145
- if name in REPLAY_MSGS :
3244
+ if name in whitelist :
3146
3245
continue
3147
3246
raise NotAchievedException("no doc fields for %s" % name)
3148
3247
for field in thing.fields.field:
@@ -3155,10 +3254,18 @@ def LoggerDocumentation(self):
3155
3254
# self.progress("Code ids: (%s)" % str(sorted(code_ids.keys())))
3156
3255
# self.progress("Docco ids: (%s)" % str(sorted(docco_ids.keys())))
3157
3256
3257
+ undocumented = set()
3258
+ overdocumented = set()
3158
3259
for name in sorted(code_ids.keys()):
3159
3260
if name not in docco_ids:
3160
- self.progress("Undocumented message: %s" % str(name))
3261
+ if name in greylist:
3262
+ self.progress(f"{name} should be documented but isn't")
3263
+ continue
3264
+ if name not in whitelist:
3265
+ undocumented.add(name)
3161
3266
continue
3267
+ if name in whitelist:
3268
+ overdocumented.add(name)
3162
3269
seen_labels = {}
3163
3270
for label in code_ids[name]["labels"].split(","):
3164
3271
if label in seen_labels:
@@ -3168,9 +3275,19 @@ def LoggerDocumentation(self):
3168
3275
if label not in docco_ids[name]["labels"]:
3169
3276
raise NotAchievedException("%s.%s not in documented fields (have (%s))" %
3170
3277
(name, label, ",".join(docco_ids[name]["labels"])))
3278
+
3279
+ if len(undocumented):
3280
+ for name in sorted(undocumented):
3281
+ self.progress(f"Undocumented message: {name}")
3282
+ raise NotAchievedException("Undocumented messages found")
3283
+ if len(overdocumented):
3284
+ for name in sorted(overdocumented):
3285
+ self.progress(f"Message documented when it shouldn't be: {name}")
3286
+ raise NotAchievedException("Overdocumented messages found")
3287
+
3171
3288
missing = []
3172
3289
for name in sorted(docco_ids):
3173
- if name not in code_ids and name not in REPLAY_MSGS :
3290
+ if name not in code_ids and name not in whitelist :
3174
3291
missing.append(name)
3175
3292
continue
3176
3293
for label in docco_ids[name]["labels"]:
0 commit comments