sys/app_metadata: Add a way to print application metadata#10961
sys/app_metadata: Add a way to print application metadata#10961MichelRottleuthner merged 4 commits intoRIOT-OS:masterfrom
Conversation
|
Meta data on what? |
After looking at the code: how about renaming the module |
sys/Makefile.include
Outdated
| endif | ||
|
|
||
| ifneq (,$(filter metadata,$(USEMODULE))) | ||
| # Overwrite the interface version |
There was a problem hiding this comment.
what interface is this referring to? API?
There was a problem hiding this comment.
None right now, the plan it to have the RDM merged then we can specify it adheres to the rules. Similar to something like it adheres to a JSON schema draft 7.
There was a problem hiding this comment.
What RDM? There are 3 under review right now?
There was a problem hiding this comment.
None right now, the plan it to have the RDM merged then we can specify it adheres to the rules. Similar to something like it adheres to a JSON schema draft 7.
Though I like the simplicity of this implementation, I wonder
a) Why pin-point to JSON, when we also support e.g. CBOR?
b) Why use printf and not fmt if and only if we want to stick to JSON.
sys/include/metadata.h
Outdated
| /** | ||
| * @brief Prints information about metadata to stdio. | ||
| */ | ||
| void metadata_get(void); |
There was a problem hiding this comment.
"get" implies this goes somewhere. maybe "print" would be more appropriate?
There was a problem hiding this comment.
Yup, that what I had originally but saw something with get... I will change it!
|
@miri64 sure thing, I wasn't that happy with the naming anyways. app_metadata it will be. |
|
I must ask for the use of this. Having the "metadata" printed is quite useless unless for the shell. How about containing this in sys/shell/commands? I'd name it "about". Everyone seeing a prompt will type "help", and everyone will try "about". |
|
@kaspar030 Ok, is "about" fine with you @miri64 |
Don't care much about that :-) |
I mean the name of the shell command. The module should still be named |
|
|
that's why I suggest to just put the code into |
I prefer to always have a corresponding module to a shell command. This way we have a way to later integrate it into other configuration/information mechanisms (e.g. via CoAP). |
|
Actually I would have done it like @kaspar030 wrote above, i.e. just adding a |
|
Also isn't the USEMODULE the way to select which shell commands are used (I tried to model this after the ps command) |
|
I just realized that the module outputs in json format... Look, my first reaction was as @miri64's: "what metadata?" I know how this works. You're happily solving some problem (in this case, maybe you've been working on the unified testing RDM) and need some functionality. It has something to do with metadata, and 15min later there's a PR for "sys/metadata". This unfortunately blanks out that there's a plethora of different understandings for metadata. The PR description is not very helpful (it could mention json format, and that it is supposed to be used by the tests, ...). So as is, there's "metadata" in "sys/", but noone gets what the folder is there for. I suspect there are gonna be more related functions. So how about directly creating a "sys/test" module? IMO, it is the right place for a function to print test metadata. It could be the in-tree code support for the coming RDM. |
Yepp, but in theory you could just define a pseudo-module for that (e.g. like I did to provide the |
|
@kaspar030 Heh, correct you got me 😁 and I will improve the description of the PR. I added this because I thought it would be useful regardless to have this from an application perspective. Yes the formatting is json but it is also somewhat human readable which has been the standard for most of this. @MichelRottleuthner the test was more to show how to use it. It can also be used just for testing and dropped before merge (I think @cladmi is doing something like that). As you wish. In terms of what is metadata, you see the information that I am wanting. Just a mechanism for the application to identify itself, I am really not tied to the name and appreciate anyone input (or simply say do it like this) I can also move it to sys/tests but I am more thinking we should have some consensus. For me it seems like there is more than one way to skin a cat but maybe we can hit two birds with one stone... :) @miri64 Thanks for the pseudo-module hint! |
Yes, we can see that after looking at the code. But the name of the module, the description of the shell command, and the descriptive text of the PR should also make that clear, so people don't assume "Oh I need metadata for feature X, and there is a metadata module. It is probably supposed to go there?!??" |
|
@miri64 Yup, bad name, got it. Any suggestions? The "about" command also seems reasonable. Maybe "app_info"? |
|
|
I am fine with that as well! |
|
Also, please find a more specific name than |
|
Yup yup. Just need to think of what is specific enough! |
This allows the application code to know what application it is running
eede925 to
5f9ea3f
Compare
This allows a access to application metadata such as BOARD, CPU, etc. It prints the contents to the stdio in a standard json form
This make an easily accessable shell command to print app_metadata
a3a032a to
e635799
Compare
MichelRottleuthner
left a comment
There was a problem hiding this comment.
Reading over the comments, requests and changes again I think besides the one minor thing stated below everything is resolved by now and its ready to be merged - @kaspar030 , @miri64 you agree?.
sys/Makefile.include
Outdated
| endif | ||
|
|
||
| ifneq (,$(filter app_metadata,$(USEMODULE))) | ||
| # Overwrite the interface version |
There was a problem hiding this comment.
The comment # Overwrite the interface version is still using the very unspecific wording interface version. How about something more explicit about the fact that this modifies the reported version of the standardized shell output format? (and to explain the context maybe a reference to the RDM?)
Adds app_metadata to the shell test This both serves as a simple test to see if the module is available and doesn't crash as well as an example
e635799 to
c36cf57
Compare
|
😗 Thanks for the review @MichelRottleuthner |
For reference: yepp, all comments were addressed :-) |
Contribution description
This PR adds a command to print a number of useful application parameters such as BOARD, MCU, OS_VERSION, APP_NAME, etc.
The print function prints in json as it is human readable (enough) and machine readable/easy to format.
It also adds an optional parameter APP_SHELL_FMT (application shell format) intended to help coordinate any specific formatting that the application is following. It can be specified in the makefile or in commandline but if not specified it doesn't print anything.
Testing procedure
run
BOARD=<???> make flash term -C tests/shell/orAPP_SHELL_FMT="test" BOARD=<???> make flash term -C tests/shell/or add APP_SHELL_FMT="test" in the makefile.Then in the shell check the response when calling
app_metadataOr just call
make flash test -C tests/shell/Issues/PRs references
None