feat: add version command

This commit is contained in:
TT 2019-08-18 08:19:17 +09:00
parent b823a8060d
commit 53d07e8c12
2 changed files with 16 additions and 2 deletions

View file

@ -53,6 +53,11 @@ endif
# Build global options
##############################################################################
ifeq ($(VERSION),)
#VERSION="unknown"
VERSION="$(shell git describe --tags)"
endif
##############################################################################
# Architecture or project specific options
#
@ -200,7 +205,7 @@ CPPWARN = -Wall -Wextra -Wundef
#
# List all user C define here, like -D_DEBUG=1
UDEFS = -DSHELL_CMD_TEST_ENABLED=FALSE -DSHELL_CMD_MEM_ENABLED=FALSE -DARM_MATH_CM0
UDEFS = -DSHELL_CMD_TEST_ENABLED=FALSE -DSHELL_CMD_MEM_ENABLED=FALSE -DARM_MATH_CM0 -DVERSION=\"$(VERSION)\"
# Define ASM defines here
UADEFS =

11
main.c
View file

@ -1663,14 +1663,23 @@ static void cmd_stat(BaseSequentialStream *chp, int argc, char *argv[])
}
#ifndef VERSION
#define VERSION "unknown"
#endif
static void cmd_version(BaseSequentialStream *chp, int argc, char *argv[])
{
(void)argc;
(void)argv;
chprintf(chp, VERSION "\r\n");
}
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(256)
static THD_WORKING_AREA(waThread2, SHELL_WA_SIZE);
static const ShellCommand commands[] =
{
{ "version", cmd_version },
{ "reset", cmd_reset },
{ "freq", cmd_freq },
{ "offset", cmd_offset },