From 0b2caedc582c86338f04f569156f4049b0957b66 Mon Sep 17 00:00:00 2001 From: Jonas Danielsson Date: Wed, 1 Sep 2021 12:19:52 +0200 Subject: [PATCH] system: Add request and print of NRF fw version This adds use of a new SYSLINK message: SYSLINK_SYS_NRF_VERSION The NRF will reply with a string, for example: Example: 2021.06 +1* Which mean 1 commit from the 2021.06 tag and the * marks it as "locally modified". --- src/hal/interface/syslink.h | 3 +++ src/hal/src/syslink.c | 4 ++++ src/modules/interface/system.h | 2 ++ src/modules/src/system.c | 27 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/src/hal/interface/syslink.h b/src/hal/interface/syslink.h index ca4408bc06..85e0ad714c 100644 --- a/src/hal/interface/syslink.h +++ b/src/hal/interface/syslink.h @@ -64,6 +64,9 @@ #define SYSLINK_OW_READ 0x22 #define SYSLINK_OW_WRITE 0x23 +#define SYSLINK_SYS_GROUP 0x30 +#define SYSLINK_SYS_NRF_VERSION 0x30 + typedef struct _SyslinkPacket { uint8_t type; diff --git a/src/hal/src/syslink.c b/src/hal/src/syslink.c index 1bd4926081..9cbf663b33 100644 --- a/src/hal/src/syslink.c +++ b/src/hal/src/syslink.c @@ -43,6 +43,7 @@ #include "pm.h" #include "ow.h" #include "static_mem.h" +#include "system.h" #ifdef UART2_LINK_COMM #include "uart2.h" @@ -102,6 +103,9 @@ static void syslinkRouteIncommingPacket(SyslinkPacket *slp) case SYSLINK_OW_GROUP: owSyslinkRecieve(slp); break; + case SYSLINK_SYS_GROUP: + systemSyslinkReceive(slp); + break; default: DEBUG_PRINT("Unknown packet:%X.\n", slp->type); break; diff --git a/src/modules/interface/system.h b/src/modules/interface/system.h index 98335c09e6..8fd3cc92c2 100644 --- a/src/modules/interface/system.h +++ b/src/modules/interface/system.h @@ -42,5 +42,7 @@ void systemSetArmed(bool val); bool systemIsArmed(); void systemRequestShutdown(); +void systemRequestNRFVersion(); +void systemSyslinkReceive(); #endif //__SYSTEM_H__ diff --git a/src/modules/src/system.c b/src/modules/src/system.c index edae5162c0..c6de303900 100644 --- a/src/modules/src/system.c +++ b/src/modules/src/system.c @@ -83,6 +83,8 @@ static bool armed = ARM_INIT; static bool forceArm; static bool isInit; +static char nrf_version[16]; + STATIC_MEM_TASK_ALLOC(systemTask, SYSTEM_TASK_STACKSIZE); /* System wide synchronisation */ @@ -200,6 +202,8 @@ void systemTask(void *arg) proximityInit(); #endif + systemRequestNRFVersion(); + //Test the modules DEBUG_PRINT("About to run tests in system.c.\n"); if (systemTest() == false) { @@ -339,6 +343,29 @@ void systemRequestShutdown() syslinkSendPacket(&slp); } +void systemRequestNRFVersion() +{ + SyslinkPacket slp; + + slp.type = SYSLINK_SYS_NRF_VERSION; + slp.length = 0; + syslinkSendPacket(&slp); +} + +void systemSyslinkReceive(SyslinkPacket *slp) +{ + if (slp->type == SYSLINK_SYS_NRF_VERSION) + { + size_t len = slp->length - 2; + + if (sizeof(nrf_version) - 1 <= len) { + len = sizeof(nrf_version) - 1; + } + memcpy(&nrf_version, &slp->data[0], len); + DEBUG_PRINT("NRF51 version: %s\n", nrf_version); + } +} + void vApplicationIdleHook( void ) { static uint32_t tickOfLatestWatchdogReset = M2T(0);