Skip to content

sys/app_metadata: Add a way to print application metadata#10961

Merged
MichelRottleuthner merged 4 commits intoRIOT-OS:masterfrom
MrKevinWeiss:pr/addshellcommands
Mar 6, 2019
Merged

sys/app_metadata: Add a way to print application metadata#10961
MichelRottleuthner merged 4 commits intoRIOT-OS:masterfrom
MrKevinWeiss:pr/addshellcommands

Conversation

@MrKevinWeiss
Copy link
Copy Markdown
Contributor

@MrKevinWeiss MrKevinWeiss commented Feb 6, 2019

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/ or APP_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_metadata
Or just call make flash test -C tests/shell/

Issues/PRs references

None

@MrKevinWeiss MrKevinWeiss added Type: new feature The issue requests / The PR implemements a new feature for RIOT Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 6, 2019
@MrKevinWeiss MrKevinWeiss self-assigned this Feb 6, 2019
@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

Meta data on what?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

Meta data on what?

After looking at the code: how about renaming the module app_metadata to make this clearer.

endif

ifneq (,$(filter metadata,$(USEMODULE)))
# Overwrite the interface version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what interface is this referring to? API?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What RDM? There are 3 under review right now?

Copy link
Copy Markdown
Member

@miri64 miri64 Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RDM I am referring to is #10624

/**
* @brief Prints information about metadata to stdio.
*/
void metadata_get(void);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"get" implies this goes somewhere. maybe "print" would be more appropriate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that what I had originally but saw something with get... I will change it!

@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

@miri64 sure thing, I wasn't that happy with the naming anyways. app_metadata it will be.

@kaspar030
Copy link
Copy Markdown
Contributor

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".

@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

@kaspar030 Ok, is "about" fine with you @miri64

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

@kaspar030 Ok, is "about" fine with you @miri64

Don't care much about that :-)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

Don't care much about that :-)

I mean the name of the shell command. The module should still be named app_metadata or something like that.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

about as a module name would be too unspecific.

@kaspar030
Copy link
Copy Markdown
Contributor

about as a module name would be too unspecific.

that's why I suggest to just put the code into sys/shell/commands/sc_about.c. Not even a module needed.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

that's why I suggest to just put the code into sys/shell/commands/sc_about.c. Not even a module needed.

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).

@MichelRottleuthner
Copy link
Copy Markdown
Contributor

MichelRottleuthner commented Feb 6, 2019

Actually I would have done it like @kaspar030 wrote above, i.e. just adding a sc_about.c. But thinking about it, I agree that putting it to a separate module is more flexible.
Another thing: The dedicated "test" can probably be removed as it doesn't really add something. tests/shell should be enough, no?

@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

Also isn't the USEMODULE the way to select which shell commands are used (I tried to model this after the ps command)

@kaspar030
Copy link
Copy Markdown
Contributor

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.
Soon there'll be "test_print_result_value()", "test_print_success()", ... Surely we don't want "sys/result_value" as module.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

Also isn't the USEMODULE the way to select which shell commands are used (I tried to model this after the ps command)

Yepp, but in theory you could just define a pseudo-module for that (e.g. like I did to provide the pktbuf command -- which is still implemented in gnrc_pktbuf_static, but usually not exposed to the shell per default).

@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

@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!

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

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)

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?!??"

@MrKevinWeiss MrKevinWeiss added State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 6, 2019
@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

@miri64 Yup, bad name, got it. Any suggestions? The "about" command also seems reasonable. Maybe "app_info"?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

@miri64 Yup, bad name, got it. Any suggestions? The "about" command also seems reasonable. Maybe "app_info"?

app_metadata is fine with me. Just metadata was a little bit confusing to me.

@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

I am fine with that as well!

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 6, 2019

Also, please find a more specific name than INTERFACE_VERSION or interface. It's already hard enough for people to find out if others talk about network interfaces or APIs [edit: or whatever else exists in the world of interfaces], so calling a specific API just "the interface" is very confusing.

@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

Yup yup. Just need to think of what is specific enough!

@MrKevinWeiss MrKevinWeiss changed the title sys/metadata: Add a metadata command to let an application give metadata sys/app_metadata: Add a way to print application metadata Feb 7, 2019
@MrKevinWeiss MrKevinWeiss removed the State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. label Feb 7, 2019
@MrKevinWeiss MrKevinWeiss added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 12, 2019
This allows the application code to know what application it is running
@MrKevinWeiss MrKevinWeiss force-pushed the pr/addshellcommands branch from eede925 to 5f9ea3f Compare March 5, 2019 13:23
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
@MrKevinWeiss MrKevinWeiss force-pushed the pr/addshellcommands branch 2 times, most recently from a3a032a to e635799 Compare March 5, 2019 16:54
Copy link
Copy Markdown
Contributor

@MichelRottleuthner MichelRottleuthner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?.

endif

ifneq (,$(filter app_metadata,$(USEMODULE)))
# Overwrite the interface version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@MrKevinWeiss MrKevinWeiss force-pushed the pr/addshellcommands branch from e635799 to c36cf57 Compare March 6, 2019 12:09
@MrKevinWeiss
Copy link
Copy Markdown
Contributor Author

😗 Thanks for the review @MichelRottleuthner

@MichelRottleuthner MichelRottleuthner merged commit 3427dcd into RIOT-OS:master Mar 6, 2019
@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 7, 2019

@kaspar030 , @miri64 you agree?.

For reference: yepp, all comments were addressed :-)

@danpetry danpetry added this to the Release 2019.04 milestone Mar 11, 2019
@MrKevinWeiss MrKevinWeiss deleted the pr/addshellcommands branch March 17, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants