Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Thermal Mgr Task #285

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions obc/app/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/digital_watchdog_mgr
${CMAKE_CURRENT_SOURCE_DIR}/eps_mgr
${CMAKE_CURRENT_SOURCE_DIR}/gnc_mgr
${CMAKE_CURRENT_SOURCE_DIR}/health_collector
${CMAKE_CURRENT_SOURCE_DIR}/thermal_mgr
${CMAKE_CURRENT_SOURCE_DIR}/state_mgr
${CMAKE_CURRENT_SOURCE_DIR}/telemetry_mgr
${CMAKE_CURRENT_SOURCE_DIR}/timekeeper
Expand All @@ -35,7 +35,7 @@ set(SOURCES

${CMAKE_CURRENT_SOURCE_DIR}/gnc_mgr/gnc_manager.c

${CMAKE_CURRENT_SOURCE_DIR}/health_collector/health_collector.c
${CMAKE_CURRENT_SOURCE_DIR}/thermal_mgr/thermal_mgr.c

${CMAKE_CURRENT_SOURCE_DIR}/state_mgr/state_mgr.c

Expand Down
6 changes: 3 additions & 3 deletions obc/app/modules/digital_watchdog_mgr/digital_watchdog_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define TASK_PAYLOAD_MGR_WATCHDOG_TIMEOUT portMAX_DELAY
#define TASK_TIMEKEEPER_WATCHDOG_TIMEOUT portMAX_DELAY
#define TASK_ALARM_MGR_WATCHDOG_TIMEOUT portMAX_DELAY
#define TASK_HEALTH_COLLECTOR_WATCHDOG_TIMEOUT portMAX_DELAY
#define TASK_THERMAL_MGR_WATCHDOG_TIMEOUT pdMS_TO_TICKS(1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this with changed tick delay

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watchdog timeout shouldl generally be 2x task rate

#define TASK_STATS_COLLECTOR_WATCHDOG_TIMEOUT portMAX_DELAY
#define TASK_LOGGER_WATCHDOG_TIMEOUT portMAX_DELAY
#define TASK_DIGITAL_WATCHDOG_MGR_WATCHDOG_TIMEOUT portMAX_DELAY
Expand Down Expand Up @@ -75,9 +75,9 @@ static watchdog_task_info_t watchdogTaskArray[] = {
{
.taskTimeoutTicks = TASK_ALARM_MGR_WATCHDOG_TIMEOUT,
},
[OBC_SCHEDULER_CONFIG_ID_HEALTH_COLLECTOR] =
[OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR] =
{
.taskTimeoutTicks = TASK_HEALTH_COLLECTOR_WATCHDOG_TIMEOUT,
.taskTimeoutTicks = TASK_THERMAL_MGR_WATCHDOG_TIMEOUT,
},
[OBC_SCHEDULER_CONFIG_ID_LOGGER] =
{
Expand Down
4 changes: 2 additions & 2 deletions obc/app/modules/state_mgr/state_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void obcTaskFunctionStateMgr(void *pvParameters) {
initFRAM(); // FRAM storage (OBC)

// Initialize the state of each module. This will not start any tasks.
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_TIMEKEEPER);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_ALARM_MGR);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_TELEMETRY_MGR);
Expand All @@ -95,7 +96,6 @@ void obcTaskFunctionStateMgr(void *pvParameters) {
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_COMMS_DOWNLINK_ENCODER);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_EPS_MGR);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_PAYLOAD_MGR);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_HEALTH_COLLECTOR);
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_GNC_MGR);
#if ENABLE_TASK_STATS_COLLECTOR == 1
obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_STATS_COLLECTOR);
Expand All @@ -112,7 +112,7 @@ void obcTaskFunctionStateMgr(void *pvParameters) {
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_COMMS_DOWNLINK_ENCODER);
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_EPS_MGR);
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_PAYLOAD_MGR);
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_HEALTH_COLLECTOR);
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR);
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_GNC_MGR);
#if ENABLE_TASK_STATS_COLLECTOR == 1
obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_STATS_COLLECTOR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
#include "health_collector.h"
#include "thermal_mgr.h"
#include "lm75bd.h"
#include "obc_time.h"
#include "telemetry_manager.h"
#include "obc_errors.h"
#include "obc_logging.h"
#include "obc_scheduler_config.h"
#include <obc_digital_watchdog.h>
#include "digital_watchdog_mgr.h"

