sys/app_metadata: Add app_metadata module
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 commit is contained in:
parent
0738084657
commit
fc80ae7724
@ -31,6 +31,13 @@ ifneq (,$(filter oneway_malloc,$(USEMODULE)))
|
|||||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/oneway-malloc/include
|
USEMODULE_INCLUDES += $(RIOTBASE)/sys/oneway-malloc/include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter app_metadata,$(USEMODULE)))
|
||||||
|
# Overwrite the interface version
|
||||||
|
ifdef APP_SHELL_FMT
|
||||||
|
CFLAGS += -DAPP_SHELL_FMT=\"$(APP_SHELL_FMT)\"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter vfs,$(USEMODULE)))
|
ifneq (,$(filter vfs,$(USEMODULE)))
|
||||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/posix/include
|
USEMODULE_INCLUDES += $(RIOTBASE)/sys/posix/include
|
||||||
endif
|
endif
|
||||||
|
|||||||
1
sys/app_metadata/Makefile
Normal file
1
sys/app_metadata/Makefile
Normal file
@ -0,0 +1 @@
|
|||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
31
sys/app_metadata/app_metadata.c
Normal file
31
sys/app_metadata/app_metadata.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
Copyright (C) 2019, HAW Hamburg.
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*
|
||||||
|
* @ingroup sys_app_metadata
|
||||||
|
* @{
|
||||||
|
* @file
|
||||||
|
* @brief Prints application metadata such as BOARD, CPU, OS_VERSION.
|
||||||
|
* @author Kevin Weiss <kevin.weiss@haw-hamburg.de>
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void app_metadata_print_json(void)
|
||||||
|
{
|
||||||
|
puts("{\"cmd\": \"app_metadata_print_json()\"}");
|
||||||
|
printf("{\"data\": {\"APP_NAME\": \"%s\"}}\n", RIOT_APPLICATION);
|
||||||
|
printf("{\"data\": {\"BOARD\": \"%s\"}}\n", RIOT_BOARD);
|
||||||
|
printf("{\"data\": {\"CPU\": \"%s\"}}\n", RIOT_CPU);
|
||||||
|
#ifdef APP_SHELL_FMT
|
||||||
|
printf("{\"data\": {\"APP_SHELL_FMT\": \"%s\"}}\n", APP_SHELL_FMT);
|
||||||
|
#endif
|
||||||
|
printf("{\"data\": {\"MCU\": \"%s\"}}\n", RIOT_MCU);
|
||||||
|
printf("{\"data\": {\"OS_VERSION\": \"%s\"}}\n", RIOT_VERSION);
|
||||||
|
|
||||||
|
printf("{\"result\": \"SUCCESS\"}\n");
|
||||||
|
}
|
||||||
55
sys/include/app_metadata.h
Normal file
55
sys/include/app_metadata.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 HAW Hamburg
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup sys_app_metadata app_metadata
|
||||||
|
* @ingroup sys
|
||||||
|
* @brief Module for the application metadata
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @author Kevin Weiss <kevin.weiss@haw-hamburg.de>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APP_METADATA_H
|
||||||
|
#define APP_METADATA_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DOXYGEN
|
||||||
|
/**
|
||||||
|
* @brief Application Shell Format is an optional application metadata
|
||||||
|
* parameter intended to help coordinate any specific formats that
|
||||||
|
* are being used.
|
||||||
|
*
|
||||||
|
* @details An example is if the application is following a specific format,
|
||||||
|
* say semantics defined in a RDM or schema, that could be specified
|
||||||
|
* by adding APP_SHELL_FMT="RDM001_v1", that would inform anything
|
||||||
|
* using the shell that the formatting should follow what is dictated.
|
||||||
|
* This define is only for documentation, to use the APP_SHELL_FMT
|
||||||
|
* add it to the application makefile with APP_SHELL_FMT=<your value>
|
||||||
|
* or when calling make such as `APP_SHELL_FMT=<your value> make flash`
|
||||||
|
*/
|
||||||
|
#define APP_SHELL_FMT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints the application metadata in json.
|
||||||
|
*
|
||||||
|
* @details Examples of application metadata are BOARD, OS_VERSION, APP_NAME...
|
||||||
|
*/
|
||||||
|
void app_metadata_print_json(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* APP_METADATA_H */
|
||||||
|
/** @} */
|
||||||
Loading…
x
Reference in New Issue
Block a user