Skip to content

Commit

Permalink
Show git revisions for nuttx/, apps/ and the main repo
Browse files Browse the repository at this point in the history
Adds an SCPI (GET:VERsion?) and an CLI (rffe get version) command to
check what firmware version is running.
  • Loading branch information
augustofg committed Jan 10, 2020
1 parent b5088f9 commit a84ea29
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 4 deletions.
15 changes: 14 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

cmd="$1"

git_hash_tag() {
cd apps/
APPS_GIT_HASH=$(git describe --no-match --always --dirty --abbrev=40)
cd ../nuttx
NUTTX_GIT_HASH=$(git describe --no-match --always --dirty --abbrev=40)
cd ..
RFFE_GIT_HASH=$(git describe --no-match --always --dirty --abbrev=40)
RFFE_GIT_TAG=$(git describe --exact-match --tags)
echo -e "/* Auto-generated file */\n\n#define APPS_GIT_HASH \"${APPS_GIT_HASH}\"\n#define NUTTX_GIT_HASH \"${NUTTX_GIT_HASH}\"\n#define RFFE_GIT_HASH \"${RFFE_GIT_HASH}\"\n#define RFFE_GIT_TAG \"${RFFE_GIT_TAG}\"\n" > rffe-app/git_version.h
}

if [ -z "$JOBS" ]; then
JOBS=1
fi

if test "$cmd" = "configure"; then
git_hash_tag
cd apps/
rm -f external
ln -s ../rffe-app external
Expand All @@ -15,6 +27,7 @@ if test "$cmd" = "configure"; then
./tools/configure.sh ../rffe-board/rffe
cd ..
elif test "$cmd" = "build"; then
git_hash_tag
cd nuttx/
if [ ! -e .config ]; then
echo "Error: Build not configured yet."
Expand All @@ -27,7 +40,7 @@ elif test "$cmd" = "clean"; then
cd nuttx/
make distclean
cd ..
rm apps/external
rm -f apps/external rffe-app/git_version.h
elif test "$cmd" = "flash"; then
openocd -f scripts/openocd/lpc17-cmsis.cfg -c "program nuttx/nuttx.bin 0x10000; reset; shutdown"
fi
1 change: 1 addition & 0 deletions rffe-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/*.adb
/*.lib
/*.src
git_version.h
10 changes: 10 additions & 0 deletions rffe-app/rffe_console_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@

#include "netconfig.h"
#include "config_file.h"
#include "git_version.h"

static char* cfg_file = "/dev/feram0";

void rffe_console_print_version(void)
{
printf("---Version---\nrelease: %s\nrffe: %s\napps: %s\nnuttx: %s\n", RFFE_GIT_TAG, RFFE_GIT_HASH, APPS_GIT_HASH, NUTTX_GIT_HASH);
}

int rffe_console_cfg(int argc, char *argv[])
{
struct netifconfig conf;
Expand Down Expand Up @@ -127,6 +133,10 @@ int rffe_console_cfg(int argc, char *argv[])
config_get_attenuation("/dev/feram0", &att);
printf("%f dB\n", b16tof(att));
}
else if (strcmp(argv[2], "version") == 0)
{
rffe_console_print_version();
}

}
else if (strcmp(argv[1], "set") == 0)
Expand Down
1 change: 1 addition & 0 deletions rffe-app/rffe_console_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
#define RFFE_CONSOLE_CFG_H_

int rffe_console_cfg(int argc, char *argv[]);
void rffe_console_print_version(void);

#endif
5 changes: 5 additions & 0 deletions rffe-app/rffe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ int rffe_main(int argc, char *argv[])
return rffe_console_cfg(argc, argv);
}

/*
* Print git hashs for apps/ nuttx/ and the main repo
*/
rffe_console_print_version();

/*
* Restore previous RF attenuation level
*/
Expand Down
7 changes: 4 additions & 3 deletions rffe-app/scpi-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
#define __SCPI_DEF_H_

#include "scpi/scpi.h"
#include "git_version.h"

#define SCPI_INPUT_BUFFER_LENGTH 64
#define SCPI_ERROR_QUEUE_SIZE 8
#define SCPI_IDN1 "LNLS"
#define SCPI_IDN2 "RFFEV4"
#define SCPI_IDN1 "CNPEM LNLS"
#define SCPI_IDN2 "RFFE"
#define SCPI_IDN3 NULL
#define SCPI_IDN4 "01-02"
#define SCPI_IDN4 RFFE_GIT_TAG

size_t SCPI_Write(scpi_t * context, const char * data, size_t len);
int SCPI_Error(scpi_t * context, int_fast16_t err);
Expand Down
10 changes: 10 additions & 0 deletions rffe-app/scpi_rffe_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "scpi_rffe_cmd.h"
#include "scpi_interface.h"
#include "config_file.h"
#include "git_version.h"

static const char* cfg_file = "/dev/feram0";
static const char* dac_file = "/dev/dac0";
Expand Down Expand Up @@ -656,6 +657,15 @@ scpi_result_t rffe_get_dhcp_mode(scpi_t* context)
return SCPI_RES_OK;
}

scpi_result_t rffe_get_version(scpi_t* context)
{
SCPI_ResultCharacters(context, APPS_GIT_HASH, strlen(APPS_GIT_HASH));
SCPI_ResultCharacters(context, NUTTX_GIT_HASH, strlen(NUTTX_GIT_HASH));
SCPI_ResultCharacters(context, RFFE_GIT_HASH, strlen(RFFE_GIT_HASH));
SCPI_ResultCharacters(context, RFFE_GIT_TAG, strlen(RFFE_GIT_TAG));
return SCPI_RES_OK;
}

scpi_result_t rffe_reset(scpi_t* context)
{
boardctl(BOARDIOC_RESET, 0);
Expand Down
1 change: 1 addition & 0 deletions rffe-app/scpi_rffe_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ scpi_result_t rffe_set_netmask(scpi_t* context);
scpi_result_t rffe_get_netmask(scpi_t* context);
scpi_result_t rffe_set_dhcp_mode(scpi_t* context);
scpi_result_t rffe_get_dhcp_mode(scpi_t* context);
scpi_result_t rffe_get_version(scpi_t* context);
scpi_result_t rffe_reset(scpi_t* context);
#endif
1 change: 1 addition & 0 deletions rffe-app/scpi_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const scpi_command_t scpi_commands[] =
{.pattern = "GET:NETMask?", .callback = rffe_get_netmask,},
{.pattern = "SET:DHCPMode", .callback = rffe_set_dhcp_mode,},
{.pattern = "GET:DHCPMode?", .callback = rffe_get_dhcp_mode,},
{.pattern = "GET:VERsion?", .callback = rffe_get_version,},
{.pattern = "SYSTem:RESet", .callback = rffe_reset,},

SCPI_CMD_LIST_END
Expand Down

0 comments on commit a84ea29

Please sign in to comment.