#include <FreeRTOS.h>
#include <os_portmacro.h>
#include <os_task.h>
#include <sys_common.h>
#include <os_queue.h>

#define HEALTH_COLLECTION_PERIOD_MS 60000UL
#define THERMAL_MGR_PERIOD_MS 1000

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our telemetry sheet, it should take the temperature once every minute, not once a sec. Also add U to the end

static obc_error_code_t collectObcLm75bdTemp(void);
void obcTaskInitThermalMgr() {}
static obc_error_code_t collectObcLm75bdTemp(void);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task should init the lm75bd


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push this above the obcTaskInit function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix indent

void obcTaskInitHealthCollector(void) {}

void obcTaskFunctionHealthCollector(void* pvParameters) {
void obcTaskFunctionThermalMgr(void* pvParameters) {
obc_error_code_t errCode;
TickType_t xLastWakeTime;

xLastWakeTime = xTaskGetTickCount();

while (1) {
LOG_IF_ERROR_CODE(collectObcLm75bdTemp());
vTaskDelay(pdMS_TO_TICKS(HEALTH_COLLECTION_PERIOD_MS));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be implementing these mailboxes in this pr https://discord.com/channels/831191521595621387/1124186460866740314/1181054461494444082

Don;t need to have other tasks sending anything to the queue right now but the queues and thermal mgr side shpuld be set up

digitalWatchdogTaskCheckIn(OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR);

vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(THERMAL_MGR_PERIOD_MS));
}


}

