Skip to content

Commit

Permalink
hwtest/main: Add DSTRX-3 test
Browse files Browse the repository at this point in the history
This commit adds the DSTRX-3 test.

Signed-off-by: Takuya Sasaki <takuya.sasaki@spacecubics.com>
  • Loading branch information
sasataku committed Jan 29, 2024
1 parent 06aa2d3 commit db0864c
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/hwtest/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
45 changes: 45 additions & 0 deletions tests/hwtest/main/src/dstrx3_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 Space Cubics, LLC.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include "sc_dstrx3.h"

#include <zephyr/logging/log.h>
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;
}
11 changes: 11 additions & 0 deletions tests/hwtest/main/src/dstrx3_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 Space Cubics, LLC.↲
*↲
* SPDX-License-Identifier: Apache-2.0↲
*/

#pragma once

#include <stdint.h>

int dstrx3_test(uint32_t *err_cnt);
9 changes: 9 additions & 0 deletions tests/hwtest/main/src/loop_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "csp_test.h"
#include "sunsens_test.h"
#include "mgnm_test.h"
#include "dstrx3_test.h"
#include "mtq.h"

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

Expand Down
4 changes: 4 additions & 0 deletions tests/hwtest/main/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit db0864c

Please sign in to comment.