From db0864ca2c3590b8d3bdb3a47409859ce5235fde Mon Sep 17 00:00:00 2001 From: Takuya Sasaki Date: Sun, 28 Jan 2024 19:14:05 +0900 Subject: [PATCH] hwtest/main: Add DSTRX-3 test This commit adds the DSTRX-3 test. Signed-off-by: Takuya Sasaki --- tests/hwtest/main/CMakeLists.txt | 1 + tests/hwtest/main/src/dstrx3_test.c | 45 +++++++++++++++++++++++++++++ tests/hwtest/main/src/dstrx3_test.h | 11 +++++++ tests/hwtest/main/src/loop_test.c | 9 ++++++ tests/hwtest/main/src/main.c | 4 +++ 5 files changed, 70 insertions(+) create mode 100644 tests/hwtest/main/src/dstrx3_test.c create mode 100644 tests/hwtest/main/src/dstrx3_test.h diff --git a/tests/hwtest/main/CMakeLists.txt b/tests/hwtest/main/CMakeLists.txt index 7dd61b24..3b94ddae 100644 --- a/tests/hwtest/main/CMakeLists.txt +++ b/tests/hwtest/main/CMakeLists.txt @@ -29,5 +29,6 @@ target_sources(app PRIVATE src/sunsens.c) target_sources(app PRIVATE src/sunsens_test.c) target_sources(app PRIVATE src/mtq.c) target_sources(app PRIVATE src/mtq_test.c) +target_sources(app PRIVATE src/dstrx3_test.c) target_sources(app PRIVATE src/main_init.c) target_sources(app PRIVATE src/loop_test.c) diff --git a/tests/hwtest/main/src/dstrx3_test.c b/tests/hwtest/main/src/dstrx3_test.c new file mode 100644 index 00000000..ce9bbefd --- /dev/null +++ b/tests/hwtest/main/src/dstrx3_test.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Space Cubics, LLC. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "sc_dstrx3.h" + +#include +LOG_MODULE_REGISTER(dstrx3_test); + +int dstrx3_test(uint32_t *err_cnt) +{ + int ret; + const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(dstrx)); + struct sc_dstrx3_hk hk; + + ret = sc_dstrx3_get_hk_telemetry(dev, &hk); + if (ret < 0) { + LOG_ERR("DSTRX-3 HK: Failed"); + (*err_cnt)++; + goto end; + } + + LOG_INF("DSTRX-3 HK FREE_COUNTER : %d", hk.free_count); + LOG_INF("DSTRX-3 HK WDT_COUNTER : %d", hk.wdt_count); + LOG_INF("DSTRX-3 HK RSSI : %d", -(hk.rssi + 16)); + LOG_INF("DSTRX-3 HK RCV_FREQ : %.4f [Hz] (raw: %d)", + (2105.350 + (hk.rcv_freq * 100)), hk.rcv_freq); + LOG_INF("DSTRX-3 HK TEMPERATURE : %d [deg]", hk.temperature); + LOG_INF("DSTRX-3 HK VOLTAGE : %.04f [v] (raw: %d)", + (float)((hk.voltage / 256) * 2.5), hk.voltage); + LOG_INF("DSTRX-3 HK TX_PWR : %.04f [dBm] (raw: %d)", + ((0.2473 * hk.tx_power) + 0.99), hk.tx_power); + LOG_INF("DSTRX-3 HK CARRIER_LOCK : %d", hk.carrier_lock); + LOG_INF("DSTRX-3 HK SUB_CARRIER_LOCK : %d", hk.sub_carrier_lock); + LOG_INF("DSTRX-3 HK TX_PWR_SET : %d", hk.tx_power_set); + LOG_INF("DSTRX-3 HK BIT_RATE_SET : %d", hk.bit_rate_set); + LOG_INF("DSTRX-3 HK PROG_NO : %d", hk.program_no); + LOG_INF("DSTRX-3 HK CHK_SUM : %d", hk.checksum); + +end: + return ret; +} diff --git a/tests/hwtest/main/src/dstrx3_test.h b/tests/hwtest/main/src/dstrx3_test.h new file mode 100644 index 00000000..abea518c --- /dev/null +++ b/tests/hwtest/main/src/dstrx3_test.h @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 Space Cubics, LLC.↲ + *↲ + * SPDX-License-Identifier: Apache-2.0↲ + */ + +#pragma once + +#include + +int dstrx3_test(uint32_t *err_cnt); diff --git a/tests/hwtest/main/src/loop_test.c b/tests/hwtest/main/src/loop_test.c index af715091..dd3ce436 100644 --- a/tests/hwtest/main/src/loop_test.c +++ b/tests/hwtest/main/src/loop_test.c @@ -12,6 +12,7 @@ #include "csp_test.h" #include "sunsens_test.h" #include "mgnm_test.h" +#include "dstrx3_test.h" #include "mtq.h" #include @@ -78,6 +79,14 @@ static int one_loop(uint32_t *err_cnt) k_sleep(K_MSEC(100)); + LOG_INF("===[DSTRX-3 Test Start (total err: %d)]===", *err_cnt); + ret = dstrx3_test(err_cnt); + if (ret < 0) { + all_ret = -1; + } + + k_sleep(K_MSEC(100)); + return all_ret; } diff --git a/tests/hwtest/main/src/main.c b/tests/hwtest/main/src/main.c index 53ff1d0e..a7cc170f 100644 --- a/tests/hwtest/main/src/main.c +++ b/tests/hwtest/main/src/main.c @@ -15,6 +15,7 @@ #include "csp_test.h" #include "sunsens_test.h" #include "mtq_test.h" +#include "dstrx3_test.h" #include "main_init.h" #include "loop_test.h" @@ -56,6 +57,8 @@ static void cmd_handler(void * p1, void * p2, void * p3) ret = sunsens_test(&err_cnt); } else if (strcmp(cmd, "mtq") == 0) { ret = mtq_test(&err_cnt); + } else if (strcmp(cmd, "dstrx3") == 0) { + ret = dstrx3_test(&err_cnt); } else if (strcmp(cmd, "loop") == 0) { ret = loop_test(atoi(arg), &err_cnt); k_event_clear(&loop_event, LOOP_STOP_EVENT); @@ -133,6 +136,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_hwtest, SHELL_CMD(mtq, NULL, "Magnetorquer test command", start_cmd_thread), SHELL_CMD(csp, NULL, "CSP test command", start_cmd_thread), SHELL_CMD(sun, NULL, "Sun Sensor test command", start_cmd_thread), + SHELL_CMD(dstrx3, NULL, "DSTRX-3 test command", start_cmd_thread), SHELL_CMD(loop, NULL, "Loop test command", start_cmd_thread), SHELL_SUBCMD_SET_END );