static obc_error_code_t collectObcLm75bdTemp(void) {
static obc_error_code_t collectObcLm75bdTemp(void) {
obc_error_code_t errCode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix indent


float temp = 0.0f;
Expand All @@ -36,4 +45,5 @@ static obc_error_code_t collectObcLm75bdTemp(void) {
RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make telem a flag that is passed in since we may want to just read the value sometimes to make sure we are safe without adding that as telemetry

return OBC_ERR_CODE_SUCCESS;
}

}
31 changes: 16 additions & 15 deletions obc/app/rtos/obc_scheduler_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define TASK_TIMEKEEPER_NAME "timekeeper"
#define TASK_DIGITAL_WATCHDOG_MGR_NAME "digital_wdg_mgr"
#define TASK_ALARM_MGR_NAME "alarm_handler"
#define TASK_HEALTH_COLLECTOR_NAME "health_collector"
#define TASK_THERMAL_MGR_NAME "thermal_mgr"
#define TASK_STATS_COLLECTOR_NAME "stats_collector"
#define TASK_LOGGER_NAME "logger"
#define TASK_GNC_MGR_NAME "gnc_mgr"
Expand All @@ -40,17 +40,18 @@
#define TASK_TIMEKEEPER_STACK_SIZE 1024U
#define TASK_DIGITAL_WATCHDOG_MGR_STACK_SIZE 128U
#define TASK_ALARM_MGR_STACK_SIZE 512U
#define TASK_HEALTH_COLLECTOR_STACK_SIZE 256U
#define TASK_STATS_COLLECTOR_STACK_SIZE 1024U
#define TASK_LOGGER_STACK_SIZE 512U
#define TASK_GNC_MGR_STACK_SIZE 512U
#define TASK_THERMAL_MGR_STACK_SIZE 256U


// All task priorities must be in [0, OBC_SCHEDULER_MAX_PRIORITY]
#define OBC_SCHEDULER_MAX_PRIORITY configMAX_PRIORITIES - 1U
#define TASK_IDLE_PRIORITY 0U
#define TASK_COMMAND_MGR_PRIORITY 1U
#define TASK_TELEMETRY_MGR_PRIORITY 1U
#define TASK_HEALTH_COLLECTOR_PRIORITY 1U
#define TASK_THERMAL_MGR_PRIORITY 1U
#define TASK_PAYLOAD_MGR_PRIORITY 1U
#define TASK_COMMS_PRIORITY 2U // Comms tasks must have the same priority
#define TASK_COMMS_MGR_PRIORITY TASK_COMMS_PRIORITY
Expand Down Expand Up @@ -88,7 +89,7 @@ extern void obcTaskInitEpsMgr(void);
extern void obcTaskInitPayloadMgr(void);
extern void obcTaskInitTimekeeper(void);
extern void obcTaskInitAlarmMgr(void);
extern void obcTaskInitHealthCollector(void);
extern void obcTaskInitThermalMgr(void);
extern void obcTaskInitStatsCollector(void);
extern void obcTaskInitLogger(void);
extern void obcTaskInitGncMgr(void);
Expand All @@ -105,7 +106,7 @@ extern void obcTaskFunctionPayloadMgr(void *params);
extern void obcTaskFunctionTimekeeper(void *params);
extern void obcTaskFunctionSwWatchdog(void *params);
extern void obcTaskFunctionAlarmMgr(void *params);
extern void obcTaskFunctionHealthCollector(void *params);
extern void obcTaskFunctionThermalMgr(void *params);
extern void obcTaskFunctionStatsCollector(void *params);
extern void obcTaskFunctionLogger(void *params);
extern void obcTaskFunctionGncMgr(void *params);
Expand Down Expand Up @@ -147,8 +148,8 @@ static StaticTask_t obcTaskBufferSwWatchdog;
static StackType_t obcTaskStackAlarmMgr[TASK_ALARM_MGR_STACK_SIZE];
static StaticTask_t obcTaskBufferAlarmMgr;

static StackType_t obcTaskStackHealthCollector[TASK_HEALTH_COLLECTOR_STACK_SIZE];
static StaticTask_t obcTaskBufferHealthCollector;
static StackType_t obcTaskStackThermalMgr[TASK_THERMAL_MGR_STACK_SIZE];
static StaticTask_t obcTaskBufferThermalMgr;

static StackType_t obcTaskStackLogger[TASK_LOGGER_STACK_SIZE];
static StaticTask_t obcTaskBufferLogger;
Expand Down Expand Up @@ -272,15 +273,15 @@ static obc_scheduler_config_t obcSchedulerConfig[] = {
.taskFunc = obcTaskFunctionAlarmMgr,
.taskInit = obcTaskInitAlarmMgr,
},
[OBC_SCHEDULER_CONFIG_ID_HEALTH_COLLECTOR] =
[OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR] =
{
.taskName = TASK_HEALTH_COLLECTOR_NAME,
.taskStack = obcTaskStackHealthCollector,
.taskBuffer = &obcTaskBufferHealthCollector,
.stackSize = TASK_HEALTH_COLLECTOR_STACK_SIZE,
.priority = TASK_HEALTH_COLLECTOR_PRIORITY,
.taskFunc = obcTaskFunctionHealthCollector,
.taskInit = obcTaskInitHealthCollector,
.taskName = TASK_THERMAL_MGR_NAME,
.taskStack = obcTaskStackThermalMgr,
.taskBuffer = &obcTaskBufferThermalMgr,
.stackSize = TASK_THERMAL_MGR_STACK_SIZE,
.priority = TASK_THERMAL_MGR_PRIORITY,
.taskFunc = obcTaskFunctionThermalMgr,
.taskInit = obcTaskInitThermalMgr,
},
[OBC_SCHEDULER_CONFIG_ID_LOGGER] =
{
Expand Down
2 changes: 1 addition & 1 deletion obc/app/rtos/obc_scheduler_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef enum {
OBC_SCHEDULER_CONFIG_ID_PAYLOAD_MGR,
OBC_SCHEDULER_CONFIG_ID_TIMEKEEPER,
OBC_SCHEDULER_CONFIG_ID_ALARM_MGR,
OBC_SCHEDULER_CONFIG_ID_HEALTH_COLLECTOR,
OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR,
OBC_SCHEDULER_CONFIG_ID_LOGGER,
OBC_SCHEDULER_CONFIG_ID_GNC_MGR,

Expand Down
Loading