From cde8f06813c9bb499b4eb9121936da7e5e12cc50 Mon Sep 17 00:00:00 2001 From: Takuya Sasaki Date: Tue, 16 Jul 2024 10:29:46 +0900 Subject: [PATCH] hwtest/main,adcs: Add paramter to syshk telemetry This commit adds new parameter to system HK telemetry. - FSW version - Last command strings Signed-off-by: Takuya Sasaki --- tests/hwtest/adcs/src/common.h | 2 ++ tests/hwtest/adcs/src/main.c | 5 +++++ tests/hwtest/adcs/src/syshk_test.c | 5 +++++ tests/hwtest/main/src/main.c | 5 +++++ tests/hwtest/main/src/syshk_test.c | 8 ++++++++ 5 files changed, 25 insertions(+) diff --git a/tests/hwtest/adcs/src/common.h b/tests/hwtest/adcs/src/common.h index 17036432..58d8bb93 100644 --- a/tests/hwtest/adcs/src/common.h +++ b/tests/hwtest/adcs/src/common.h @@ -36,4 +36,6 @@ struct all_test_result { uint32_t loop_count; uint32_t err_cnt; + char version[32]; + char last_cmd[32]; }; diff --git a/tests/hwtest/adcs/src/main.c b/tests/hwtest/adcs/src/main.c index b8b1ae81..16e6b012 100644 --- a/tests/hwtest/adcs/src/main.c +++ b/tests/hwtest/adcs/src/main.c @@ -24,6 +24,8 @@ #define CMD_HANDLER_PRIO (0U) #define CMD_EXEC_EVENT (1U) +char last_cmd[32]; + K_THREAD_STACK_DEFINE(cmd_thread_stack, 2048); static struct k_thread cmd_thread; static struct k_event exec_event; @@ -89,6 +91,8 @@ static int start_cmd_thread(const struct shell *sh, size_t argc, char **argv) int ret = 0; k_tid_t cmd_tid; + strncpy(last_cmd, sh->ctx->temp_buff, MIN(sh->ctx->cmd_tmp_buff_len, sizeof(last_cmd) - 1)); + if (argc < 1) { shell_error(sh, "Invalid argument"); ret = -EINVAL; @@ -116,6 +120,7 @@ static int start_cmd_thread(const struct shell *sh, size_t argc, char **argv) static int stop_cmd(const struct shell *sh, size_t argc, char **argv) { + strncpy(last_cmd, sh->ctx->temp_buff, MIN(sh->ctx->cmd_tmp_buff_len, sizeof(last_cmd) - 1)); k_event_set(&loop_event, LOOP_STOP_EVENT); return 0; } diff --git a/tests/hwtest/adcs/src/syshk_test.c b/tests/hwtest/adcs/src/syshk_test.c index e483644f..76a5d44d 100644 --- a/tests/hwtest/adcs/src/syshk_test.c +++ b/tests/hwtest/adcs/src/syshk_test.c @@ -13,6 +13,7 @@ #include "imu_test.h" #include "gnss_test.h" #include "rw_test.h" +#include "version.h" #include LOG_MODULE_REGISTER(syshk_test); @@ -20,6 +21,7 @@ LOG_MODULE_REGISTER(syshk_test); static uint8_t syshk_head = 0; uint8_t syshk_tail = 0; extern struct k_event loop_event; +extern char last_cmd[]; struct rw_count_data rw_data_fifo[SYSHK_FIFO_NUM]; struct adcs_temp_test_result temp_ret_fifo[SYSHK_FIFO_NUM]; @@ -83,8 +85,11 @@ static int one_loop(enum rw_pos pos, uint32_t *err_cnt) gnss_hwmon_ret_fifo[syshk_head] = hwmon_ret; gnss_bestpos_ret_fifo[syshk_head] = bestpos_ret; + memset(&test_ret, 0, sizeof(test_ret)); test_ret.loop_count = loop_count; test_ret.err_cnt = *err_cnt; + strcpy(test_ret.version, ADCS_HWTEST_VERSION); + strcpy(test_ret.last_cmd, last_cmd); test_ret_fifo[syshk_head] = test_ret; syshk_tail = syshk_head; diff --git a/tests/hwtest/main/src/main.c b/tests/hwtest/main/src/main.c index 889e839c..4532e5de 100644 --- a/tests/hwtest/main/src/main.c +++ b/tests/hwtest/main/src/main.c @@ -29,6 +29,8 @@ LOG_MODULE_REGISTER(main); #define CMD_HANDLER_PRIO (0U) #define CMD_EXEC_EVENT (1U) +char last_cmd[32]; + K_THREAD_STACK_DEFINE(cmd_thread_stack, 2048); static struct k_thread cmd_thread; static struct k_event exec_event; @@ -98,6 +100,8 @@ static int start_cmd_thread(const struct shell *sh, size_t argc, char **argv) int ret = 0; k_tid_t cmd_tid; + strncpy(last_cmd, sh->ctx->temp_buff, MIN(sh->ctx->cmd_tmp_buff_len, sizeof(last_cmd) - 1)); + if (argc < 1) { shell_error(sh, "Invalid argument"); ret = -EINVAL; @@ -154,6 +158,7 @@ int main(void) static int stop_cmd(const struct shell *sh, size_t argc, char **argv) { + strncpy(last_cmd, sh->ctx->temp_buff, MIN(sh->ctx->cmd_tmp_buff_len, sizeof(last_cmd) - 1)); k_event_set(&loop_event, LOOP_STOP_EVENT); return 0; } diff --git a/tests/hwtest/main/src/syshk_test.c b/tests/hwtest/main/src/syshk_test.c index 173db742..4192bdef 100644 --- a/tests/hwtest/main/src/syshk_test.c +++ b/tests/hwtest/main/src/syshk_test.c @@ -17,16 +17,20 @@ #include "mtq.h" #include "csp.h" #include "syshk.h" +#include "version.h" #include LOG_MODULE_REGISTER(syshk_test); extern struct k_event loop_event; extern enum hwtest_mode test_mode; +extern char last_cmd[]; struct all_test_result { uint32_t loop_count; uint32_t err_cnt; + char version[32]; + char last_cmd[32]; }; #define CSP_GET_SYSHK_PORT (10U) @@ -195,8 +199,12 @@ static int one_loop(uint32_t *err_cnt) k_sleep(K_MSEC(100)); } + memset(&test_ret, 0, sizeof(test_ret)); test_ret.loop_count = loop_count; test_ret.err_cnt = *err_cnt; + strcpy(test_ret.version, MAIN_HWTEST_VERSION); + strcpy(test_ret.last_cmd, last_cmd); + send_syshk(ALL_TEST_RESULT, &test_ret, sizeof(test_ret)); loop_count++;