Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Logger: Add enum information to VER log message metadata #26308

Merged

Conversation

shancock884
Copy link
Contributor

@shancock884 shancock884 commented Feb 23, 2024

The aim of this PR is to add help text for the VER and FILE log messages (linked to issue #26088).

Implemented by adding the relevant comment tags into AP_Logger.cpp

As well as just adding the field descriptions, I wanted to include the enumeration information for the BT, BST and BU fields of the VER message. As there are sets of #defines and not actual enums, I made the following updates:

  • Add support to enum_parse.py to extract #define sets enclosed between @LoggerEnum and @LoggerEnumEnd comment tags.
  • Add @LoggerEnum and @LoggerEnumEnd comment tags around HAL_BOARD and HAL_BOARD_SUBTYPE defines in AP_HAL_Boards.h.
  • Add @LoggerEnum and @LoggerEnumEnd comment tags around APM_BUILD defines in AP_Vehicle_Type.h.

Tested by running parse.py for each vehicle type, and checking the output.
As example, this is the output for the VER message in the .rst output file used to create the wiki page (truncated here to save space):

+--------+----------+-------------------------------------------------------+
| TimeUS | μs       | Time since system startup                             |
+--------+----------+-------------------------------------------------------+
| BT     | enum     | Board type                                            |
|        |          | Values:                                               |
|        |          |                                                       |
|        |          | +-------------------+----+----------+                 |
|        |          | | HAL_BOARD_SITL    | 3  |          |                 |
|        |          | +-------------------+----+----------+                 |
|        |          | | HAL_BOARD_SMACCM  | 4  | unused   |                 |
|        |          | +-------------------+----+----------+                 |
|        |          | (etc)                                                 |
+--------+----------+-------------------------------------------------------+
| BST    | enum     | Board subtype                                         |
|        |          | Values:                                               |
|        |          |                                                       |
|        |          | +-----------------------------------------+------+--+ |
|        |          | | HAL_BOARD_SUBTYPE_NONE                  | -1   |  | |
|        |          | +-----------------------------------------+------+--+ |
|        |          | | HAL_BOARD_SUBTYPE_LINUX_NONE            | 1000 |  | |
|        |          | +-----------------------------------------+------+--+ |
|        |          | (etc)                                                 |

@peterbarker
Copy link
Contributor

Could we get a PR for just the message documentation without enumerations, please? That would give immediate value.

We're already a little over-enthusiastic about what we're parsing out of the C++ code; it took a lot of convincing to even allow parsing out of enum-classes!

Parsing out #define lists is, perhaps a little too much. We could instead look at changing these enumerations to be enum-class instead - that would be a DevCall topic given the extent of that change. This PR (after rebasing on top of a merge-to-master of just the message stuff) would be a good talking point for that topic.

@shancock884
Copy link
Contributor Author

Sure no problem - small steps :-).... New PR created #26311.

@shancock884 shancock884 marked this pull request as draft February 23, 2024 23:11
@shancock884 shancock884 changed the title AP_Logger: Add help for VER and FILE log messages AP_Logger: Add enum information to VER log message metadata Feb 23, 2024
@peterbarker
Copy link
Contributor

Merged the other one - rebase, please?

@shancock884 shancock884 force-pushed the ver-file-logmessage-metadata branch from b00a634 to bc91b6e Compare February 25, 2024 08:43
@shancock884
Copy link
Contributor Author

I hadn't thought I was opening up a controversial topic! Sorry for that :-).... I can appreciate that parsing the source code in this way may lead to cases where compiler-legitimate code changes end up breaking this parsing - and that is probably even more plausible with #defines.
I'm guessing that these particular cases have to be #defines as they are used by the pre-processor.
I was thinking that the idea of only parsing #defines between specific comment tags (@LoggerEnum/@LoggerEnumEnd) may decrease the risk.

More of a nice to have to no rush on having the debate, and if it is preferred to reject, no worries!

One idea instead could be to use add to the field description something like "See HAL_BOARD_* in AP_HAL_Boards.h", so that at least users have some clue on how to know what any given value means.

@shancock884 shancock884 marked this pull request as ready for review February 25, 2024 11:05
@peterbarker
Copy link
Contributor

@shancock884 needs a rebase.

Marking for DevCall to see if we're OK with this additional parsing.

@shancock884 shancock884 force-pushed the ver-file-logmessage-metadata branch 3 times, most recently from d05476d to 5fe8452 Compare November 8, 2024 18:01
@shancock884
Copy link
Contributor Author

needs a rebase.

Marking for DevCall to see if we're OK with this additional parsing.

Rebase done, and checked that output is as expected.

@shancock884 shancock884 force-pushed the ver-file-logmessage-metadata branch from 5fe8452 to fef05ce Compare November 9, 2024 17:34
@IamPete1
Copy link
Member

Maybe we have it somewhere, and not a blocker for this PR. But it would be great to document the various @ tricks for logger and param metadata.

@peterbarker peterbarker merged commit 67412c9 into ArduPilot:master Nov 12, 2024
99 checks passed
@shancock884 shancock884 deleted the ver-file-logmessage-metadata branch November 12, 2024 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants