From 5278640762659057efb3d145668be85a7c2704aa Mon Sep 17 00:00:00 2001 From: ishdeshpa Date: Mon, 25 Sep 2023 23:51:32 +0000 Subject: [PATCH] kinda functional sendcarcan test with new test framework way of writiy of writing tests, may be deemed un-useful and removed later on. going to keep it on sendcarcan_test branch for now. --- Tests/Leader/Test_App_SendCarCAN.c | 66 ++++++++++++++++-------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/Tests/Leader/Test_App_SendCarCAN.c b/Tests/Leader/Test_App_SendCarCAN.c index 0b8a03c8..4d2c504d 100644 --- a/Tests/Leader/Test_App_SendCarCAN.c +++ b/Tests/Leader/Test_App_SendCarCAN.c @@ -10,21 +10,17 @@ #include "BSP_ADC.h" -#define TEST_USE_RTOS 1 +// Import test runner +#define USE_OS #include "Test_Runner.h" -// static OS_TMR IOStateTestTmr; - -static CANDATA_t checkData; - -// Test Functions (Each test function should test one aspect of code functionality) +// Test Cases static void Test_IOState(){ OS_ERR err; // Check for IO State CAN message here // Data should be default system state - OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT); - __asm("bkpt"); + OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err); // Change state for some outputs Contactors_Set(MOTOR_CONTACTOR, true, true); @@ -32,16 +28,39 @@ static void Test_IOState(){ // Check for IO State CAN message here // Data should be changed according to change in outputs - OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT); - __asm("bkpt"); - - // Once breakpoint is hit, change some inputs to system - // Then check if appropriate change has been made to CAN message - OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT); - __asm("bkpt"); + OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err); + + for(int i=0; i<5; i++){ + // Once breakpoint is hit, change some inputs to system + // Then check if appropriate change has been made to CAN message + OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err); // Breakpoint here + } } -static void Test_Send +static void Test_ControlMode(){ + OS_ERR err; + + OSTaskCreate( + (OS_TCB *)&SendTritium_TCB, + (CPU_CHAR *)"SendTritium", + (OS_TASK_PTR)Task_SendTritium, + (void *)NULL, + (OS_PRIO)TASK_SEND_TRITIUM_PRIO, + (CPU_STK *)SendTritium_Stk, + (CPU_STK_SIZE)DEFAULT_STACK_SIZE, + (CPU_STK_SIZE)DEFAULT_STACK_SIZE, + (OS_MSG_QTY)0, + (OS_TICK)NULL, + (void *)NULL, + (OS_OPT)(OS_OPT_TASK_STK_CLR), + (OS_ERR *)&err); + + for(int i=0; i<5; i++){ + // Once breakpoint is hit, change some inputs to system + // Then check if appropriate change has been made to CAN message + OSTimeDlyHMSM(0, 0, 0, IO_STATE_TMR_DLY_MS, OS_OPT_TIME_HMSM_STRICT, &err); // Breakpoint here + } +} // Test Drivers void Test_Setup(){ @@ -51,7 +70,6 @@ void Test_Setup(){ Pedals_Init(); Minions_Init(); - checkData.ID = IO_STATE; return; } @@ -59,8 +77,6 @@ void Test_Start(){ // Spawn necessary applications OS_ERR err; - SendCarCAN_Init(); - OSTaskCreate( (OS_TCB *)&SendCarCAN_TCB, (CPU_CHAR *)"SendCarCAN", @@ -76,20 +92,10 @@ void Test_Start(){ (OS_OPT)(OS_OPT_TASK_STK_CLR), (OS_ERR *)&err); assertOSError(OS_MAIN_LOC, err); - - // OSTmrCreate(&IOStateTestTmr, - // "IO State Test Timer", - // 0, - // IO_STATE_TMR_DLY_TS, - // OS_OPT_TMR_ONE_SHOT, - // IOStateTestHandler, - // NULL, - // &err - // ); - // assertOSError(OS_MAIN_LOC, err); // Run all test functions here Test_IOState(); + Test_ControlMode(); return; } \ No newline at end of file