Skip to content

Commit

Permalink
hwtest/main,adcs: Add paramter to syshk telemetry
Browse files Browse the repository at this point in the history
This commit adds new parameter to system HK telemetry.

  - FSW version
  - Last command strings

Signed-off-by: Takuya Sasaki <takuya.sasaki@spacecubics.com>
  • Loading branch information
sasataku committed Jul 18, 2024
1 parent 6819fae commit cde8f06
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/hwtest/adcs/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@
struct all_test_result {
uint32_t loop_count;
uint32_t err_cnt;
char version[32];
char last_cmd[32];
};
5 changes: 5 additions & 0 deletions tests/hwtest/adcs/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/hwtest/adcs/src/syshk_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
#include "imu_test.h"
#include "gnss_test.h"
#include "rw_test.h"
#include "version.h"

#include <zephyr/logging/log.h>
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];
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions tests/hwtest/main/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/hwtest/main/src/syshk_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@
#include "mtq.h"
#include "csp.h"
#include "syshk.h"
#include "version.h"

#include <zephyr/logging/log.h>
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)
Expand Down Expand Up @@ -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++;

Expand Down

0 comments on commit cde8f06

Please sign in to comment.