From f08c10ed57d0fdf8dc536cf984121a9938aa1b39 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sun, 30 Apr 2023 14:23:12 +0000 Subject: [PATCH 01/31] Complete task 1 --- projects/fw103_taksh/src/main.c | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 projects/fw103_taksh/src/main.c diff --git a/projects/fw103_taksh/src/main.c b/projects/fw103_taksh/src/main.c new file mode 100644 index 000000000..f781973af --- /dev/null +++ b/projects/fw103_taksh/src/main.c @@ -0,0 +1,53 @@ +#include +#include + +#include "FreeRTOS.h" +#include "tasks.h" + +#include "gpio.h" +#include "log.h" +#include "misc.h" +#include "delay.h" + +// Non blocking delay. Simply consumes cpu cycles until a given time has passed +static void prv_delay(const TickType_t delay_ms) { + TickType_t curr_tick = xTaskGetTickCount(); + while(xTaskGetTickCount() - curr_tick < pdMS_TO_TICKS(delay_ms)) + {} +} + +TASK(task1, TASK_STACK_512) { + int counter1 = 0; + while (true) { + // Your code here + LOG_DEBUG("TASK 1- %s, %d", task1->name, counter1); + counter1++; + prv_delay(1000); + // delay_ms(1000); + } +} + +TASK(task2, TASK_STACK_512) { + int counter2 = 0; + while (true) { + // Your code here + LOG_DEBUG("TASK 2- %s, %d", task2->name, counter2); + counter2++; + prv_delay(1000); + // delay_ms(1000); + } +} + +int main(void) { + log_init(); + // Create tasks here + tasks_init(); + tasks_init_task(task1, TASK_PRIORITY(1), NULL); + tasks_init_task(task2, TASK_PRIORITY(1), NULL); + + LOG_DEBUG("Program start...\n"); + // Start the scheduler + tasks_start(); + + return 0; +} \ No newline at end of file From 846d7f0f844f557ffd5c3f16b086eabef77f29aa Mon Sep 17 00:00:00 2001 From: vagrant Date: Sun, 30 Apr 2023 22:04:26 +0000 Subject: [PATCH 02/31] Complete task 1 --- projects/fw103_taksh/src/main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/fw103_taksh/src/main.c b/projects/fw103_taksh/src/main.c index f781973af..4955d5a6d 100644 --- a/projects/fw103_taksh/src/main.c +++ b/projects/fw103_taksh/src/main.c @@ -10,11 +10,11 @@ #include "delay.h" // Non blocking delay. Simply consumes cpu cycles until a given time has passed -static void prv_delay(const TickType_t delay_ms) { - TickType_t curr_tick = xTaskGetTickCount(); - while(xTaskGetTickCount() - curr_tick < pdMS_TO_TICKS(delay_ms)) - {} -} +// static void prv_delay(const TickType_t delay_ms) { +// TickType_t curr_tick = xTaskGetTickCount(); +// while(xTaskGetTickCount() - curr_tick < pdMS_TO_TICKS(delay_ms)) +// {} +// } TASK(task1, TASK_STACK_512) { int counter1 = 0; @@ -22,8 +22,8 @@ TASK(task1, TASK_STACK_512) { // Your code here LOG_DEBUG("TASK 1- %s, %d", task1->name, counter1); counter1++; - prv_delay(1000); - // delay_ms(1000); + // prv_delay(1000); + delay_ms(1000); } } @@ -33,8 +33,8 @@ TASK(task2, TASK_STACK_512) { // Your code here LOG_DEBUG("TASK 2- %s, %d", task2->name, counter2); counter2++; - prv_delay(1000); - // delay_ms(1000); + // prv_delay(1000); + delay_ms(1000); } } @@ -43,7 +43,7 @@ int main(void) { // Create tasks here tasks_init(); tasks_init_task(task1, TASK_PRIORITY(1), NULL); - tasks_init_task(task2, TASK_PRIORITY(1), NULL); + tasks_init_task(task2, TASK_PRIORITY(2), NULL); LOG_DEBUG("Program start...\n"); // Start the scheduler From 0031dbffc532d10ceceee456b168f791f527ddc4 Mon Sep 17 00:00:00 2001 From: vagrant Date: Fri, 5 May 2023 12:21:24 +0000 Subject: [PATCH 03/31] Taksh Parmar tasks commit --- fwxv | 1 + projects/fw103_taksh/README.md | 16 ++++++ projects/fw103_taksh/config.json | 6 +++ .../fw103_taksh/src/{main.c => tasks/tasks.c} | 0 projects/hello_world/README.md | 16 ++++++ projects/hello_world/config.json | 6 +++ projects/hello_world/src/main.c | 52 +++++++++++++++++++ 7 files changed, 97 insertions(+) create mode 160000 fwxv create mode 100644 projects/fw103_taksh/README.md create mode 100644 projects/fw103_taksh/config.json rename projects/fw103_taksh/src/{main.c => tasks/tasks.c} (100%) create mode 100644 projects/hello_world/README.md create mode 100644 projects/hello_world/config.json create mode 100644 projects/hello_world/src/main.c diff --git a/fwxv b/fwxv new file mode 160000 index 000000000..93065f264 --- /dev/null +++ b/fwxv @@ -0,0 +1 @@ +Subproject commit 93065f264c0fa69f26f1bbf375456fcf0ce92558 diff --git a/projects/fw103_taksh/README.md b/projects/fw103_taksh/README.md new file mode 100644 index 000000000..655e7e33a --- /dev/null +++ b/projects/fw103_taksh/README.md @@ -0,0 +1,16 @@ + +# fw103_taksh + diff --git a/projects/fw103_taksh/config.json b/projects/fw103_taksh/config.json new file mode 100644 index 000000000..4019f4748 --- /dev/null +++ b/projects/fw103_taksh/config.json @@ -0,0 +1,6 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common" + ] +} \ No newline at end of file diff --git a/projects/fw103_taksh/src/main.c b/projects/fw103_taksh/src/tasks/tasks.c similarity index 100% rename from projects/fw103_taksh/src/main.c rename to projects/fw103_taksh/src/tasks/tasks.c diff --git a/projects/hello_world/README.md b/projects/hello_world/README.md new file mode 100644 index 000000000..ffea5e973 --- /dev/null +++ b/projects/hello_world/README.md @@ -0,0 +1,16 @@ + +# hello_world + diff --git a/projects/hello_world/config.json b/projects/hello_world/config.json new file mode 100644 index 000000000..4019f4748 --- /dev/null +++ b/projects/hello_world/config.json @@ -0,0 +1,6 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common" + ] +} \ No newline at end of file diff --git a/projects/hello_world/src/main.c b/projects/hello_world/src/main.c new file mode 100644 index 000000000..0c3f628d7 --- /dev/null +++ b/projects/hello_world/src/main.c @@ -0,0 +1,52 @@ +#include + +#include "log.h" +#include "tasks.h" + +#ifdef MS_PLATFORM_X86 +#define MASTER_MS_CYCLE_TIME 100 +#else +#define MASTER_MS_CYCLE_TIME 1000 +#endif + +void run_fast_cycle() +{ + +} + +void run_medium_cycle() +{ + +} + +void run_slow_cycle() +{ + +} + +TASK(master_task, TASK_MIN_STACK_SIZE) { + int counter = 0; + while (true) { + run_fast_cycle(); + if (!(counter%10)) + run_medium_cycle(); + if (!(counter%100)) + run_slow_cycle(); + vTaskDelay(pdMS_TO_TICKS(1000)); + ++counter; + } +} + +int main() { + tasks_init(); + log_init(); + LOG_DEBUG("Welcome to TEST!"); + + tasks_init_task(master_task, TASK_PRIORITY(2), NULL); + + tasks_start(); + + LOG_DEBUG("exiting main?"); + return 0; +} + From f0b7bb8d5c5d73df29fe0f263de9153cfa3052b1 Mon Sep 17 00:00:00 2001 From: vagrant Date: Thu, 11 May 2023 15:56:00 +0000 Subject: [PATCH 04/31] complete task 2 --- projects/fw103_taksh/src/queues1.c | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 projects/fw103_taksh/src/queues1.c diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c new file mode 100644 index 000000000..6b9514f12 --- /dev/null +++ b/projects/fw103_taksh/src/queues1.c @@ -0,0 +1,75 @@ +#include +#include +#include "FreeRTOS.h" +#include "tasks.h" +#include "queues.h" +#include "status.h" +#include "delay.h" +#include "log.h" +#include "misc.h" +#include "string.h" + +#define ITEM_SZ 6 +#define QUEUE_LEN 5 +#define BUF_SIZE (QUEUE_LEN * ITEM_SZ) +#define code 'STATUS_CODE_OK' +static const char s_list[QUEUE_LEN][ITEM_SZ] = { + "Item1", + "Item2", + "Item3", + "Item4", + "Item5" +}; +// Task static entities +static uint8_t s_queue1_buf[BUF_SIZE]; +static Queue s_queue1 = { + // Add parameters + .num_items = QUEUE_LEN, + .item_size = ITEM_SZ, + .storage_buf = s_queue1_buf, +}; +TASK(task1, TASK_STACK_512) { + LOG_DEBUG("Task 1 initialized!\n"); + StatusCode ret; + char to_send = ' '; + int i = 0; + while (true) { + // Your code goes here + strcpy(&to_send, s_list[0]); + i++; + if(i == QUEUE_LEN) { + i = 0; + } + ret = queue_send(&s_queue1, &to_send, 0); + delay_ms(100); + if (ret != 0) { + LOG_DEBUG("write to queue failed"); + } + } +} +TASK(task2, TASK_STACK_512) { + LOG_DEBUG("Task 2 initialized!\n"); + const char outstr[ITEM_SZ]; + StatusCode ret; + while (true) { + // Your code goes here + ret = queue_receive(&s_queue1, (char *)&outstr, 0); + if (ret == 0) { + LOG_DEBUG("%s\n", outstr); + } else { + LOG_DEBUG("read from queue failed"); + } + } +} +int main(void) { + + log_init(); + // Initialize queues here + queue_init(&s_queue1); + tasks_init_task(task1, TASK_PRIORITY(2), NULL); + tasks_init_task(task2, TASK_PRIORITY(2), NULL); + LOG_DEBUG("Program start...\n"); + tasks_start(); +// LOG_DEBUG("%s\n", s_list[0]); + return 0; +} \ No newline at end of file From c385f7af2ddad1af1a724a53eecea98b99fead5e Mon Sep 17 00:00:00 2001 From: vagrant Date: Fri, 12 May 2023 18:57:18 +0000 Subject: [PATCH 05/31] Task 2 complete(1) --- projects/fw103_taksh/src/queues1.c | 36 +++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index 6b9514f12..ed6b66138 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -1,25 +1,22 @@ #include #include + #include "FreeRTOS.h" -#include "tasks.h" -#include "queues.h" -#include "status.h" #include "delay.h" #include "log.h" #include "misc.h" +#include "queues.h" +#include "status.h" #include "string.h" +#include "tasks.h" #define ITEM_SZ 6 #define QUEUE_LEN 5 #define BUF_SIZE (QUEUE_LEN * ITEM_SZ) #define code 'STATUS_CODE_OK' -static const char s_list[QUEUE_LEN][ITEM_SZ] = { - "Item1", - "Item2", - "Item3", - "Item4", - "Item5" -}; +static const char s_list[QUEUE_LEN][ITEM_SZ] = { + "Item1", "Item2", "Item3", "Item4", "Item5" + }; // Task static entities static uint8_t s_queue1_buf[BUF_SIZE]; static Queue s_queue1 = { @@ -35,15 +32,13 @@ TASK(task1, TASK_STACK_512) { int i = 0; while (true) { // Your code goes here - strcpy(&to_send, s_list[0]); + strcpy(&to_send, s_list[i]); i++; - if(i == QUEUE_LEN) { - i = 0; - } + i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); delay_ms(100); - if (ret != 0) { - LOG_DEBUG("write to queue failed"); + if (ret != STATUS_CODE_OK) { + LOG_DEBUG("write to queue failed"); } } } @@ -54,15 +49,14 @@ TASK(task2, TASK_STACK_512) { while (true) { // Your code goes here ret = queue_receive(&s_queue1, (char *)&outstr, 0); - if (ret == 0) { - LOG_DEBUG("%s\n", outstr); + if (ret == STATUS_CODE_OK) { + LOG_DEBUG("%s\n", outstr); } else { - LOG_DEBUG("read from queue failed"); + LOG_DEBUG("read from queue failed"); } } } int main(void) { - log_init(); // Initialize queues here queue_init(&s_queue1); @@ -70,6 +64,6 @@ int main(void) { tasks_init_task(task2, TASK_PRIORITY(2), NULL); LOG_DEBUG("Program start...\n"); tasks_start(); -// LOG_DEBUG("%s\n", s_list[0]); + // LOG_DEBUG("%s\n", s_list[0]); return 0; } \ No newline at end of file From e598d03f96deac33c926ef51303d0581469e8b46 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 01:16:18 +0000 Subject: [PATCH 06/31] Task 2 complete(with lint) --- projects/fw103_taksh/src/queues1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index ed6b66138..d670a3773 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -14,8 +14,8 @@ #define QUEUE_LEN 5 #define BUF_SIZE (QUEUE_LEN * ITEM_SZ) #define code 'STATUS_CODE_OK' -static const char s_list[QUEUE_LEN][ITEM_SZ] = { - "Item1", "Item2", "Item3", "Item4", "Item5" +static const char s_list[QUEUE_LEN][ITEM_SZ] = { + "Item1", "Item2", "Item3", "Item4", "Item5" }; // Task static entities static uint8_t s_queue1_buf[BUF_SIZE]; @@ -66,4 +66,4 @@ int main(void) { tasks_start(); // LOG_DEBUG("%s\n", s_list[0]); return 0; -} \ No newline at end of file +} From be4182d88e321ceb8a040e395f76acf9c5092493 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 02:05:01 +0000 Subject: [PATCH 07/31] Task 2 complete(linting done) --- projects/fw103_taksh/src/queues1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index d670a3773..d7b5d1560 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -28,11 +28,12 @@ static Queue s_queue1 = { TASK(task1, TASK_STACK_512) { LOG_DEBUG("Task 1 initialized!\n"); StatusCode ret; - char to_send = ' '; + char to_send = [50]; int i = 0; while (true) { // Your code goes here - strcpy(&to_send, s_list[i]); + // strcpy(&to_send, s_list[i]); + snprintf(to_send, sizeof(to_send), s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From d2f7f36b241bf30c7ad156cb95ea20f0f9645ac8 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 02:19:28 +0000 Subject: [PATCH 08/31] Task 2 complete(2) --- projects/fw103_taksh/src/queues1.c | 4 +-- projects/fw103_taksh/src/tasks/tasks.c | 50 +++++++++++++------------- projects/hello_world/src/main.c | 48 ++++++++++--------------- 3 files changed, 44 insertions(+), 58 deletions(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index d7b5d1560..5707a2c62 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -14,9 +14,7 @@ #define QUEUE_LEN 5 #define BUF_SIZE (QUEUE_LEN * ITEM_SZ) #define code 'STATUS_CODE_OK' -static const char s_list[QUEUE_LEN][ITEM_SZ] = { - "Item1", "Item2", "Item3", "Item4", "Item5" - }; +static const char s_list[QUEUE_LEN][ITEM_SZ] = { "Item1", "Item2", "Item3", "Item4", "Item5" }; // Task static entities static uint8_t s_queue1_buf[BUF_SIZE]; static Queue s_queue1 = { diff --git a/projects/fw103_taksh/src/tasks/tasks.c b/projects/fw103_taksh/src/tasks/tasks.c index 4955d5a6d..a367916ec 100644 --- a/projects/fw103_taksh/src/tasks/tasks.c +++ b/projects/fw103_taksh/src/tasks/tasks.c @@ -1,13 +1,13 @@ +#include "tasks.h" + #include #include #include "FreeRTOS.h" -#include "tasks.h" - +#include "delay.h" #include "gpio.h" #include "log.h" #include "misc.h" -#include "delay.h" // Non blocking delay. Simply consumes cpu cycles until a given time has passed // static void prv_delay(const TickType_t delay_ms) { @@ -19,35 +19,35 @@ TASK(task1, TASK_STACK_512) { int counter1 = 0; while (true) { - // Your code here - LOG_DEBUG("TASK 1- %s, %d", task1->name, counter1); - counter1++; - // prv_delay(1000); - delay_ms(1000); + // Your code here + LOG_DEBUG("TASK 1- %s, %d", task1->name, counter1); + counter1++; + // prv_delay(1000); + delay_ms(1000); } } TASK(task2, TASK_STACK_512) { int counter2 = 0; while (true) { - // Your code here - LOG_DEBUG("TASK 2- %s, %d", task2->name, counter2); - counter2++; - // prv_delay(1000); - delay_ms(1000); + // Your code here + LOG_DEBUG("TASK 2- %s, %d", task2->name, counter2); + counter2++; + // prv_delay(1000); + delay_ms(1000); } } int main(void) { - log_init(); - // Create tasks here - tasks_init(); - tasks_init_task(task1, TASK_PRIORITY(1), NULL); - tasks_init_task(task2, TASK_PRIORITY(2), NULL); - - LOG_DEBUG("Program start...\n"); - // Start the scheduler - tasks_start(); - - return 0; -} \ No newline at end of file + log_init(); + // Create tasks here + tasks_init(); + tasks_init_task(task1, TASK_PRIORITY(1), NULL); + tasks_init_task(task2, TASK_PRIORITY(2), NULL); + + LOG_DEBUG("Program start...\n"); + // Start the scheduler + tasks_start(); + + return 0; +} diff --git a/projects/hello_world/src/main.c b/projects/hello_world/src/main.c index 0c3f628d7..636f6deff 100644 --- a/projects/hello_world/src/main.c +++ b/projects/hello_world/src/main.c @@ -9,44 +9,32 @@ #define MASTER_MS_CYCLE_TIME 1000 #endif -void run_fast_cycle() -{ +void run_fast_cycle() {} -} - -void run_medium_cycle() -{ - -} +void run_medium_cycle() {} -void run_slow_cycle() -{ - -} +void run_slow_cycle() {} TASK(master_task, TASK_MIN_STACK_SIZE) { - int counter = 0; - while (true) { - run_fast_cycle(); - if (!(counter%10)) - run_medium_cycle(); - if (!(counter%100)) - run_slow_cycle(); - vTaskDelay(pdMS_TO_TICKS(1000)); - ++counter; - } + int counter = 0; + while (true) { + run_fast_cycle(); + if (!(counter % 10)) run_medium_cycle(); + if (!(counter % 100)) run_slow_cycle(); + vTaskDelay(pdMS_TO_TICKS(1000)); + ++counter; + } } int main() { - tasks_init(); - log_init(); - LOG_DEBUG("Welcome to TEST!"); + tasks_init(); + log_init(); + LOG_DEBUG("Welcome to TEST!"); - tasks_init_task(master_task, TASK_PRIORITY(2), NULL); + tasks_init_task(master_task, TASK_PRIORITY(2), NULL); - tasks_start(); + tasks_start(); - LOG_DEBUG("exiting main?"); - return 0; + LOG_DEBUG("exiting main?"); + return 0; } - From fa252042e0c0087d268f529f32d85ae39d098ebc Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 02:34:52 +0000 Subject: [PATCH 09/31] Task 2 complete(2) --- projects/fw103_taksh/src/queues1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index 5707a2c62..dc71a81d9 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -26,12 +26,12 @@ static Queue s_queue1 = { TASK(task1, TASK_STACK_512) { LOG_DEBUG("Task 1 initialized!\n"); StatusCode ret; - char to_send = [50]; + char to_send[50]; int i = 0; while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(to_send, sizeof(to_send), s_list[i]); + snprintf(&to_send, sizeof(to_send), &s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From 645f09d2d11bfb421ba90ac201b304271a9f5609 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 02:49:04 +0000 Subject: [PATCH 10/31] Task 2 complete(2) --- projects/fw103_taksh/src/queues1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index dc71a81d9..ed2b535a3 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -26,12 +26,12 @@ static Queue s_queue1 = { TASK(task1, TASK_STACK_512) { LOG_DEBUG("Task 1 initialized!\n"); StatusCode ret; - char to_send[50]; + char to_send = ' '; int i = 0; while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(&to_send, sizeof(to_send), &s_list[i]); + snprintf(to_send, sizeof(to_send), s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From 885badb986ddf2e6ff18170ae905096350a0ae7c Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 03:06:31 +0000 Subject: [PATCH 11/31] Task 2 complete(2) --- projects/fw103_taksh/src/queues1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index ed2b535a3..277e89379 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -31,7 +31,7 @@ TASK(task1, TASK_STACK_512) { while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(to_send, sizeof(to_send), s_list[i]); + snprintf(&to_send, sizeof(to_send), s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From 1201d86c9868b97f5cce2a0dd975a4a06f32927f Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 04:04:45 +0000 Subject: [PATCH 12/31] Task 2 complete(2) --- projects/fw103_taksh/src/queues1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index 277e89379..fd648a064 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -31,7 +31,7 @@ TASK(task1, TASK_STACK_512) { while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(&to_send, sizeof(to_send), s_list[i]); + snprintf(&to_send, sizeof(to_send), &s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From b82110e886468b01a288f54e80cf777c791ccf3e Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 04:43:31 +0000 Subject: [PATCH 13/31] Task 2 complete(2) --- projects/fw103_taksh/src/queues1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index fd648a064..1bba26a15 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -31,7 +31,7 @@ TASK(task1, TASK_STACK_512) { while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(&to_send, sizeof(to_send), &s_list[i]); + snprintf(&to_send, sizeof(to_send), (char *)s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From 55146db62945ce09d615fbc3d27e4ae8da500943 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 13:03:17 +0000 Subject: [PATCH 14/31] Task 2 Complete(2) --- projects/fw103_taksh/src/queues1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index 1bba26a15..2bb987a4d 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -31,7 +31,7 @@ TASK(task1, TASK_STACK_512) { while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(&to_send, sizeof(to_send), (char *)s_list[i]); + snprintf(&to_send, sizeof(to_send), "%s",s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From a0a283471d250eaae434c228f6711f06a7b62709 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 13 May 2023 13:12:24 +0000 Subject: [PATCH 15/31] Task 2 Complete(2) --- projects/fw103_taksh/src/queues1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c index 2bb987a4d..321cfa781 100644 --- a/projects/fw103_taksh/src/queues1.c +++ b/projects/fw103_taksh/src/queues1.c @@ -31,7 +31,7 @@ TASK(task1, TASK_STACK_512) { while (true) { // Your code goes here // strcpy(&to_send, s_list[i]); - snprintf(&to_send, sizeof(to_send), "%s",s_list[i]); + snprintf(&to_send, sizeof(to_send), "%s", s_list[i]); i++; i = i % QUEUE_LEN; ret = queue_send(&s_queue1, &to_send, 0); From 9f410136218f52976dfa6d1e72aa855383a6cac7 Mon Sep 17 00:00:00 2001 From: Taksh-041102 Date: Wed, 14 Jun 2023 15:44:21 -0400 Subject: [PATCH 16/31] uv_cutoff smoke tests ready for eval --- smoke/uv_cutoff/src/main.c | 135 +++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 smoke/uv_cutoff/src/main.c diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c new file mode 100644 index 000000000..55f7dd07a --- /dev/null +++ b/smoke/uv_cutoff/src/main.c @@ -0,0 +1,135 @@ +#include + +#include "can.h" +#include "gpio.h" +#include "can_board_ids.h" +#include "delay.h" +#include "interrupt.h" +#include "log.h" +#include "misc.h" +#include "soft_timer.h" +#include "tasks.h" +#include "uv_cutoff.h" +#include "uv_cutoff_getters.h" +#include "uv_cutoff_setters.h" + +// TODO(devAdhiraj): update with actual ports and pins +#define UV_CUTOFF_PORT GPIO_PORT_A +#define UV_CUTOFF_PIN 5 + +#define HORN_PORT GPIO_PORT_A +#define HORN_PIN 5 + +#define LIGHTS_PORT GPIO_PORT_A +#define LIGHTS_PIN 5 + +static const GpioAddress uv_status = { .port = UV_CUTOFF_PORT, .pin = UV_CUTOFF_PIN }; + +static const GpioAddress horn = { .port = HORN_PORT, .pin = HORN_PIN }; + +static const GpioAddress lights = { .port = LIGHTS_PORT, .pin = LIGHTS_PIN }; + + +static UVCutoffState state = UV_CUTOFF_ACTIVE; + +void uv_smoke_logic() { + GpioState uv_value; + + if (gpio_get_state(&uv_status, &uv_value) != STATUS_CODE_OK) { + LOG_CRITICAL("Error reading UV_cutoff pin!\n"); + return; + } + if (uv_value == GPIO_STATE_LOW) { + state = UV_CUTOFF_DISCONNECTED; + } else { + state = UV_CUTOFF_ACTIVE; + } + + set_uv_cutoff_notification_signal1(state); + + if (state == UV_CUTOFF_DISCONNECTED) { + return; + } + StatusCode status; + GpioState state_val; + + if (get_horn_and_lights_horn_state()) { + assert ( status = gpio_set_state(&horn, GPIO_STATE_HIGH) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Horn State could not be set to high\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&horn, &state_val); + if( state_val != GPIO_STATE_HIGH) { + LOG_DEBUG("Horn State not set correctly\n") + } else if (state_val == GPIO_STATE_HIGH) { + LOG_DEBUG("Horn State set correctly\n"); + } + } + } else { + assert ( status = gpio_set_state(&horn, GPIO_STATE_LOW) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Horn State could not be set to low\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&horn, &state_val); + if( state_val != GPIO_STATE_LOW) { + LOG_DEBUG("Horn State not set correctly\n") + } else if (state_val == GPIO_STATE_LOW) { + LOG_DEBUG("Horn state set correctly\n"); + } + } + + } + + if (get_horn_and_lights_lights_state()) { + assert ( status = gpio_set_state(&lights, GPIO_STATE_HIGH) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Lights State could not be set to high\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&lights, &state_val); + if(state_Val != GPIO_STATE_HIGH) { + LOG_DEBUG("Lights State not set correctly\n"); + } else if (state_val == GPIO_STATE_HIGH) { + LOG_DEBUG("Lights State set correctly\n") + } + } + + } else { + assert ( status = gpio_set_state(&lights, GPIO_STATE_LOW) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Lights State could not be set to low\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&lights, &state_val); + if(state_val != GPIO_STATE_LOW) { + LOG_DEBUG("Lights State not set correctly\n"); + } else if (state_val == GPIO_STATE_LOW) { + LOG_DEBUG("Lights State set correctly\n"); + } + } + } +} + +TASK(smoke_task, TASK_MIN_STACK_SIZE) { + uv_smoke_logic(); +} + +int main() { + tasks_init(); + log_init(); + + gpio_init(); + + gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); + gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); + gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); + + tasks_init_task(smoke_task, TASK_PRIORITY(1), NULL); + + tasks_start(); + + LOG_DEBUG("UV cutoff task!\n"); + return 0; +} \ No newline at end of file From 89e883e9fc909fd5c3429d422b68fe559992845e Mon Sep 17 00:00:00 2001 From: vagrant Date: Wed, 14 Jun 2023 19:56:35 +0000 Subject: [PATCH 17/31] uv_cutoff smoke tests ready for eval --- smoke/uv_cutoff/src/main.c | 270 ++++++++++++++++++------------------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 55f7dd07a..f1e55a4de 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -1,135 +1,135 @@ -#include - -#include "can.h" -#include "gpio.h" -#include "can_board_ids.h" -#include "delay.h" -#include "interrupt.h" -#include "log.h" -#include "misc.h" -#include "soft_timer.h" -#include "tasks.h" -#include "uv_cutoff.h" -#include "uv_cutoff_getters.h" -#include "uv_cutoff_setters.h" - -// TODO(devAdhiraj): update with actual ports and pins -#define UV_CUTOFF_PORT GPIO_PORT_A -#define UV_CUTOFF_PIN 5 - -#define HORN_PORT GPIO_PORT_A -#define HORN_PIN 5 - -#define LIGHTS_PORT GPIO_PORT_A -#define LIGHTS_PIN 5 - -static const GpioAddress uv_status = { .port = UV_CUTOFF_PORT, .pin = UV_CUTOFF_PIN }; - -static const GpioAddress horn = { .port = HORN_PORT, .pin = HORN_PIN }; - -static const GpioAddress lights = { .port = LIGHTS_PORT, .pin = LIGHTS_PIN }; - - -static UVCutoffState state = UV_CUTOFF_ACTIVE; - -void uv_smoke_logic() { - GpioState uv_value; - - if (gpio_get_state(&uv_status, &uv_value) != STATUS_CODE_OK) { - LOG_CRITICAL("Error reading UV_cutoff pin!\n"); - return; - } - if (uv_value == GPIO_STATE_LOW) { - state = UV_CUTOFF_DISCONNECTED; - } else { - state = UV_CUTOFF_ACTIVE; - } - - set_uv_cutoff_notification_signal1(state); - - if (state == UV_CUTOFF_DISCONNECTED) { - return; - } - StatusCode status; - GpioState state_val; - - if (get_horn_and_lights_horn_state()) { - assert ( status = gpio_set_state(&horn, GPIO_STATE_HIGH) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Horn State could not be set to high\n"); - } - else if (status == STATUS_CODE_OK) { - gpio_get_state(&horn, &state_val); - if( state_val != GPIO_STATE_HIGH) { - LOG_DEBUG("Horn State not set correctly\n") - } else if (state_val == GPIO_STATE_HIGH) { - LOG_DEBUG("Horn State set correctly\n"); - } - } - } else { - assert ( status = gpio_set_state(&horn, GPIO_STATE_LOW) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Horn State could not be set to low\n"); - } - else if (status == STATUS_CODE_OK) { - gpio_get_state(&horn, &state_val); - if( state_val != GPIO_STATE_LOW) { - LOG_DEBUG("Horn State not set correctly\n") - } else if (state_val == GPIO_STATE_LOW) { - LOG_DEBUG("Horn state set correctly\n"); - } - } - - } - - if (get_horn_and_lights_lights_state()) { - assert ( status = gpio_set_state(&lights, GPIO_STATE_HIGH) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Lights State could not be set to high\n"); - } - else if (status == STATUS_CODE_OK) { - gpio_get_state(&lights, &state_val); - if(state_Val != GPIO_STATE_HIGH) { - LOG_DEBUG("Lights State not set correctly\n"); - } else if (state_val == GPIO_STATE_HIGH) { - LOG_DEBUG("Lights State set correctly\n") - } - } - - } else { - assert ( status = gpio_set_state(&lights, GPIO_STATE_LOW) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Lights State could not be set to low\n"); - } - else if (status == STATUS_CODE_OK) { - gpio_get_state(&lights, &state_val); - if(state_val != GPIO_STATE_LOW) { - LOG_DEBUG("Lights State not set correctly\n"); - } else if (state_val == GPIO_STATE_LOW) { - LOG_DEBUG("Lights State set correctly\n"); - } - } - } -} - -TASK(smoke_task, TASK_MIN_STACK_SIZE) { - uv_smoke_logic(); -} - -int main() { - tasks_init(); - log_init(); - - gpio_init(); - - gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); - gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); - gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); - - tasks_init_task(smoke_task, TASK_PRIORITY(1), NULL); - - tasks_start(); - - LOG_DEBUG("UV cutoff task!\n"); - return 0; -} \ No newline at end of file +#include + +// #include "can.h" +#include "gpio.h" +#include "can_board_ids.h" +#include "delay.h" +#include "interrupt.h" +#include "log.h" +#include "misc.h" +#include "soft_timer.h" +#include "tasks.h" +#include "uv_cutoff.h" +#include "uv_cutoff_getters.h" +#include "uv_cutoff_setters.h" + +// TODO(devAdhiraj): update with actual ports and pins +#define UV_CUTOFF_PORT GPIO_PORT_A +#define UV_CUTOFF_PIN 5 + +#define HORN_PORT GPIO_PORT_A +#define HORN_PIN 5 + +#define LIGHTS_PORT GPIO_PORT_A +#define LIGHTS_PIN 5 + +static const GpioAddress uv_status = { .port = UV_CUTOFF_PORT, .pin = UV_CUTOFF_PIN }; + +static const GpioAddress horn = { .port = HORN_PORT, .pin = HORN_PIN }; + +static const GpioAddress lights = { .port = LIGHTS_PORT, .pin = LIGHTS_PIN }; + + +static UVCutoffState state = UV_CUTOFF_ACTIVE; + +void uv_smoke_logic() { + GpioState uv_value; + + if (gpio_get_state(&uv_status, &uv_value) != STATUS_CODE_OK) { + LOG_CRITICAL("Error reading UV_cutoff pin!\n"); + return; + } + if (uv_value == GPIO_STATE_LOW) { + state = UV_CUTOFF_DISCONNECTED; + } else { + state = UV_CUTOFF_ACTIVE; + } + + set_uv_cutoff_notification_signal1(state); + + if (state == UV_CUTOFF_DISCONNECTED) { + return; + } + StatusCode status; + GpioState state_val; + + if (get_horn_and_lights_horn_state()) { + assert ( status = gpio_set_state(&horn, GPIO_STATE_HIGH) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Horn State could not be set to high\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&horn, &state_val); + if( state_val != GPIO_STATE_HIGH) { + LOG_DEBUG("Horn State not set correctly\n") + } else if (state_val == GPIO_STATE_HIGH) { + LOG_DEBUG("Horn State set correctly\n"); + } + } + } else { + assert ( status = gpio_set_state(&horn, GPIO_STATE_LOW) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Horn State could not be set to low\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&horn, &state_val); + if( state_val != GPIO_STATE_LOW) { + LOG_DEBUG("Horn State not set correctly\n") + } else if (state_val == GPIO_STATE_LOW) { + LOG_DEBUG("Horn state set correctly\n"); + } + } + + } + + if (get_horn_and_lights_lights_state()) { + assert ( status = gpio_set_state(&lights, GPIO_STATE_HIGH) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Lights State could not be set to high\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&lights, &state_val); + if(state_Val != GPIO_STATE_HIGH) { + LOG_DEBUG("Lights State not set correctly\n"); + } else if (state_val == GPIO_STATE_HIGH) { + LOG_DEBUG("Lights State set correctly\n") + } + } + + } else { + assert ( status = gpio_set_state(&lights, GPIO_STATE_LOW) ); + if(status != STATUS_CODE_OK) { + LOG_DEBUG("GPIO Lights State could not be set to low\n"); + } + else if (status == STATUS_CODE_OK) { + gpio_get_state(&lights, &state_val); + if(state_val != GPIO_STATE_LOW) { + LOG_DEBUG("Lights State not set correctly\n"); + } else if (state_val == GPIO_STATE_LOW) { + LOG_DEBUG("Lights State set correctly\n"); + } + } + } +} + +TASK(smoke_task, TASK_MIN_STACK_SIZE) { + uv_smoke_logic(); +} + +int main() { + tasks_init(); + log_init(); + + gpio_init(); + + gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); + gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); + gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); + + tasks_init_task(smoke_task, TASK_PRIORITY(1), NULL); + + tasks_start(); + + LOG_DEBUG("UV cutoff task!\n"); + return 0; +} From 11ef0b17b05b2be1a247ef883915421c0ab1f5e2 Mon Sep 17 00:00:00 2001 From: Taksh-041102 Date: Wed, 14 Jun 2023 16:09:40 -0400 Subject: [PATCH 18/31] uv_cutoff smoke tests ready for eval --- smoke/uv_cutoff/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index f1e55a4de..73aa477bf 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -1,6 +1,6 @@ #include -// #include "can.h" +#include "..\can\inc\can.h" #include "gpio.h" #include "can_board_ids.h" #include "delay.h" @@ -9,7 +9,7 @@ #include "misc.h" #include "soft_timer.h" #include "tasks.h" -#include "uv_cutoff.h" +#include "..\projects\uv_cutoff\inc\uv_cutoff.h" #include "uv_cutoff_getters.h" #include "uv_cutoff_setters.h" From 806b8450ac68d4672141b415e72607eb4d6cc5ef Mon Sep 17 00:00:00 2001 From: Taksh-041102 Date: Wed, 14 Jun 2023 16:26:02 -0400 Subject: [PATCH 19/31] uv_cutoff smoke tests ready for eval --- smoke/uv_cutoff/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 73aa477bf..1aa00e54b 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -1,6 +1,6 @@ #include -#include "..\can\inc\can.h" +// #include "can.h" #include "gpio.h" #include "can_board_ids.h" #include "delay.h" From a212c6dbdf123fb97ff2b5abaf520433f22afd49 Mon Sep 17 00:00:00 2001 From: vagrant Date: Wed, 14 Jun 2023 21:36:53 +0000 Subject: [PATCH 20/31] uv_cutoff smoke tests ready for eval --- projects/uv_cutoff/inc/uv_cutoff.h | 3 +++ projects/uv_cutoff/src/main.c | 2 +- smoke/uv_cutoff/src/main.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/projects/uv_cutoff/inc/uv_cutoff.h b/projects/uv_cutoff/inc/uv_cutoff.h index 07d49b0ed..0726387d3 100644 --- a/projects/uv_cutoff/inc/uv_cutoff.h +++ b/projects/uv_cutoff/inc/uv_cutoff.h @@ -4,3 +4,6 @@ typedef enum UVCutoffState { UV_CUTOFF_ACTIVE = 0, UV_CUTOFF_DISCONNECTED, } UVCutoffState; + +void uv_ligc () {}; + diff --git a/projects/uv_cutoff/src/main.c b/projects/uv_cutoff/src/main.c index 73b26dcda..b6bcceb6a 100644 --- a/projects/uv_cutoff/src/main.c +++ b/projects/uv_cutoff/src/main.c @@ -54,7 +54,7 @@ void uv_logic() { } if (uv_value == GPIO_STATE_LOW) { state = UV_CUTOFF_DISCONNECTED; - } else { + } else { state = UV_CUTOFF_ACTIVE; } diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 1aa00e54b..99933831c 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -1,6 +1,6 @@ #include -// #include "can.h" +#include "can.h" #include "gpio.h" #include "can_board_ids.h" #include "delay.h" @@ -9,7 +9,7 @@ #include "misc.h" #include "soft_timer.h" #include "tasks.h" -#include "..\projects\uv_cutoff\inc\uv_cutoff.h" +#include "uv_cutoff.h" #include "uv_cutoff_getters.h" #include "uv_cutoff_setters.h" @@ -113,7 +113,14 @@ void uv_smoke_logic() { } TASK(smoke_task, TASK_MIN_STACK_SIZE) { + + //TEST 1 - Disconnected UV status + gpio_set_state(&uv_status,GPIO_STATE_LOW); uv_smoke_logic(); + assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_DISCONNECTED ); + + //TEST 2 - + } int main() { From 1a4b89887d8db74ffb38d43bf6f62a066ea36a65 Mon Sep 17 00:00:00 2001 From: JarvisWeng Date: Thu, 15 Jun 2023 17:47:15 -0400 Subject: [PATCH 21/31] fixed up scons --- scons/build.scons | 15 +++++++++++---- smoke/uv_cutoff/config.json | 10 ++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 smoke/uv_cutoff/config.json diff --git a/scons/build.scons b/scons/build.scons index 919dc0f23..6d6ba136b 100644 --- a/scons/build.scons +++ b/scons/build.scons @@ -58,9 +58,12 @@ def proj_bin(proj_name, is_smoke=False): ########################################################### # Header file generation from jinja templates ########################################################### -def generate_can_files(env, target=[], source=[], project=TARGET): +def generate_can_files(env, target=[], source=[], project=TARGET, is_smoke=False): source_yaml = BOARDS_DIR.File(project + ".yaml") - project_can_dir = OBJ_DIR.Dir("projects").Dir(project).Dir("can") + if is_smoke: + project_can_dir = OBJ_DIR.Dir("smoke").Dir(project).Dir("can") + else: + project_can_dir = OBJ_DIR.Dir("projects").Dir(project).Dir("can") source_dir = project_can_dir.Dir("src") header_dir = project_can_dir.Dir("inc") source += [BOARDS_DIR, TEMPLATES_DIR, GENERATOR] @@ -126,15 +129,19 @@ for entry in PROJ_DIRS + LIB_DIRS + SMOKE_DIRS: config = parse_config(entry) if config["can"]: + is_smoke = entry in SMOKE_DIRS can_location_name = entry.name if (entry.name == "power_distribution"): can_location_name += "_" + str(GetOption("location")) # Add Autogenerated files - can_sources, can_header_dir = generate_can_files(env, project=can_location_name) + can_sources, can_header_dir = generate_can_files(env, project=can_location_name, is_smoke=is_smoke) srcs += can_sources inc_dirs.append(can_header_dir) - + + if "include" in config: + for i in config["include"]: + inc_dirs.append(Dir(i)) # Glob the source files from OBJ_DIR because it's a variant dir # See: https://scons.org/doc/1.2.0/HTML/scons-user/x3346.html diff --git a/smoke/uv_cutoff/config.json b/smoke/uv_cutoff/config.json new file mode 100644 index 000000000..e617f0cb9 --- /dev/null +++ b/smoke/uv_cutoff/config.json @@ -0,0 +1,10 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common" + ], + "include": [ + "#/projects/uv_cutoff/inc" + ], + "can": true +} \ No newline at end of file From 24d23286be35a5e9faf3ab1cc652ffc47f4678b4 Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 20 Jun 2023 00:12:31 +0000 Subject: [PATCH 22/31] uv_cutoff smoke tests --- smoke/uv_cutoff/config.json | 7 ++ smoke/uv_cutoff/src/main.c | 127 +++++++++++++++++++++++------------- 2 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 smoke/uv_cutoff/config.json diff --git a/smoke/uv_cutoff/config.json b/smoke/uv_cutoff/config.json new file mode 100644 index 000000000..8f09bcd55 --- /dev/null +++ b/smoke/uv_cutoff/config.json @@ -0,0 +1,7 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common" + ], + "can": true +} \ No newline at end of file diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 99933831c..808f95488 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -29,6 +29,9 @@ static const GpioAddress horn = { .port = HORN_PORT, .pin = HORN_PIN }; static const GpioAddress lights = { .port = LIGHTS_PORT, .pin = LIGHTS_PIN }; + StatusCode status; + GpioState state_val; + int lights_check = 0; static UVCutoffState state = UV_CUTOFF_ACTIVE; @@ -50,64 +53,63 @@ void uv_smoke_logic() { if (state == UV_CUTOFF_DISCONNECTED) { return; } - StatusCode status; - GpioState state_val; + - if (get_horn_and_lights_horn_state()) { - assert ( status = gpio_set_state(&horn, GPIO_STATE_HIGH) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Horn State could not be set to high\n"); - } - else if (status == STATUS_CODE_OK) { + if (get_horn_and_lights_horn_state() && !lights_check) { + status = gpio_set_state(&horn, GPIO_STATE_HIGH); + // if(status != STATUS_CODE_OK) { + // LOG_DEBUG("GPIO Horn State could not be set to high\n"); + // } + if (status == STATUS_CODE_OK) { gpio_get_state(&horn, &state_val); - if( state_val != GPIO_STATE_HIGH) { - LOG_DEBUG("Horn State not set correctly\n") - } else if (state_val == GPIO_STATE_HIGH) { - LOG_DEBUG("Horn State set correctly\n"); - } + // if( state_val != GPIO_STATE_HIGH) { + // LOG_DEBUG("Horn State not set correctly\n") + // } else if (state_val == GPIO_STATE_HIGH) { + // LOG_DEBUG("Horn State set correctly\n"); + // } } } else { - assert ( status = gpio_set_state(&horn, GPIO_STATE_LOW) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Horn State could not be set to low\n"); - } - else if (status == STATUS_CODE_OK) { + status = gpio_set_state(&horn, GPIO_STATE_LOW); + // if(status != STATUS_CODE_OK) { + // LOG_DEBUG("GPIO Horn State could not be set to low\n"); + // } + if (status == STATUS_CODE_OK) { gpio_get_state(&horn, &state_val); - if( state_val != GPIO_STATE_LOW) { - LOG_DEBUG("Horn State not set correctly\n") - } else if (state_val == GPIO_STATE_LOW) { - LOG_DEBUG("Horn state set correctly\n"); - } + // if( state_val != GPIO_STATE_LOW) { + // LOG_DEBUG("Horn State not set correctly\n") + // } else if (state_val == GPIO_STATE_LOW) { + // LOG_DEBUG("Horn state set correctly\n"); + // } } } - if (get_horn_and_lights_lights_state()) { - assert ( status = gpio_set_state(&lights, GPIO_STATE_HIGH) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Lights State could not be set to high\n"); - } - else if (status == STATUS_CODE_OK) { + if (get_horn_and_lights_lights_state() && lights_check) { + status = gpio_set_state(&lights, GPIO_STATE_HIGH); + // if(status != STATUS_CODE_OK) { + // LOG_DEBUG("GPIO Lights State could not be set to high\n"); + // } + if (status == STATUS_CODE_OK) { gpio_get_state(&lights, &state_val); - if(state_Val != GPIO_STATE_HIGH) { - LOG_DEBUG("Lights State not set correctly\n"); - } else if (state_val == GPIO_STATE_HIGH) { - LOG_DEBUG("Lights State set correctly\n") - } + // if(state_Val != GPIO_STATE_HIGH) { + // LOG_DEBUG("Lights State not set correctly\n"); + // } else if (state_val == GPIO_STATE_HIGH) { + // LOG_DEBUG("Lights State set correctly\n") + // } } } else { - assert ( status = gpio_set_state(&lights, GPIO_STATE_LOW) ); - if(status != STATUS_CODE_OK) { - LOG_DEBUG("GPIO Lights State could not be set to low\n"); - } - else if (status == STATUS_CODE_OK) { + status = gpio_set_state(&lights, GPIO_STATE_LOW); + // if(status != STATUS_CODE_OK) { + // LOG_DEBUG("GPIO Lights State could not be set to low\n"); + // } + if (status == STATUS_CODE_OK) { gpio_get_state(&lights, &state_val); - if(state_val != GPIO_STATE_LOW) { - LOG_DEBUG("Lights State not set correctly\n"); - } else if (state_val == GPIO_STATE_LOW) { - LOG_DEBUG("Lights State set correctly\n"); - } + // if(state_val != GPIO_STATE_LOW) { + // LOG_DEBUG("Lights State not set correctly\n"); + // } else if (state_val == GPIO_STATE_LOW) { + // LOG_DEBUG("Lights State set correctly\n"); + // } } } } @@ -118,9 +120,40 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { gpio_set_state(&uv_status,GPIO_STATE_LOW); uv_smoke_logic(); assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_DISCONNECTED ); - - //TEST 2 - - + LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_DISCONNECTED'\n"); + //TEST 2 - Active UV status + gpio_set_state(&uv_status,GPIO_STATE_HIGH); + uv_smoke_logic(); + assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_ACTIVE ); + LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_ACTIVE'\n"); + //TEST 3 - Horn state HIGH + gpio_set_state(&uv_status,GPIO_STATE_HIGH); + gpio_set_state(&horn,GPIO_STATE_HIGH); + lights_check = 0; + uv_smoke_logic(); + assert(status == STATUS_CODE_OK); + assert(state_val == GPIO_STATE_HIGH); + //TEST 4 - Lights state HIGH + gpio_set_state(&uv_status,GPIO_STATE_HIGH); + gpio_set_state(&lights,GPIO_STATE_HIGH); + lights_check = 1; + uv_smoke_logic(); + assert(status == STATUS_CODE_OK); + assert(state_val == GPIO_STATE_HIGH); + //TEST 5 - Horn state LOW + gpio_set_state(&uv_status,GPIO_STATE_HIGH); + gpio_set_state(&horn,GPIO_STATE_LOw); + lights_check = 0; + uv_smoke_logic(); + assert(status == STATUS_CODE_OK); + assert(state_val == GPIO_STATE_LOW); + //TEST 6 - Lights state LOW + gpio_set_state(&uv_status,GPIO_STATE_HIGH); + gpio_set_state(&lights,GPIO_STATE_LOw); + lights_check = 1; + uv_smoke_logic(); + assert(status == STATUS_CODE_OK); + assert(state_val == GPIO_STATE_LOW); } int main() { From 5908678001d07088e55d822553878aa2dc790be8 Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 20 Jun 2023 15:00:29 +0000 Subject: [PATCH 23/31] uv_cutoff smoke tests --- projects/uv_cutoff/inc/uv_cutoff.h | 2 +- projects/uv_cutoff/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/uv_cutoff/inc/uv_cutoff.h b/projects/uv_cutoff/inc/uv_cutoff.h index 0726387d3..60265bd45 100644 --- a/projects/uv_cutoff/inc/uv_cutoff.h +++ b/projects/uv_cutoff/inc/uv_cutoff.h @@ -5,5 +5,5 @@ typedef enum UVCutoffState { UV_CUTOFF_DISCONNECTED, } UVCutoffState; -void uv_ligc () {}; +void uv_ligc() {} diff --git a/projects/uv_cutoff/src/main.c b/projects/uv_cutoff/src/main.c index b6bcceb6a..73b26dcda 100644 --- a/projects/uv_cutoff/src/main.c +++ b/projects/uv_cutoff/src/main.c @@ -54,7 +54,7 @@ void uv_logic() { } if (uv_value == GPIO_STATE_LOW) { state = UV_CUTOFF_DISCONNECTED; - } else { + } else { state = UV_CUTOFF_ACTIVE; } From fff6c9596543841fa43ab197fce6720ba2cdfc5e Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 20 Jun 2023 15:18:27 +0000 Subject: [PATCH 24/31] uv_cutoff smoke tests --- projects/uv_cutoff/inc/uv_cutoff.h | 1 - smoke/uv_cutoff/src/main.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/uv_cutoff/inc/uv_cutoff.h b/projects/uv_cutoff/inc/uv_cutoff.h index 60265bd45..451f9d59a 100644 --- a/projects/uv_cutoff/inc/uv_cutoff.h +++ b/projects/uv_cutoff/inc/uv_cutoff.h @@ -6,4 +6,3 @@ typedef enum UVCutoffState { } UVCutoffState; void uv_ligc() {} - diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 808f95488..070d860ef 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -115,7 +115,7 @@ void uv_smoke_logic() { } TASK(smoke_task, TASK_MIN_STACK_SIZE) { - + // //TEST 1 - Disconnected UV status gpio_set_state(&uv_status,GPIO_STATE_LOW); uv_smoke_logic(); From 182048a80525ff0c0ae4d2fbc3614343695bd62c Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 20 Jun 2023 15:25:46 +0000 Subject: [PATCH 25/31] uv_cutoff smoke tests --- smoke/uv_cutoff/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 070d860ef..56bd890a5 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -142,7 +142,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { assert(state_val == GPIO_STATE_HIGH); //TEST 5 - Horn state LOW gpio_set_state(&uv_status,GPIO_STATE_HIGH); - gpio_set_state(&horn,GPIO_STATE_LOw); + gpio_set_state(&horn,GPIO_STATE_LOW); lights_check = 0; uv_smoke_logic(); assert(status == STATUS_CODE_OK); From d3f4b0d25a36a518042083efb1442ffad20ec008 Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 20 Jun 2023 15:34:22 +0000 Subject: [PATCH 26/31] uv_cutoff smoke tests --- smoke/uv_cutoff/src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 56bd890a5..0b95c2220 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -1,6 +1,7 @@ #include #include "can.h" +#include "assert.h" #include "gpio.h" #include "can_board_ids.h" #include "delay.h" @@ -149,7 +150,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { assert(state_val == GPIO_STATE_LOW); //TEST 6 - Lights state LOW gpio_set_state(&uv_status,GPIO_STATE_HIGH); - gpio_set_state(&lights,GPIO_STATE_LOw); + gpio_set_state(&lights,GPIO_STATE_LOW); lights_check = 1; uv_smoke_logic(); assert(status == STATUS_CODE_OK); From 73f80d0029d801bd938118fa0325dde033bd2093 Mon Sep 17 00:00:00 2001 From: Taksh-041102 Date: Mon, 26 Jun 2023 13:51:40 -0400 Subject: [PATCH 27/31] uv_cutoff smoke tests ready --- projects/fw103_taksh/README.md | 16 ------ projects/fw103_taksh/config.json | 6 --- projects/fw103_taksh/src/queues1.c | 68 -------------------------- projects/fw103_taksh/src/tasks/tasks.c | 53 -------------------- projects/hello_world/README.md | 16 ------ projects/hello_world/config.json | 6 --- projects/hello_world/src/main.c | 40 --------------- 7 files changed, 205 deletions(-) delete mode 100644 projects/fw103_taksh/README.md delete mode 100644 projects/fw103_taksh/config.json delete mode 100644 projects/fw103_taksh/src/queues1.c delete mode 100644 projects/fw103_taksh/src/tasks/tasks.c delete mode 100644 projects/hello_world/README.md delete mode 100644 projects/hello_world/config.json delete mode 100644 projects/hello_world/src/main.c diff --git a/projects/fw103_taksh/README.md b/projects/fw103_taksh/README.md deleted file mode 100644 index 655e7e33a..000000000 --- a/projects/fw103_taksh/README.md +++ /dev/null @@ -1,16 +0,0 @@ - -# fw103_taksh - diff --git a/projects/fw103_taksh/config.json b/projects/fw103_taksh/config.json deleted file mode 100644 index 4019f4748..000000000 --- a/projects/fw103_taksh/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "libs": [ - "FreeRTOS", - "ms-common" - ] -} \ No newline at end of file diff --git a/projects/fw103_taksh/src/queues1.c b/projects/fw103_taksh/src/queues1.c deleted file mode 100644 index 321cfa781..000000000 --- a/projects/fw103_taksh/src/queues1.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include - -#include "FreeRTOS.h" -#include "delay.h" -#include "log.h" -#include "misc.h" -#include "queues.h" -#include "status.h" -#include "string.h" -#include "tasks.h" - -#define ITEM_SZ 6 -#define QUEUE_LEN 5 -#define BUF_SIZE (QUEUE_LEN * ITEM_SZ) -#define code 'STATUS_CODE_OK' -static const char s_list[QUEUE_LEN][ITEM_SZ] = { "Item1", "Item2", "Item3", "Item4", "Item5" }; -// Task static entities -static uint8_t s_queue1_buf[BUF_SIZE]; -static Queue s_queue1 = { - // Add parameters - .num_items = QUEUE_LEN, - .item_size = ITEM_SZ, - .storage_buf = s_queue1_buf, -}; -TASK(task1, TASK_STACK_512) { - LOG_DEBUG("Task 1 initialized!\n"); - StatusCode ret; - char to_send = ' '; - int i = 0; - while (true) { - // Your code goes here - // strcpy(&to_send, s_list[i]); - snprintf(&to_send, sizeof(to_send), "%s", s_list[i]); - i++; - i = i % QUEUE_LEN; - ret = queue_send(&s_queue1, &to_send, 0); - delay_ms(100); - if (ret != STATUS_CODE_OK) { - LOG_DEBUG("write to queue failed"); - } - } -} -TASK(task2, TASK_STACK_512) { - LOG_DEBUG("Task 2 initialized!\n"); - const char outstr[ITEM_SZ]; - StatusCode ret; - while (true) { - // Your code goes here - ret = queue_receive(&s_queue1, (char *)&outstr, 0); - if (ret == STATUS_CODE_OK) { - LOG_DEBUG("%s\n", outstr); - } else { - LOG_DEBUG("read from queue failed"); - } - } -} -int main(void) { - log_init(); - // Initialize queues here - queue_init(&s_queue1); - tasks_init_task(task1, TASK_PRIORITY(2), NULL); - tasks_init_task(task2, TASK_PRIORITY(2), NULL); - LOG_DEBUG("Program start...\n"); - tasks_start(); - // LOG_DEBUG("%s\n", s_list[0]); - return 0; -} diff --git a/projects/fw103_taksh/src/tasks/tasks.c b/projects/fw103_taksh/src/tasks/tasks.c deleted file mode 100644 index a367916ec..000000000 --- a/projects/fw103_taksh/src/tasks/tasks.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "tasks.h" - -#include -#include - -#include "FreeRTOS.h" -#include "delay.h" -#include "gpio.h" -#include "log.h" -#include "misc.h" - -// Non blocking delay. Simply consumes cpu cycles until a given time has passed -// static void prv_delay(const TickType_t delay_ms) { -// TickType_t curr_tick = xTaskGetTickCount(); -// while(xTaskGetTickCount() - curr_tick < pdMS_TO_TICKS(delay_ms)) -// {} -// } - -TASK(task1, TASK_STACK_512) { - int counter1 = 0; - while (true) { - // Your code here - LOG_DEBUG("TASK 1- %s, %d", task1->name, counter1); - counter1++; - // prv_delay(1000); - delay_ms(1000); - } -} - -TASK(task2, TASK_STACK_512) { - int counter2 = 0; - while (true) { - // Your code here - LOG_DEBUG("TASK 2- %s, %d", task2->name, counter2); - counter2++; - // prv_delay(1000); - delay_ms(1000); - } -} - -int main(void) { - log_init(); - // Create tasks here - tasks_init(); - tasks_init_task(task1, TASK_PRIORITY(1), NULL); - tasks_init_task(task2, TASK_PRIORITY(2), NULL); - - LOG_DEBUG("Program start...\n"); - // Start the scheduler - tasks_start(); - - return 0; -} diff --git a/projects/hello_world/README.md b/projects/hello_world/README.md deleted file mode 100644 index ffea5e973..000000000 --- a/projects/hello_world/README.md +++ /dev/null @@ -1,16 +0,0 @@ - -# hello_world - diff --git a/projects/hello_world/config.json b/projects/hello_world/config.json deleted file mode 100644 index 4019f4748..000000000 --- a/projects/hello_world/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "libs": [ - "FreeRTOS", - "ms-common" - ] -} \ No newline at end of file diff --git a/projects/hello_world/src/main.c b/projects/hello_world/src/main.c deleted file mode 100644 index 636f6deff..000000000 --- a/projects/hello_world/src/main.c +++ /dev/null @@ -1,40 +0,0 @@ -#include - -#include "log.h" -#include "tasks.h" - -#ifdef MS_PLATFORM_X86 -#define MASTER_MS_CYCLE_TIME 100 -#else -#define MASTER_MS_CYCLE_TIME 1000 -#endif - -void run_fast_cycle() {} - -void run_medium_cycle() {} - -void run_slow_cycle() {} - -TASK(master_task, TASK_MIN_STACK_SIZE) { - int counter = 0; - while (true) { - run_fast_cycle(); - if (!(counter % 10)) run_medium_cycle(); - if (!(counter % 100)) run_slow_cycle(); - vTaskDelay(pdMS_TO_TICKS(1000)); - ++counter; - } -} - -int main() { - tasks_init(); - log_init(); - LOG_DEBUG("Welcome to TEST!"); - - tasks_init_task(master_task, TASK_PRIORITY(2), NULL); - - tasks_start(); - - LOG_DEBUG("exiting main?"); - return 0; -} From 53a5264128b28b151d977ea0a39091044de7adc6 Mon Sep 17 00:00:00 2001 From: vagrant Date: Mon, 24 Jul 2023 22:00:24 +0000 Subject: [PATCH 28/31] uv_cutoff smoke tests --- smoke/uv_cutoff/src/main.c | 105 ++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 0b95c2220..45dce71c9 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -16,13 +16,13 @@ // TODO(devAdhiraj): update with actual ports and pins #define UV_CUTOFF_PORT GPIO_PORT_A -#define UV_CUTOFF_PIN 5 +#define UV_CUTOFF_PIN 4 -#define HORN_PORT GPIO_PORT_A -#define HORN_PIN 5 +#define HORN_PORT GPIO_PORT_B +#define HORN_PIN 14 -#define LIGHTS_PORT GPIO_PORT_A -#define LIGHTS_PIN 5 +#define LIGHTS_PORT GPIO_PORT_B +#define LIGHTS_PIN 13 static const GpioAddress uv_status = { .port = UV_CUTOFF_PORT, .pin = UV_CUTOFF_PIN }; @@ -54,107 +54,104 @@ void uv_smoke_logic() { if (state == UV_CUTOFF_DISCONNECTED) { return; } - - if (get_horn_and_lights_horn_state() && !lights_check) { + + GpioState horn_val; + gpio_get_state(&horn,&horn_val); + // LOG_DEBUG("Horn actual state = %d\n", horn_val); + if (horn_val == (GpioState) GPIO_STATE_LOW) { status = gpio_set_state(&horn, GPIO_STATE_HIGH); - // if(status != STATUS_CODE_OK) { - // LOG_DEBUG("GPIO Horn State could not be set to high\n"); - // } + g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_HIGH; if (status == STATUS_CODE_OK) { gpio_get_state(&horn, &state_val); - // if( state_val != GPIO_STATE_HIGH) { - // LOG_DEBUG("Horn State not set correctly\n") - // } else if (state_val == GPIO_STATE_HIGH) { - // LOG_DEBUG("Horn State set correctly\n"); - // } } } else { status = gpio_set_state(&horn, GPIO_STATE_LOW); - // if(status != STATUS_CODE_OK) { - // LOG_DEBUG("GPIO Horn State could not be set to low\n"); - // } + g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_LOW; if (status == STATUS_CODE_OK) { gpio_get_state(&horn, &state_val); - // if( state_val != GPIO_STATE_LOW) { - // LOG_DEBUG("Horn State not set correctly\n") - // } else if (state_val == GPIO_STATE_LOW) { - // LOG_DEBUG("Horn state set correctly\n"); - // } } } - if (get_horn_and_lights_lights_state() && lights_check) { - status = gpio_set_state(&lights, GPIO_STATE_HIGH); - // if(status != STATUS_CODE_OK) { - // LOG_DEBUG("GPIO Lights State could not be set to high\n"); - // } - if (status == STATUS_CODE_OK) { - gpio_get_state(&lights, &state_val); - // if(state_Val != GPIO_STATE_HIGH) { - // LOG_DEBUG("Lights State not set correctly\n"); - // } else if (state_val == GPIO_STATE_HIGH) { - // LOG_DEBUG("Lights State set correctly\n") - // } - } - - } else { - status = gpio_set_state(&lights, GPIO_STATE_LOW); - // if(status != STATUS_CODE_OK) { - // LOG_DEBUG("GPIO Lights State could not be set to low\n"); - // } - if (status == STATUS_CODE_OK) { - gpio_get_state(&lights, &state_val); - // if(state_val != GPIO_STATE_LOW) { - // LOG_DEBUG("Lights State not set correctly\n"); - // } else if (state_val == GPIO_STATE_LOW) { - // LOG_DEBUG("Lights State set correctly\n"); - // } + GpioState light_val; + if(lights_check) { + gpio_get_state(&lights, &light_val); + if ( light_val == (GpioState) GPIO_STATE_LOW) { + status = gpio_set_state(&lights, GPIO_STATE_HIGH); + g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_HIGH; + if (status == STATUS_CODE_OK) { + gpio_get_state(&lights, &state_val); + } + + } else { + status = gpio_set_state(&lights, GPIO_STATE_LOW); + g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_LOW; + if (status == STATUS_CODE_OK) { + gpio_get_state(&lights, &state_val); + } } } + } TASK(smoke_task, TASK_MIN_STACK_SIZE) { // //TEST 1 - Disconnected UV status + LOG_DEBUG("Running test for UV Disconnected state\n"); gpio_set_state(&uv_status,GPIO_STATE_LOW); uv_smoke_logic(); assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_DISCONNECTED ); LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_DISCONNECTED'\n"); + delay_ms(1000); //TEST 2 - Active UV status + LOG_DEBUG("Running test for UV Active state\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); uv_smoke_logic(); assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_ACTIVE ); LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_ACTIVE'\n"); + delay_ms(1000); //TEST 3 - Horn state HIGH + LOG_DEBUG("Running test for Horn in state HIGH\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&horn,GPIO_STATE_HIGH); lights_check = 0; uv_smoke_logic(); assert(status == STATUS_CODE_OK); - assert(state_val == GPIO_STATE_HIGH); + assert(state_val == GPIO_STATE_LOW); + LOG_DEBUG("horn state set to LOW\n"); + delay_ms(1000); //TEST 4 - Lights state HIGH + LOG_DEBUG("Running test for Lights in state HIGH\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&lights,GPIO_STATE_HIGH); lights_check = 1; uv_smoke_logic(); assert(status == STATUS_CODE_OK); - assert(state_val == GPIO_STATE_HIGH); + assert(state_val == GPIO_STATE_LOW); + LOG_DEBUG("lights state set to LOW\n"); + delay_ms(1000); //TEST 5 - Horn state LOW + LOG_DEBUG("Running test for Horn in state LOW\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&horn,GPIO_STATE_LOW); lights_check = 0; uv_smoke_logic(); assert(status == STATUS_CODE_OK); - assert(state_val == GPIO_STATE_LOW); + assert(state_val == GPIO_STATE_HIGH); + LOG_DEBUG("horn state set to HIGH\n"); + delay_ms(1000); //TEST 6 - Lights state LOW + LOG_DEBUG("Running test for Lights in state LOW\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&lights,GPIO_STATE_LOW); lights_check = 1; uv_smoke_logic(); assert(status == STATUS_CODE_OK); - assert(state_val == GPIO_STATE_LOW); + assert(state_val == GPIO_STATE_HIGH); + LOG_DEBUG("lights state set to HIGH\n"); + delay_ms(1000); + LOG_DEBUG("All tasks completed!\n"); } int main() { @@ -163,7 +160,7 @@ int main() { gpio_init(); - gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); + gpio_init_pin(&uv_status, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); From 25d1e6705e08848927a03c7d9fbed1b70ec39326 Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 25 Jul 2023 19:01:57 +0000 Subject: [PATCH 29/31] uv cutoff smoke tests done --- projects/uv_cutoff/src/main.c | 2 +- smoke/uv_cutoff/src/main.c | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/projects/uv_cutoff/src/main.c b/projects/uv_cutoff/src/main.c index 73b26dcda..57e203605 100644 --- a/projects/uv_cutoff/src/main.c +++ b/projects/uv_cutoff/src/main.c @@ -108,7 +108,7 @@ int main() { can_init(&s_can_storage, &can_settings); gpio_init(); - gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); + gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 45dce71c9..04e85064a 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -54,39 +54,29 @@ void uv_smoke_logic() { if (state == UV_CUTOFF_DISCONNECTED) { return; } - - - GpioState horn_val; - gpio_get_state(&horn,&horn_val); - // LOG_DEBUG("Horn actual state = %d\n", horn_val); - if (horn_val == (GpioState) GPIO_STATE_LOW) { - status = gpio_set_state(&horn, GPIO_STATE_HIGH); - g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_HIGH; + + if (get_horn_and_lights_horn_state()) { + status = gpio_set_state(&horn, GPIO_STATE_LOW); if (status == STATUS_CODE_OK) { gpio_get_state(&horn, &state_val); } } else { - status = gpio_set_state(&horn, GPIO_STATE_LOW); - g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_LOW; + status = gpio_set_state(&horn, GPIO_STATE_HIGH); if (status == STATUS_CODE_OK) { gpio_get_state(&horn, &state_val); } } - GpioState light_val; if(lights_check) { - gpio_get_state(&lights, &light_val); - if ( light_val == (GpioState) GPIO_STATE_LOW) { - status = gpio_set_state(&lights, GPIO_STATE_HIGH); - g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_HIGH; + if (get_horn_and_lights_lights_state()) { + status = gpio_set_state(&lights, GPIO_STATE_LOW); if (status == STATUS_CODE_OK) { gpio_get_state(&lights, &state_val); } } else { - status = gpio_set_state(&lights, GPIO_STATE_LOW); - g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_LOW; + status = gpio_set_state(&lights, GPIO_STATE_HIGH); if (status == STATUS_CODE_OK) { gpio_get_state(&lights, &state_val); } @@ -103,7 +93,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { uv_smoke_logic(); assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_DISCONNECTED ); LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_DISCONNECTED'\n"); - delay_ms(1000); + // delay_ms(1000); //TEST 2 - Active UV status LOG_DEBUG("Running test for UV Active state\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); @@ -115,6 +105,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { LOG_DEBUG("Running test for Horn in state HIGH\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&horn,GPIO_STATE_HIGH); + g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_HIGH; lights_check = 0; uv_smoke_logic(); assert(status == STATUS_CODE_OK); @@ -125,6 +116,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { LOG_DEBUG("Running test for Lights in state HIGH\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&lights,GPIO_STATE_HIGH); + g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_HIGH; lights_check = 1; uv_smoke_logic(); assert(status == STATUS_CODE_OK); @@ -135,6 +127,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { LOG_DEBUG("Running test for Horn in state LOW\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&horn,GPIO_STATE_LOW); + g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_LOW; lights_check = 0; uv_smoke_logic(); assert(status == STATUS_CODE_OK); @@ -145,6 +138,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { LOG_DEBUG("Running test for Lights in state LOW\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); gpio_set_state(&lights,GPIO_STATE_LOW); + g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_LOW; lights_check = 1; uv_smoke_logic(); assert(status == STATUS_CODE_OK); @@ -160,6 +154,7 @@ int main() { gpio_init(); + //IT SHOULD BE GPIO_INPUT_PULL_UP BUT CHANGED FOR TESTING PURPOSES ONLY gpio_init_pin(&uv_status, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); From 125c69f0bbef57b68f4b676e0aeef42c56a69c22 Mon Sep 17 00:00:00 2001 From: vagrant Date: Tue, 25 Jul 2023 19:52:59 +0000 Subject: [PATCH 30/31] uv cutoff smoke tests done --- projects/uv_cutoff/src/main.c | 2 +- smoke/uv_cutoff/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/uv_cutoff/src/main.c b/projects/uv_cutoff/src/main.c index 57e203605..73b26dcda 100644 --- a/projects/uv_cutoff/src/main.c +++ b/projects/uv_cutoff/src/main.c @@ -108,7 +108,7 @@ int main() { can_init(&s_can_storage, &can_settings); gpio_init(); - gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); + gpio_init_pin(&uv_status, GPIO_INPUT_PULL_UP, GPIO_STATE_HIGH); gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); diff --git a/smoke/uv_cutoff/src/main.c b/smoke/uv_cutoff/src/main.c index 04e85064a..d87fce317 100644 --- a/smoke/uv_cutoff/src/main.c +++ b/smoke/uv_cutoff/src/main.c @@ -93,7 +93,7 @@ TASK(smoke_task, TASK_MIN_STACK_SIZE) { uv_smoke_logic(); assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_DISCONNECTED ); LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_DISCONNECTED'\n"); - // delay_ms(1000); + delay_ms(1000); //TEST 2 - Active UV status LOG_DEBUG("Running test for UV Active state\n"); gpio_set_state(&uv_status,GPIO_STATE_HIGH); From 1722a4916ce3c9dfbe09c9268c273d7f167cae0b Mon Sep 17 00:00:00 2001 From: vagrant Date: Wed, 26 Jul 2023 16:45:08 +0000 Subject: [PATCH 31/31] uv cutoff smoke tests done --- projects/uv_cutoff/inc/uv_cutoff.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/uv_cutoff/inc/uv_cutoff.h b/projects/uv_cutoff/inc/uv_cutoff.h index 451f9d59a..07d49b0ed 100644 --- a/projects/uv_cutoff/inc/uv_cutoff.h +++ b/projects/uv_cutoff/inc/uv_cutoff.h @@ -4,5 +4,3 @@ typedef enum UVCutoffState { UV_CUTOFF_ACTIVE = 0, UV_CUTOFF_DISCONNECTED, } UVCutoffState; - -void uv_ligc() {}