From 18d93e3e6f8753872e16f533ab3a630dabb5e6ba Mon Sep 17 00:00:00 2001 From: Caio Date: Mon, 5 May 2025 23:58:16 -0400 Subject: [PATCH 01/23] building mocks --- Core/Src/pedals.c | 2 +- {Test/unity/tests => Tests/Inc}/cerberus_test.h | 0 {Test/unity/tests => Tests/Src}/can_handler_test.c | 0 .../unity/tests/cerberus_test.c => Tests/Src/test_main.c | 9 ++++++++- 4 files changed, 9 insertions(+), 2 deletions(-) rename {Test/unity/tests => Tests/Inc}/cerberus_test.h (100%) rename {Test/unity/tests => Tests/Src}/can_handler_test.c (100%) rename Test/unity/tests/cerberus_test.c => Tests/Src/test_main.c (53%) diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index bb82c9b9..d393653d 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -64,7 +64,7 @@ bool get_brake_state() * @param raw_adc * @return float */ -static float adc_to_volts(uint32_t raw_adc) +float adc_to_volts(uint32_t raw_adc) { float v3_volts = raw_adc * MAX_VOLTS / MAX_ADC_VAL_12b; // undo 2k + 3k voltage divider on APPS lines diff --git a/Test/unity/tests/cerberus_test.h b/Tests/Inc/cerberus_test.h similarity index 100% rename from Test/unity/tests/cerberus_test.h rename to Tests/Inc/cerberus_test.h diff --git a/Test/unity/tests/can_handler_test.c b/Tests/Src/can_handler_test.c similarity index 100% rename from Test/unity/tests/can_handler_test.c rename to Tests/Src/can_handler_test.c diff --git a/Test/unity/tests/cerberus_test.c b/Tests/Src/test_main.c similarity index 53% rename from Test/unity/tests/cerberus_test.c rename to Tests/Src/test_main.c index 1c58a5be..96430719 100644 --- a/Test/unity/tests/cerberus_test.c +++ b/Tests/Src/test_main.c @@ -1,5 +1,6 @@ #include "unity.h" #include "cerberus_test.h" +#include "pedals.h" void setUp(void) { // set stuff up here @@ -9,8 +10,14 @@ void tearDown(void) { // clean stuff up here } +// A simple random test +void test_random(void) { + TEST_ASSERT_EQUAL_INT(15, (int)adc_to_volts(1802)); +} + + int main(void) { UNITY_BEGIN(); - RUN_TEST(test_can_handler); + RUN_TEST(test_random); return UNITY_END(); } \ No newline at end of file From a218ca88e8bed432c81d69be98a0fb4fd08a01b6 Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 7 May 2025 21:31:11 -0400 Subject: [PATCH 02/23] running mocks --- Core/Inc/bms.h | 2 +- Core/Inc/can_handler.h | 4 ++-- Core/Inc/dti.h | 2 +- Core/Inc/mpu.h | 4 ++-- Core/Inc/pdu.h | 4 ++-- Drivers/Embedded-Base | 2 +- Tests/Inc/test_main.h | 15 +++++++++++++++ Tests/Src/test_main.c | 2 +- 8 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 Tests/Inc/test_main.h diff --git a/Core/Inc/bms.h b/Core/Inc/bms.h index 80598c40..d9216a40 100644 --- a/Core/Inc/bms.h +++ b/Core/Inc/bms.h @@ -1,7 +1,7 @@ #ifndef BMS_H #define BMS_H -#include "cmsis_os.h" +#include "cmsis_os_test.h" #include "can.h" #define BMS_CANID_CELL_TEMPS 0x84 /* BMS CELL TEMPERATURES */ diff --git a/Core/Inc/can_handler.h b/Core/Inc/can_handler.h index fb075bc1..babe9ba7 100644 --- a/Core/Inc/can_handler.h +++ b/Core/Inc/can_handler.h @@ -2,11 +2,11 @@ #define CAN_HANDLER_H #include "can.h" -#include "cmsis_os.h" +#include "cmsis_os_test.h" #include "control.h" #include "dti.h" #include "bms.h" -#include "stm32f4xx_hal.h" +#include "stm32xx_hal.h" /** * @brief Callback to be called when a message is received on CAN line 1. diff --git a/Core/Inc/dti.h b/Core/Inc/dti.h index c0504729..101599af 100644 --- a/Core/Inc/dti.h +++ b/Core/Inc/dti.h @@ -13,7 +13,7 @@ #define DTI_H #include "can.h" -#include "cmsis_os.h" +#include "cmsis_os_test.h" /* Message IDs from DTI CAN Datasheet */ #define DTI_CANID_ERPM 0x416 /* ERPM, Duty, Input Voltage */ diff --git a/Core/Inc/mpu.h b/Core/Inc/mpu.h index 9e5baf82..577f32cf 100644 --- a/Core/Inc/mpu.h +++ b/Core/Inc/mpu.h @@ -3,8 +3,8 @@ #include -#include "cmsis_os.h" -#include "stm32f4xx_hal.h" +#include "cmsis_os_test.h" +#include "stm32xx_hal.h" typedef struct { I2C_HandleTypeDef *hi2c; diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index 60070b91..d9442705 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -2,14 +2,14 @@ #define PDU_H #include -#include "cmsis_os.h" +#include "cmsis_os_test.h" #include "tca9539.h" #include "INA226.h" #include #include #include "bitstream.h" #include "c_utils.h" -#include "stm32f4xx_hal.h" +#include "stm32xx_hal.h" typedef struct { I2C_HandleTypeDef *hi2c; diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index d568fc32..30a84d97 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit d568fc32e92a1e3a0eaec02714eb2132e53a31d5 +Subproject commit 30a84d9758a91cde7cc0eaafe1dc8eba54742489 diff --git a/Tests/Inc/test_main.h b/Tests/Inc/test_main.h new file mode 100644 index 00000000..b8921f9f --- /dev/null +++ b/Tests/Inc/test_main.h @@ -0,0 +1,15 @@ +#ifndef CERBERUS_TEST_H +#define CERBERUS_TEST_H + +/* + * ************** NOTE ************** + * These test files are specifically + * for unit tests, developers can + * make sure that specific functions + * and APIs meet requirements set out. + * This should NOT be used for actually + * simulating drivers and hardware, + * that is what we are using Renode for + */ + +#endif // CERBERUS_TEST_H \ No newline at end of file diff --git a/Tests/Src/test_main.c b/Tests/Src/test_main.c index 96430719..e712f95e 100644 --- a/Tests/Src/test_main.c +++ b/Tests/Src/test_main.c @@ -12,7 +12,7 @@ void tearDown(void) { // A simple random test void test_random(void) { - TEST_ASSERT_EQUAL_INT(15, (int)adc_to_volts(1802)); + TEST_ASSERT_EQUAL_INT(15, 2); } From b76b4edd6082422e997aeecbf9f71b1f2e50f7ff Mon Sep 17 00:00:00 2001 From: Caio Date: Mon, 19 May 2025 21:13:28 -0400 Subject: [PATCH 03/23] trying to compile stuff --- Core/Inc/fault.h | 3 ++- Core/Inc/main.h | 2 +- Core/Inc/monitor.h | 2 +- Core/Src/cerb_tasks.c | 0 Tests/Inc/test_source.h | 18 ++++++++++++++++++ Tests/Src/test_source.c | 22 ++++++++++++++++++++++ 6 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 Core/Src/cerb_tasks.c create mode 100644 Tests/Inc/test_source.h create mode 100644 Tests/Src/test_source.c diff --git a/Core/Inc/fault.h b/Core/Inc/fault.h index 87a9671d..3d87f178 100644 --- a/Core/Inc/fault.h +++ b/Core/Inc/fault.h @@ -1,8 +1,9 @@ #ifndef CERBERUS_FAULT_H #define CERBERUS_FAULT_H -#include "cmsis_os.h" +#include "cmsis_os_test.h" #include +#include "stm32xx_hal.h" typedef enum { /* START CRIT FAULTS HERE */ diff --git a/Core/Inc/main.h b/Core/Inc/main.h index e2ed20a1..7e6dcd53 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -27,7 +27,7 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" +#include "stm32xx_hal.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ diff --git a/Core/Inc/monitor.h b/Core/Inc/monitor.h index 8a27d9ae..815d79e7 100644 --- a/Core/Inc/monitor.h +++ b/Core/Inc/monitor.h @@ -3,7 +3,7 @@ #include -#include "cmsis_os.h" +#include "cmsis_os_test.h" #include "mpu.h" #include "pdu.h" diff --git a/Core/Src/cerb_tasks.c b/Core/Src/cerb_tasks.c new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Inc/test_source.h b/Tests/Inc/test_source.h new file mode 100644 index 00000000..9a699432 --- /dev/null +++ b/Tests/Inc/test_source.h @@ -0,0 +1,18 @@ +#ifndef CERBERUS_TEST_H +#define CERBERUS_TEST_H + +/* + * ************** NOTE ************** + * These test files are specifically + * for unit tests, developers can + * make sure that specific functions + * and APIs meet requirements set out. + * This should NOT be used for actually + * simulating drivers and hardware, + * that is what we are using Renode for + */ + + void setUp(void); + void tearDown(void); + +#endif // CERBERUS_TEST_H \ No newline at end of file diff --git a/Tests/Src/test_source.c b/Tests/Src/test_source.c new file mode 100644 index 00000000..802bbfe1 --- /dev/null +++ b/Tests/Src/test_source.c @@ -0,0 +1,22 @@ +#include "unity.h" +#include "cerberus_test.h" +#include "pedals.h" + +void setUp(void) { + // set stuff up here +} + +void tearDown(void) { + // clean stuff up here +} + +// A simple random test +void test_random(void) { + TEST_ASSERT_EQUAL_INT(15, 2); +} + +int main(void) { + UNITY_BEGIN(); + RUN_TEST(test_random); + return UNITY_END(); +} \ No newline at end of file From 630747ac8878fbffad9d30c055b5df7e4798a5fa Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 21 May 2025 13:10:05 -0400 Subject: [PATCH 04/23] first test working --- Core/Inc/pedals.h | 7 +++++++ Core/Src/pedals.c | 4 ++-- Tests/Src/test_source.c | 14 ++++++++++++-- Tests/mocked_includes.txt | 8 ++++++++ Tests/test_sources.txt | 1 + 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 Tests/mocked_includes.txt create mode 100644 Tests/test_sources.txt diff --git a/Core/Inc/pedals.h b/Core/Inc/pedals.h index b84f5581..2549553f 100644 --- a/Core/Inc/pedals.h +++ b/Core/Inc/pedals.h @@ -107,4 +107,11 @@ void toggle_launch_control(); */ bool get_launch_control(); +/** + * @brief determines if APPS should fault based on pedal readings + */ +bool calc_pedal_faults(float accel1, float accel2, float accel1_norm, + float accel2_norm); + + #endif diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index d393653d..8d0b1f06 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -141,9 +141,9 @@ void set_torque_limit(float percentage) } } -float get_torque_limit_percentage() +int get_torque_limit_percentage() { - return torque_limit_percentage; + return 1; } uint16_t get_regen_limit() diff --git a/Tests/Src/test_source.c b/Tests/Src/test_source.c index 802bbfe1..bbcba3ca 100644 --- a/Tests/Src/test_source.c +++ b/Tests/Src/test_source.c @@ -1,7 +1,15 @@ #include "unity.h" -#include "cerberus_test.h" +#include "mock_stub_functions.h" +#include "mock_debounce.h" +#include "mock_c_utils.h" +#include "mock_pdu.h" +#include "mock_state_machine.h" +#include "mock_mpu.h" +#include "mock_can_handler.h" #include "pedals.h" +#include + void setUp(void) { // set stuff up here } @@ -12,7 +20,9 @@ void tearDown(void) { // A simple random test void test_random(void) { - TEST_ASSERT_EQUAL_INT(15, 2); + debounce_Ignore(); + debounce_Ignore(); + TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), false); } int main(void) { diff --git a/Tests/mocked_includes.txt b/Tests/mocked_includes.txt new file mode 100644 index 00000000..a2897599 --- /dev/null +++ b/Tests/mocked_includes.txt @@ -0,0 +1,8 @@ +/home/app/Core/Inc/dti.h +/home/app/Drivers/Embedded-Base/middleware/include/debounce.h +/home/app/Drivers/Embedded-Base/middleware/include/c_utils.h +/home/app/Core/Inc/fault.h +/home/app/Core/Inc/state_machine.h +/home/app/Core/Inc/pdu.h +/home/app/Core/Inc/mpu.h +/home/app/Core/Inc/can_handler.h \ No newline at end of file diff --git a/Tests/test_sources.txt b/Tests/test_sources.txt new file mode 100644 index 00000000..6a51f15c --- /dev/null +++ b/Tests/test_sources.txt @@ -0,0 +1 @@ +/home/app/Core/Src/pedals.c \ No newline at end of file From e424c3e4d35ba23b6a60f0618d1eeea10d14ed3a Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 21 May 2025 19:24:08 -0400 Subject: [PATCH 05/23] works on first make --- Tests/Src/test_source.c | 2 +- Tests/mocked_includes.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Src/test_source.c b/Tests/Src/test_source.c index bbcba3ca..7ab232ec 100644 --- a/Tests/Src/test_source.c +++ b/Tests/Src/test_source.c @@ -22,7 +22,7 @@ void tearDown(void) { void test_random(void) { debounce_Ignore(); debounce_Ignore(); - TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), false); + TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), true); } int main(void) { diff --git a/Tests/mocked_includes.txt b/Tests/mocked_includes.txt index a2897599..86dc5d93 100644 --- a/Tests/mocked_includes.txt +++ b/Tests/mocked_includes.txt @@ -5,4 +5,4 @@ /home/app/Core/Inc/state_machine.h /home/app/Core/Inc/pdu.h /home/app/Core/Inc/mpu.h -/home/app/Core/Inc/can_handler.h \ No newline at end of file +/home/app/Core/Inc/can_handler.h From 8b4662607353092e2c9ae982922010b5c7ce92dc Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 21 May 2025 20:54:58 -0400 Subject: [PATCH 06/23] compiling all --- Tests/mocked_includes.txt | 14 ++++++-------- Tests/test_sources.txt | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 Tests/test_sources.txt diff --git a/Tests/mocked_includes.txt b/Tests/mocked_includes.txt index 86dc5d93..a38959e7 100644 --- a/Tests/mocked_includes.txt +++ b/Tests/mocked_includes.txt @@ -1,8 +1,6 @@ -/home/app/Core/Inc/dti.h -/home/app/Drivers/Embedded-Base/middleware/include/debounce.h -/home/app/Drivers/Embedded-Base/middleware/include/c_utils.h -/home/app/Core/Inc/fault.h -/home/app/Core/Inc/state_machine.h -/home/app/Core/Inc/pdu.h -/home/app/Core/Inc/mpu.h -/home/app/Core/Inc/can_handler.h +Core/Inc/dti.h +Core/Inc/fault.h +Core/Inc/state_machine.h +Core/Inc/pdu.h +Core/Inc/mpu.h +Core/Inc/can_handler.h \ No newline at end of file diff --git a/Tests/test_sources.txt b/Tests/test_sources.txt deleted file mode 100644 index 6a51f15c..00000000 --- a/Tests/test_sources.txt +++ /dev/null @@ -1 +0,0 @@ -/home/app/Core/Src/pedals.c \ No newline at end of file From 33af3d8aa1bdb80cf2be82e69ccfa52c496b38bd Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 22 May 2025 20:35:28 -0400 Subject: [PATCH 07/23] another test --- Core/Inc/pdu.h | 2 ++ Core/Inc/state_machine.h | 3 +++ Core/Src/pdu.c | 4 ++++ Core/Src/state_machine.c | 10 +++------- Tests/Src/test_source.c | 18 +++++++++++++++--- Tests/mocked_includes.txt | 1 - 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index d9442705..2ce2a1e9 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -106,6 +106,8 @@ uint8_t write_tca_config(pdu_t *pdu); */ bool verify_tca_config(pdu_t *pdu); +void set_rtds_flag(); + /** * @brief Read the status of all expander debug pins (both ctrl and shutdown, in that order). * diff --git a/Core/Inc/state_machine.h b/Core/Inc/state_machine.h index c811b23f..612d504d 100644 --- a/Core/Inc/state_machine.h +++ b/Core/Inc/state_machine.h @@ -134,4 +134,7 @@ int set_ready_mode(); */ int fault(); +int transition_functional_state(func_state_t new_state, pdu_t *pdu, + dti_t *mc, mpu_t *mpu); + #endif \ No newline at end of file diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 201124d2..c559df55 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -233,6 +233,10 @@ const osThreadAttr_t rtds_attributes = { .name = "RtdsThread", /* The task will run infrequently */ .priority = osPriorityRealtime7 }; +void set_rtds_flag() { + osThreadFlagsSet(rtds_thread, SOUND_RTDS_FLAG); +} + void vRTDS(void *arg) { pdu_t *pdu = (pdu_t *)arg; diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index 2782cd2b..a7d5e0df 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -82,7 +82,7 @@ nero_state_t get_nero_state() return cerberus_state.nero; } -static int transition_functional_state(func_state_t new_state, pdu_t *pdu, +int transition_functional_state(func_state_t new_state, pdu_t *pdu, dti_t *mc, mpu_t *mpu) { /* Special case: should be able to fault no matter what conditions */ @@ -138,12 +138,8 @@ static int transition_functional_state(func_state_t new_state, pdu_t *pdu, if (!brake_state || !get_tsms()) { return 3; } -#endif - - if (get_tsms()) { - osThreadFlagsSet(rtds_thread, SOUND_RTDS_FLAG); - } - +#endif + set_rtds_flag(); printf("ACTIVE STATE\r\n"); break; default: diff --git a/Tests/Src/test_source.c b/Tests/Src/test_source.c index 7ab232ec..8f98f9f0 100644 --- a/Tests/Src/test_source.c +++ b/Tests/Src/test_source.c @@ -3,19 +3,28 @@ #include "mock_debounce.h" #include "mock_c_utils.h" #include "mock_pdu.h" -#include "mock_state_machine.h" #include "mock_mpu.h" #include "mock_can_handler.h" #include "pedals.h" +#include "state_machine.h" #include +#include + +mpu_t *mpu; +pdu_t *pdu; +dti_t *dti; void setUp(void) { - // set stuff up here + mpu = malloc(sizeof(mpu_t)); + pdu = malloc(sizeof(pdu_t)); + dti = malloc(sizeof(dti_t)); } void tearDown(void) { - // clean stuff up here + free(mpu); + free(pdu); + free(dti); } // A simple random test @@ -23,6 +32,9 @@ void test_random(void) { debounce_Ignore(); debounce_Ignore(); TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), true); + + write_fault_IgnoreAndReturn(0); + TEST_ASSERT_EQUAL_INT(transition_functional_state(FAULTED, pdu, dti, mpu), 0); } int main(void) { diff --git a/Tests/mocked_includes.txt b/Tests/mocked_includes.txt index a38959e7..5cb11d87 100644 --- a/Tests/mocked_includes.txt +++ b/Tests/mocked_includes.txt @@ -1,6 +1,5 @@ Core/Inc/dti.h Core/Inc/fault.h -Core/Inc/state_machine.h Core/Inc/pdu.h Core/Inc/mpu.h Core/Inc/can_handler.h \ No newline at end of file From 8ba124819ad85f63d2045fe5d1241b0549a060bc Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 22 May 2025 21:12:04 -0400 Subject: [PATCH 08/23] fix include --- Core/Inc/bms.h | 2 +- Core/Inc/can_handler.h | 2 +- Core/Inc/dti.h | 2 +- Core/Inc/fault.h | 2 +- Core/Inc/monitor.h | 2 +- Core/Inc/mpu.h | 2 +- Core/Inc/pdu.h | 7 +++++-- Core/Src/pdu.c | 7 ++++--- Core/Src/state_machine.c | 2 +- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Core/Inc/bms.h b/Core/Inc/bms.h index d9216a40..01df7008 100644 --- a/Core/Inc/bms.h +++ b/Core/Inc/bms.h @@ -1,7 +1,7 @@ #ifndef BMS_H #define BMS_H -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" #include "can.h" #define BMS_CANID_CELL_TEMPS 0x84 /* BMS CELL TEMPERATURES */ diff --git a/Core/Inc/can_handler.h b/Core/Inc/can_handler.h index babe9ba7..a1a0e9b4 100644 --- a/Core/Inc/can_handler.h +++ b/Core/Inc/can_handler.h @@ -2,7 +2,7 @@ #define CAN_HANDLER_H #include "can.h" -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" #include "control.h" #include "dti.h" #include "bms.h" diff --git a/Core/Inc/dti.h b/Core/Inc/dti.h index 101599af..a127d1df 100644 --- a/Core/Inc/dti.h +++ b/Core/Inc/dti.h @@ -13,7 +13,7 @@ #define DTI_H #include "can.h" -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" /* Message IDs from DTI CAN Datasheet */ #define DTI_CANID_ERPM 0x416 /* ERPM, Duty, Input Voltage */ diff --git a/Core/Inc/fault.h b/Core/Inc/fault.h index 3d87f178..3bef4b9d 100644 --- a/Core/Inc/fault.h +++ b/Core/Inc/fault.h @@ -1,7 +1,7 @@ #ifndef CERBERUS_FAULT_H #define CERBERUS_FAULT_H -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" #include #include "stm32xx_hal.h" diff --git a/Core/Inc/monitor.h b/Core/Inc/monitor.h index 815d79e7..8f869a85 100644 --- a/Core/Inc/monitor.h +++ b/Core/Inc/monitor.h @@ -3,7 +3,7 @@ #include -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" #include "mpu.h" #include "pdu.h" diff --git a/Core/Inc/mpu.h b/Core/Inc/mpu.h index 577f32cf..c22046c7 100644 --- a/Core/Inc/mpu.h +++ b/Core/Inc/mpu.h @@ -3,7 +3,7 @@ #include -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" #include "stm32xx_hal.h" typedef struct { diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index 2ce2a1e9..39509b78 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -2,7 +2,7 @@ #define PDU_H #include -#include "cmsis_os_test.h" +#include "ner_cmsis_os.h" #include "tca9539.h" #include "INA226.h" #include @@ -106,7 +106,10 @@ uint8_t write_tca_config(pdu_t *pdu); */ bool verify_tca_config(pdu_t *pdu); -void set_rtds_flag(); +/** + * @brief sounds the rtds by setting its thread flag + */ +void sound_rtds(); /** * @brief Read the status of all expander debug pins (both ctrl and shutdown, in that order). diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index c559df55..1568f465 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -233,9 +233,6 @@ const osThreadAttr_t rtds_attributes = { .name = "RtdsThread", /* The task will run infrequently */ .priority = osPriorityRealtime7 }; -void set_rtds_flag() { - osThreadFlagsSet(rtds_thread, SOUND_RTDS_FLAG); -} void vRTDS(void *arg) { @@ -283,6 +280,10 @@ static int8_t write_ctrl(pdu_t *pdu, bool state, uint8_t pin, uint8_t reg) return 0; } +void sound_rtds() { + osThreadFlagsSet(rtds_thread, SOUND_RTDS_FLAG); +} + int8_t write_pump_1(pdu_t *pdu, bool state) { return write_ctrl(pdu, state, PIN_PUMP_CTRL_1, TCA_OUTPUT_PORT_0); diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index a7d5e0df..6f4993a6 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -139,7 +139,7 @@ int transition_functional_state(func_state_t new_state, pdu_t *pdu, return 3; } #endif - set_rtds_flag(); + sound_rtds(); printf("ACTIVE STATE\r\n"); break; default: From 290f55ad3165904fa5ab02071b11d2c1b837318f Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 22 May 2025 23:20:24 -0400 Subject: [PATCH 09/23] fixed --- Core/Inc/pdu.h | 5 +++++ Core/Inc/pedals.h | 1 - Core/Src/pedals.c | 2 +- Core/Src/state_machine.c | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index 39509b78..e1b94ef4 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -120,6 +120,11 @@ void sound_rtds(); */ int8_t read_expander_debug(pdu_t *pdu, uint8_t expander_debug_data[4]); +/** + * @brief sounds rtds by settings its thread flag + */ +void sound_rtds(); + /** * @brief Taskf for sounding RTDS. * diff --git a/Core/Inc/pedals.h b/Core/Inc/pedals.h index 2549553f..d0c403ba 100644 --- a/Core/Inc/pedals.h +++ b/Core/Inc/pedals.h @@ -113,5 +113,4 @@ bool get_launch_control(); bool calc_pedal_faults(float accel1, float accel2, float accel1_norm, float accel2_norm); - #endif diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index 8d0b1f06..72b4e34e 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -141,7 +141,7 @@ void set_torque_limit(float percentage) } } -int get_torque_limit_percentage() +float get_torque_limit_percentage() { return 1; } diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index 6f4993a6..1d029721 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -9,6 +9,7 @@ #include "monitor.h" #include "pedals.h" #include "can_handler.h" +#include "pdu.h" #define STATE_TRANS_QUEUE_SIZE 4 From 910d647647f417062cd368b62f15b38a99eb6fed Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 22 May 2025 23:31:22 -0400 Subject: [PATCH 10/23] remove extra --- Core/Inc/pdu.h | 5 ----- Core/Src/pedals.c | 4 ++-- Tests/Inc/test_main.h | 15 --------------- Tests/Src/test_main.c | 23 ----------------------- 4 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 Tests/Inc/test_main.h delete mode 100644 Tests/Src/test_main.c diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index e1b94ef4..ffa83a84 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -106,11 +106,6 @@ uint8_t write_tca_config(pdu_t *pdu); */ bool verify_tca_config(pdu_t *pdu); -/** - * @brief sounds the rtds by setting its thread flag - */ -void sound_rtds(); - /** * @brief Read the status of all expander debug pins (both ctrl and shutdown, in that order). * diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index 72b4e34e..bb82c9b9 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -64,7 +64,7 @@ bool get_brake_state() * @param raw_adc * @return float */ -float adc_to_volts(uint32_t raw_adc) +static float adc_to_volts(uint32_t raw_adc) { float v3_volts = raw_adc * MAX_VOLTS / MAX_ADC_VAL_12b; // undo 2k + 3k voltage divider on APPS lines @@ -143,7 +143,7 @@ void set_torque_limit(float percentage) float get_torque_limit_percentage() { - return 1; + return torque_limit_percentage; } uint16_t get_regen_limit() diff --git a/Tests/Inc/test_main.h b/Tests/Inc/test_main.h deleted file mode 100644 index b8921f9f..00000000 --- a/Tests/Inc/test_main.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CERBERUS_TEST_H -#define CERBERUS_TEST_H - -/* - * ************** NOTE ************** - * These test files are specifically - * for unit tests, developers can - * make sure that specific functions - * and APIs meet requirements set out. - * This should NOT be used for actually - * simulating drivers and hardware, - * that is what we are using Renode for - */ - -#endif // CERBERUS_TEST_H \ No newline at end of file diff --git a/Tests/Src/test_main.c b/Tests/Src/test_main.c deleted file mode 100644 index e712f95e..00000000 --- a/Tests/Src/test_main.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "unity.h" -#include "cerberus_test.h" -#include "pedals.h" - -void setUp(void) { - // set stuff up here -} - -void tearDown(void) { - // clean stuff up here -} - -// A simple random test -void test_random(void) { - TEST_ASSERT_EQUAL_INT(15, 2); -} - - -int main(void) { - UNITY_BEGIN(); - RUN_TEST(test_random); - return UNITY_END(); -} \ No newline at end of file From d9ce20a964c9a155ad45cc84570a3b3ea064fa97 Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 22 May 2025 23:34:41 -0400 Subject: [PATCH 11/23] fixed --- Core/Inc/state_machine.h | 10 ++++++++++ Core/Src/state_machine.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Core/Inc/state_machine.h b/Core/Inc/state_machine.h index 612d504d..43024d11 100644 --- a/Core/Inc/state_machine.h +++ b/Core/Inc/state_machine.h @@ -134,6 +134,16 @@ int set_ready_mode(); */ int fault(); +/** + * @brief tranitions the functional state based on current sate + * + * @param new_state state that is requesting transition + * @param pdu pdu interface + * @param mc dti interface + * @param mpu mpu interface + * + * @return error code + */ int transition_functional_state(func_state_t new_state, pdu_t *pdu, dti_t *mc, mpu_t *mpu); diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index 1d029721..d4854ec1 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -140,7 +140,9 @@ int transition_functional_state(func_state_t new_state, pdu_t *pdu, return 3; } #endif - sound_rtds(); + if (get_tsms()) { + sound_rtds(); + } printf("ACTIVE STATE\r\n"); break; default: From 3a21a8a03842cecaae13eaa84c8d5a002dea9213 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 24 May 2025 19:13:40 -0400 Subject: [PATCH 12/23] separate tests --- Drivers/Embedded-Base | 2 +- Tests/Inc/cerberus_test.h | 17 ---------- Tests/Inc/test_pedals.h | 8 +++++ Tests/Inc/test_source.h | 18 ----------- Tests/Inc/test_state_machine.h | 8 +++++ Tests/Src/can_handler_test.c | 6 ---- Tests/Src/test_pedals.c | 31 +++++++++++++++++++ .../{test_source.c => test_state_machine.c} | 18 +++-------- 8 files changed, 53 insertions(+), 55 deletions(-) delete mode 100644 Tests/Inc/cerberus_test.h create mode 100644 Tests/Inc/test_pedals.h delete mode 100644 Tests/Inc/test_source.h create mode 100644 Tests/Inc/test_state_machine.h delete mode 100644 Tests/Src/can_handler_test.c create mode 100644 Tests/Src/test_pedals.c rename Tests/Src/{test_source.c => test_state_machine.c} (58%) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 30a84d97..21fc8dc0 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 30a84d9758a91cde7cc0eaafe1dc8eba54742489 +Subproject commit 21fc8dc07558bc795415b647518b7e47e802a588 diff --git a/Tests/Inc/cerberus_test.h b/Tests/Inc/cerberus_test.h deleted file mode 100644 index 57cf964b..00000000 --- a/Tests/Inc/cerberus_test.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CERBERUS_TEST_H -#define CERBERUS_TEST_H - -/* - * ************** NOTE ************** - * These test files are specifically - * for unit tests, developers can - * make sure that specific functions - * and APIs meet requirements set out. - * This should NOT be used for actually - * simulating drivers and hardware, - * that is what we are using Renode for - */ - -void test_can_handler(void); - -#endif // CERBERUS_TEST_H \ No newline at end of file diff --git a/Tests/Inc/test_pedals.h b/Tests/Inc/test_pedals.h new file mode 100644 index 00000000..1b770fff --- /dev/null +++ b/Tests/Inc/test_pedals.h @@ -0,0 +1,8 @@ +#ifndef TEST_PEDALS_H +#define TEST_PEDALS_H + +#include "pedals.h" + +void test_calc_pedal_faults(void); + +#endif \ No newline at end of file diff --git a/Tests/Inc/test_source.h b/Tests/Inc/test_source.h deleted file mode 100644 index 9a699432..00000000 --- a/Tests/Inc/test_source.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CERBERUS_TEST_H -#define CERBERUS_TEST_H - -/* - * ************** NOTE ************** - * These test files are specifically - * for unit tests, developers can - * make sure that specific functions - * and APIs meet requirements set out. - * This should NOT be used for actually - * simulating drivers and hardware, - * that is what we are using Renode for - */ - - void setUp(void); - void tearDown(void); - -#endif // CERBERUS_TEST_H \ No newline at end of file diff --git a/Tests/Inc/test_state_machine.h b/Tests/Inc/test_state_machine.h new file mode 100644 index 00000000..c57bbc43 --- /dev/null +++ b/Tests/Inc/test_state_machine.h @@ -0,0 +1,8 @@ +#ifndef TEST_STATE_MACHINE_H +#define TEST_STATE_MACHINE_H + +#include "state_machine.h" + +void test_tansition_functional_state(void); + +#endif // TEST_STATE_MACHINE_H \ No newline at end of file diff --git a/Tests/Src/can_handler_test.c b/Tests/Src/can_handler_test.c deleted file mode 100644 index 0c0ffd4c..00000000 --- a/Tests/Src/can_handler_test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "unity.h" - -void test_can_handler(void) -{ - //TEST_ASSERT_NOT_NULL(getFunction(0x2010)); -} \ No newline at end of file diff --git a/Tests/Src/test_pedals.c b/Tests/Src/test_pedals.c new file mode 100644 index 00000000..40481328 --- /dev/null +++ b/Tests/Src/test_pedals.c @@ -0,0 +1,31 @@ +#include "unity.h" +#include "mock_stub_functions.h" +#include "mock_debounce.h" +#include "mock_c_utils.h" +#include "mock_pdu.h" +#include "mock_mpu.h" +#include "mock_can_handler.h" +#include "test_pedals.h" + +void setUp(void) { + +} + +void tearDown(void) { +} + +void test_calc_pedal_faults() { + debounce_Ignore(); + debounce_Ignore(); + TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), true); + + debounce_Ignore(); + debounce_Ignore(); + TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .30), false); +} + +int main(void) { + UNITY_BEGIN(); + RUN_TEST(test_calc_pedal_faults); + return UNITY_END(); +} \ No newline at end of file diff --git a/Tests/Src/test_source.c b/Tests/Src/test_state_machine.c similarity index 58% rename from Tests/Src/test_source.c rename to Tests/Src/test_state_machine.c index 8f98f9f0..c4878e5d 100644 --- a/Tests/Src/test_source.c +++ b/Tests/Src/test_state_machine.c @@ -1,12 +1,8 @@ + #include "unity.h" -#include "mock_stub_functions.h" -#include "mock_debounce.h" -#include "mock_c_utils.h" -#include "mock_pdu.h" #include "mock_mpu.h" -#include "mock_can_handler.h" -#include "pedals.h" -#include "state_machine.h" +#include "mock_pdu.h" +#include "test_state_machine.h" #include #include @@ -28,17 +24,13 @@ void tearDown(void) { } // A simple random test -void test_random(void) { - debounce_Ignore(); - debounce_Ignore(); - TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), true); - +void test_tansition_functional_state(void) { write_fault_IgnoreAndReturn(0); TEST_ASSERT_EQUAL_INT(transition_functional_state(FAULTED, pdu, dti, mpu), 0); } int main(void) { UNITY_BEGIN(); - RUN_TEST(test_random); + RUN_TEST(test_tansition_functional_state); return UNITY_END(); } \ No newline at end of file From dd3ccf6abf010160254813eab99f21978b6b6e9a Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 24 May 2025 23:16:57 -0400 Subject: [PATCH 13/23] move header --- Drivers/Embedded-Base | 2 +- Tests/Inc/test_pedals.h | 1 + Tests/Inc/test_state_machine.h | 1 + Tests/Src/test_pedals.c | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 21fc8dc0..443b71af 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 21fc8dc07558bc795415b647518b7e47e802a588 +Subproject commit 443b71af23a3b3d47de19ec34b77f6da96d4ccca diff --git a/Tests/Inc/test_pedals.h b/Tests/Inc/test_pedals.h index 1b770fff..8ce34dac 100644 --- a/Tests/Inc/test_pedals.h +++ b/Tests/Inc/test_pedals.h @@ -1,6 +1,7 @@ #ifndef TEST_PEDALS_H #define TEST_PEDALS_H +#include "unity.h" #include "pedals.h" void test_calc_pedal_faults(void); diff --git a/Tests/Inc/test_state_machine.h b/Tests/Inc/test_state_machine.h index c57bbc43..25fb5e9d 100644 --- a/Tests/Inc/test_state_machine.h +++ b/Tests/Inc/test_state_machine.h @@ -1,6 +1,7 @@ #ifndef TEST_STATE_MACHINE_H #define TEST_STATE_MACHINE_H +#include "unity.h" #include "state_machine.h" void test_tansition_functional_state(void); diff --git a/Tests/Src/test_pedals.c b/Tests/Src/test_pedals.c index 40481328..c5ada7af 100644 --- a/Tests/Src/test_pedals.c +++ b/Tests/Src/test_pedals.c @@ -1,4 +1,4 @@ -#include "unity.h" + #include "mock_stub_functions.h" #include "mock_debounce.h" #include "mock_c_utils.h" From b5555573cf08f6515cf1acbcbb89eed25c92a455 Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 25 May 2025 22:13:09 -0400 Subject: [PATCH 14/23] support separate test configs --- Drivers/Embedded-Base | 2 +- Tests/Src/test_state_machine.c | 1 - Tests/mock_configs/test_pedals.txt | 5 +++++ .../test_state_machine.txt} | 0 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 Tests/mock_configs/test_pedals.txt rename Tests/{mocked_includes.txt => mock_configs/test_state_machine.txt} (100%) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 443b71af..8b18c738 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 443b71af23a3b3d47de19ec34b77f6da96d4ccca +Subproject commit 8b18c738843644801c170f137644fa2623a4b42f diff --git a/Tests/Src/test_state_machine.c b/Tests/Src/test_state_machine.c index c4878e5d..a9f2351f 100644 --- a/Tests/Src/test_state_machine.c +++ b/Tests/Src/test_state_machine.c @@ -1,5 +1,4 @@ -#include "unity.h" #include "mock_mpu.h" #include "mock_pdu.h" #include "test_state_machine.h" diff --git a/Tests/mock_configs/test_pedals.txt b/Tests/mock_configs/test_pedals.txt new file mode 100644 index 00000000..3aec91f7 --- /dev/null +++ b/Tests/mock_configs/test_pedals.txt @@ -0,0 +1,5 @@ +Core/Inc/dti.h +Core/Inc/fault.h +Core/Inc/pdu.h +Core/Inc/mpu.h +Core/Inc/can_handler.h diff --git a/Tests/mocked_includes.txt b/Tests/mock_configs/test_state_machine.txt similarity index 100% rename from Tests/mocked_includes.txt rename to Tests/mock_configs/test_state_machine.txt From 2e55352e4d9d7586d1cc29980c5cb6b7592aebfc Mon Sep 17 00:00:00 2001 From: Caio Date: Fri, 6 Jun 2025 23:43:35 -0400 Subject: [PATCH 15/23] github cli --- .github/workflows/test-check.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/test-check.yml diff --git a/.github/workflows/test-check.yml b/.github/workflows/test-check.yml new file mode 100644 index 00000000..08b341f6 --- /dev/null +++ b/.github/workflows/test-check.yml @@ -0,0 +1,23 @@ +name: Unit Test Check + +on: [push] + +jobs: + test-check: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout code + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Run UNITY Testing files + - name: Run UNITY Testing files + run: | + if ! docker compose run --rm ner-gcc-arm \ + bash -c "cd Drivers/Embedded-Base/ner_enviornment/build_sytem && python3 test_runner.py"; then + echo "Unit tests failed." + exit 1 + fi + + From 7fb2060ea0ab1c83da3d40f90013de2f066ff24e Mon Sep 17 00:00:00 2001 From: Caio Date: Fri, 20 Jun 2025 22:27:40 -0400 Subject: [PATCH 16/23] test build check --- .github/workflows/test-check.yml | 2 +- Drivers/Embedded-Base | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-check.yml b/.github/workflows/test-check.yml index 08b341f6..72fbb3d9 100644 --- a/.github/workflows/test-check.yml +++ b/.github/workflows/test-check.yml @@ -15,7 +15,7 @@ jobs: - name: Run UNITY Testing files run: | if ! docker compose run --rm ner-gcc-arm \ - bash -c "cd Drivers/Embedded-Base/ner_enviornment/build_sytem && python3 test_runner.py"; then + bash -c "python3 Drivers/Embedded-Base/ner_environment/build_system/test_runner.py"; then echo "Unit tests failed." exit 1 fi diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 8b18c738..4c2d7064 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 8b18c738843644801c170f137644fa2623a4b42f +Subproject commit 4c2d7064b32c5ed78c62b218827edd2843574b55 From 31418b0d22cdb909cfc5eabecdc363e6434dcc9f Mon Sep 17 00:00:00 2001 From: Caio Date: Fri, 20 Jun 2025 22:34:12 -0400 Subject: [PATCH 17/23] testing --- .github/workflows/test-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-check.yml b/.github/workflows/test-check.yml index 72fbb3d9..f0f9057b 100644 --- a/.github/workflows/test-check.yml +++ b/.github/workflows/test-check.yml @@ -1,6 +1,7 @@ name: Unit Test Check -on: [push] +on: + pull_request: jobs: test-check: @@ -12,7 +13,6 @@ jobs: with: submodules: recursive - name: Run UNITY Testing files - - name: Run UNITY Testing files run: | if ! docker compose run --rm ner-gcc-arm \ bash -c "python3 Drivers/Embedded-Base/ner_environment/build_system/test_runner.py"; then From 129f64d6851fa8165a5905d245dd2a28234c55e4 Mon Sep 17 00:00:00 2001 From: Caio Date: Fri, 20 Jun 2025 22:37:57 -0400 Subject: [PATCH 18/23] workflow --- .github/workflows/test-check.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-check.yml b/.github/workflows/test-check.yml index f0f9057b..62f8b22a 100644 --- a/.github/workflows/test-check.yml +++ b/.github/workflows/test-check.yml @@ -1,6 +1,7 @@ name: Unit Test Check on: + push: pull_request: jobs: @@ -8,16 +9,14 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Checkout code - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Run UNITY Testing files + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Run UNITY Testing files run: | - if ! docker compose run --rm ner-gcc-arm \ - bash -c "python3 Drivers/Embedded-Base/ner_environment/build_system/test_runner.py"; then - echo "Unit tests failed." - exit 1 - fi - - + if ! docker compose run --rm ner-gcc-arm \ + bash -c "python3 Drivers/Embedded-Base/ner_environment/build_system/test_runner.py"; then + echo "Unit tests failed." + exit 1 + fi From a465927f3f45de0110863e87d77099124f71ca12 Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 22 Jun 2025 00:06:21 -0400 Subject: [PATCH 19/23] yml --- Drivers/Embedded-Base | 2 +- compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 4c2d7064..ec8a07f6 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 4c2d7064b32c5ed78c62b218827edd2843574b55 +Subproject commit ec8a07f6eaf6ec2d8a46d462c336583cb7f2d385 diff --git a/compose.yml b/compose.yml index 71089463..2e358afe 100644 --- a/compose.yml +++ b/compose.yml @@ -2,7 +2,7 @@ name: cerberus services: ner-gcc-arm: - image: ghcr.io/northeastern-electric-racing/embedded-base:main + image: ghcr.io/northeastern-electric-racing/embedded-base:unity-testing build: . network_mode: host privileged: true From 6864149afad4f3925ac634ec617c8476ba17c4d1 Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 22 Jun 2025 10:05:28 -0400 Subject: [PATCH 20/23] test failing --- Tests/Src/test_pedals.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Src/test_pedals.c b/Tests/Src/test_pedals.c index c5ada7af..00182a0e 100644 --- a/Tests/Src/test_pedals.c +++ b/Tests/Src/test_pedals.c @@ -17,7 +17,7 @@ void tearDown(void) { void test_calc_pedal_faults() { debounce_Ignore(); debounce_Ignore(); - TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), true); + TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), false); debounce_Ignore(); debounce_Ignore(); From c8c4397059a8665c390df13c0f9752ccb7f24e21 Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 22 Jun 2025 10:14:28 -0400 Subject: [PATCH 21/23] failing test v2 --- Core/Src/state_machine.c | 6 +++--- Drivers/Embedded-Base | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index d4854ec1..c6fbfd56 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -83,8 +83,8 @@ nero_state_t get_nero_state() return cerberus_state.nero; } -int transition_functional_state(func_state_t new_state, pdu_t *pdu, - dti_t *mc, mpu_t *mpu) +int transition_functional_state(func_state_t new_state, pdu_t *pdu, dti_t *mc, + mpu_t *mpu) { /* Special case: should be able to fault no matter what conditions */ if (new_state == FAULTED) { @@ -139,7 +139,7 @@ int transition_functional_state(func_state_t new_state, pdu_t *pdu, if (!brake_state || !get_tsms()) { return 3; } -#endif +#endif if (get_tsms()) { sound_rtds(); } diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index ec8a07f6..909a2d20 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit ec8a07f6eaf6ec2d8a46d462c336583cb7f2d385 +Subproject commit 909a2d202118674bfa986021b8b3cbb46da80fa5 From 2b7ff66f5f6d1f04746c0cd5bf65c9e3d4b43b7a Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 22 Jun 2025 10:16:47 -0400 Subject: [PATCH 22/23] format --- Core/Src/pdu.c | 4 ++-- Tests/Src/test_pedals.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 1568f465..c53de23d 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -233,7 +233,6 @@ const osThreadAttr_t rtds_attributes = { .name = "RtdsThread", /* The task will run infrequently */ .priority = osPriorityRealtime7 }; - void vRTDS(void *arg) { pdu_t *pdu = (pdu_t *)arg; @@ -280,7 +279,8 @@ static int8_t write_ctrl(pdu_t *pdu, bool state, uint8_t pin, uint8_t reg) return 0; } -void sound_rtds() { +void sound_rtds() +{ osThreadFlagsSet(rtds_thread, SOUND_RTDS_FLAG); } diff --git a/Tests/Src/test_pedals.c b/Tests/Src/test_pedals.c index 00182a0e..c5ada7af 100644 --- a/Tests/Src/test_pedals.c +++ b/Tests/Src/test_pedals.c @@ -17,7 +17,7 @@ void tearDown(void) { void test_calc_pedal_faults() { debounce_Ignore(); debounce_Ignore(); - TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), false); + TEST_ASSERT_EQUAL_INT(calc_pedal_faults(3.2, 1.2, 0.50, .10), true); debounce_Ignore(); debounce_Ignore(); From f72768483d2e8ca63e8f83187a4703d6e01523b2 Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 20 Jul 2025 08:16:53 -0400 Subject: [PATCH 23/23] fix cli --- .github/workflows/test-check.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-check.yml b/.github/workflows/test-check.yml index 62f8b22a..1a471da2 100644 --- a/.github/workflows/test-check.yml +++ b/.github/workflows/test-check.yml @@ -1,8 +1,6 @@ name: Unit Test Check -on: - push: - pull_request: +on: [push] jobs: test-check: