From ad9088697d38af7f784191cd9da865100f958632 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 13 Feb 2024 17:15:02 -0500 Subject: [PATCH] Streamline code --- MSB/api/msb_can.h | 2 -- MSB/api/msb_common.h | 2 +- MSB/msb_can.c | 9 +++++++-- MSB/msb_main.c | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MSB/api/msb_can.h b/MSB/api/msb_can.h index f5b17b9..26009e2 100644 --- a/MSB/api/msb_can.h +++ b/MSB/api/msb_can.h @@ -2,8 +2,6 @@ #ifndef MSB_CAN_H #define MSB_CAN_H -void loop_publish_can(); - void start_can_publisher(); void stop_can_publisher(); diff --git a/MSB/api/msb_common.h b/MSB/api/msb_common.h index 209d862..337790b 100644 --- a/MSB/api/msb_common.h +++ b/MSB/api/msb_common.h @@ -2,6 +2,6 @@ #ifndef MSB_COMMON_H #define MSB_COMMON_H -void push_can_queue(char* message); +short push_can_queue(char* message); #endif diff --git a/MSB/msb_can.c b/MSB/msb_can.c index bb7c010..d623149 100644 --- a/MSB/msb_can.c +++ b/MSB/msb_can.c @@ -2,7 +2,9 @@ #include "api/msb_common.h" #include "api/msb_can.h" -char* queue[25]; +#define MAX_SIZE 25 + +char* queue[MAX_SIZE]; int queue_index; int running = 0; @@ -22,6 +24,9 @@ void stop_can_publisher() { running = 0; } -void push_can_queue(char* message) { +short push_can_queue(char* message) { + if (queue_index == MAX_SIZE) return 0; + queue[queue_index++] = message; + return 1; } diff --git a/MSB/msb_main.c b/MSB/msb_main.c index e6e889c..60b23f5 100644 --- a/MSB/msb_main.c +++ b/MSB/msb_main.c @@ -1,8 +1,9 @@ #include "api/msb_main.h" #include "api/msb_can.h" +#include "cmsis_os.h" -//osThreadId_t canTaskHandle; +osThreadId_t canTaskHandle; void init_msb() { // spawn CAN output thread