Skip to content

Commit

Permalink
Fixed issues with monitor functions and threads
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Feb 23, 2024
1 parent 6503850 commit 42b44ee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
11 changes: 7 additions & 4 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ int main(void)
MX_FDCAN1_Init();
MX_I2C3_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */

/* USER CODE BEGIN 2 */
msb_temp_t *temp_data;
msb_knuckle_t *knuckle_data;
msb_central_t *central_data;
/* USER CODE END 2 */

/* Init scheduler */
Expand All @@ -139,9 +142,9 @@ int main(void)
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

/* USER CODE BEGIN RTOS_THREADS */
osThreadId_t tempThread = osThreadNew(monitor_temp_msb, NULL, NULL);
osThreadId_t imuThread = osThreadNew(monitor_knuckle_msb, NULL, NULL);
osThreadId_t centralThread = osThreadNew(monitor_central_msb, NULL, NULL);
osThreadId_t tempThread = osThreadNew(monitor_temp_msb, temp_data, NULL);
osThreadId_t imuThread = osThreadNew(monitor_knuckle_msb, knuckle_data, NULL);
osThreadId_t centralThread = osThreadNew(monitor_central_msb, central_data, NULL);
/* USER CODE END RTOS_THREADS */

/* USER CODE BEGIN RTOS_EVENTS */
Expand Down
6 changes: 3 additions & 3 deletions MSB/api/monitor_msb.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "msb_knuckle.h"
#include "msb_central.h"

void monitor_temp_msb(msb_temp_t* msb, temp_data_t* out);
void monitor_knuckle_msb(msb_knuckle_t* msb, knuckle_data_t* out);
void monitor_central_msb(msb_central_t* msb, central_data_t* msb_central_data);
void monitor_temp_msb(void* arg);
void monitor_knuckle_msb(void* arg);
void monitor_central_msb(void* arg);

#endif
22 changes: 19 additions & 3 deletions MSB/monitor_msb.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#include "cmsis_os.h"
#include <stdio.h>
#include <stdlib.h>

#include "api/monitor_msb.h"

void monitor_temp_msb(msb_temp_t* msb, temp_data_t* out) {
void monitor_temp_msb(void* arg) {

msb_temp_t* msb = (msb_temp_t*)arg;

temp_data_t* out = malloc(sizeof(temp_data_t));

char status[100];
for (;;) {
Expand All @@ -15,9 +20,14 @@ void monitor_temp_msb(msb_temp_t* msb, temp_data_t* out) {
push_can_queue(status);
osDelay(500);
}
free(out); //Check if this works
}

void monitor_knuckle_msb(msb_knuckle_t* msb, knuckle_data_t* out) {
void monitor_knuckle_msb(void* arg) {

msb_knuckle_t* msb = (msb_knuckle_t*)arg;

knuckle_data_t* out = malloc(sizeof(knuckle_data_t));

char status[100];
for (;;) {
Expand All @@ -30,9 +40,14 @@ void monitor_knuckle_msb(msb_knuckle_t* msb, knuckle_data_t* out) {
push_can_queue(status);
osDelay(500);
}
free(out); //Check if this works
}

void monitor_central_msb(msb_central_t* msb, central_data_t* out) {
void monitor_central_msb(void* arg) {

msb_central_t* msb = (msb_central_t*)arg;

central_data_t* out = malloc(sizeof(msb_central_t));

char status[100];
for (;;) {
Expand All @@ -53,6 +68,7 @@ void monitor_central_msb(msb_central_t* msb, central_data_t* out) {
push_can_queue(status);
osDelay(500);
}
free(out); //Check if this works
}


0 comments on commit 42b44ee

Please sign in to comment.