Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
93 changes: 67 additions & 26 deletions .cproject

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ STM32L152-Discovery.elf.launch

# VS2022
.vs/
.vscode/

# OS Specific
**/.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
[submodule "SoarCommunications"]
path = SoarCommunications
url = https://github.com/UCSOAR/CommunicationSystemsSubmodule.git
[submodule "SoarProtobufs"]
path = SoarProtobufs
url = https://github.com/StudentOrganisationForAerospaceResearch/SoarProto.git
branch = Jad/Protobufs
66 changes: 34 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
repos:

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017
hooks:
- id: clang-format
args: ['--style={BasedOnStyle: Google, SortIncludes: false}']
files: \.(cpp|hpp)$
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
files: \.(js|ts|jsx|tsx|css|less|html|json|markdown|md|yaml|yml)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
hooks:
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
stages: [commit]
- id: ruff-format
stages: [commit]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017
hooks:
- id: clang-format
args:
[
"--style={BasedOnStyle: Google, SortIncludes: false, ColumnLimit: 120}",
]
files: \.(cpp|hpp)$
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
files: \.(js|ts|jsx|tsx|css|less|html|json|markdown|md|yaml|yml)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
hooks:
- id: ruff
types_or: [python, pyi]
args: [--fix]
stages: [commit]
- id: ruff-format
stages: [commit]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
62 changes: 62 additions & 0 deletions Components/Core/Inc/Logging_Task_M.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
********************************************************************************
* @file Logging_Task_M.hpp
* @author jaddina
* @date Sep 6, 2025
* @brief
********************************************************************************
*/

#ifndef CORE_INC_LOGGING_TASK_M_HPP_
#define CORE_INC_LOGGING_TASK_M_HPP_

/************************************
* INCLUDES
************************************/
//#include "SensorDataTypes.hpp"
#include "Task.hpp"
#include "SystemDefines.hpp"

/************************************
* MACROS AND DEFINES
************************************/
constexpr uint16_t LOGGING_RX_BUFFER_SZ_BYTES = 16;
/************************************
* TYPEDEFS
************************************/

/************************************
* CLASS DEFINITIONS
************************************/

/************************************
* FUNCTION DECLARATIONS
************************************/
class LoggingTask : public Task
{
public:
static LoggingTask& Inst() {
static LoggingTask inst;
return inst;
}



void InitTask();

protected:
bool RecieveData();
static void RunTask(void* pvParams) { LoggingTask::Inst().Run(pvParams); } // Static Task Interface, passes control to the instance Run();
void Run(void * pvParams); // Main run code
void HandleCommand(Command& cm);
void WriteData();//put argue
bool HandleDataBrokerCommand(Command& cm);

private:
// Private Functions
LoggingTask(); // Private constructor
LoggingTask(const LoggingTask&); // Prevent copy-construction
LoggingTask& operator=(const LoggingTask&); // Prevent assignment
};

#endif /* CORE_INC_LOGGING_TASK_M_HPP_ */
159 changes: 159 additions & 0 deletions Components/Core/Logging_Task_M.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/**
********************************************************************************
* @file Logging_Task_M.cpp
* @author jaddina
* @date Sep 6, 2025
* @brief
*
* * Setup Steps
* 1. Define the Task Queue Depth in SystemDefines.hpp
* 2. Define the Task Stack Depth in SystemDefines.hpp
* 3. Define the Task Priority in SystemDefines.hpp
* 4. Replace all placeholders marked with a $ sign
********************************************************************************
*/

/************************************
* INCLUDES
************************************/
#include "Logging_Task_M.hpp"
#include "SystemDefines.hpp"
#include "Command.hpp"
#include "DataBroker.hpp"
#include "DataBrokerMessageTypes.hpp"

/************************************
* PRIVATE MACROS AND DEFINES
************************************/

/************************************
* VARIABLES
************************************/

/************************************
* FUNCTION DECLARATIONS
************************************/

/************************************
* FUNCTION DEFINITIONS
************************************/
/**
* @brief Constructor for LoggingTask
*/
LoggingTask::LoggingTask()
: Task(LOGGING_TASK_DEPTH_OBJS)
{

}

/**
* @brief Initialize the LoggingTask
* Do not modify this function aside from adding the task name
*/
void LoggingTask::InitTask()
{
// Make sure the task is not already initialized
SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize watchdog task twice");

BaseType_t rtValue =
xTaskCreate((TaskFunction_t)LoggingTask::RunTask,
(const char*)"LoggingTask",
(uint16_t)LOGGING_TASK_DEPTH_WORDS,
(void*)this,
(UBaseType_t)LOGGING_TASK_PRIORITY,
(TaskHandle_t*)&rtTaskHandle);

SOAR_ASSERT(rtValue == pdPASS, "LoggingTask::InitTask() - xTaskCreate() failed");
}


/**
* @brief Instance Run loop for the Task, runs on scheduler start as long as the task is initialized.
* @param pvParams RTOS Passed void parameters, contains a pointer to the object instance, should not be used
*/
void LoggingTask::Run(void * pvParams)
{
DataBroker::Subscribe<AccelerometerData>(this);
DataBroker::Subscribe<PressureData>(this);
DataBroker::Subscribe<ThermocoupleData>(this);


while (1) {
/* Process commands in blocking mode */
Command cm;
bool res = qEvtQueue->ReceiveWait(cm);
if(res){
HandleCommand(cm);
}
}
}

/**
* @brief Handles a command
* @param cm Command reference to handle
*/
void LoggingTask::HandleCommand(Command& cm)
{
switch (cm.GetCommand()) {

case DATA_BROKER_COMMAND:
HandleDataBrokerCommand(cm);
break;

default:
SOAR_PRINT("LoggingTask - Received Unsupported Command {%d}\n", cm.GetCommand());
break;
}

//No matter what we happens, we must reset allocated data
cm.Reset();
}

bool LoggingTask::HandleDataBrokerCommand(Command& cm){

DataBrokerMessageTypes messageType = DataBroker::getMessageType(cm);
AccelerometerData accel_data = {};
PressureData pressure_data = {};
ThermocoupleData thermocouple_data = {};

switch (messageType){

case DataBrokerMessageTypes :: ACCELEROMETER_DATA:
accel_data = DataBroker::ExtractData<AccelerometerData>(cm);




SOAR_PRINT("Data Recieved\n");
SOAR_PRINT("accelX: %d\n", accel_data.accelX);
SOAR_PRINT("accelY: %d\n", accel_data.accelY);
SOAR_PRINT("accelZ: %d\n", accel_data.accelZ);

//access IMU data, then write data to a file in the fs
//Use FreeRTOS FATFS wrapper
break;
case DataBrokerMessageTypes::PRESSURE_DATA:
pressure_data = DataBroker::ExtractData<PressureData>(cm);
//access PressureData data, then write data to a file in the fs
//Use FreeRTOS FATFS wrapper
SOAR_PRINT("Data Recieved");
SOAR_PRINT("pressure: %f", pressure_data.pressure);
break;
case DataBrokerMessageTypes::THERMOCOUPLE_DATA:
thermocouple_data = DataBroker::ExtractData<ThermocoupleData>(cm);
//access Thermocouple data, then write data to a file in the fs
//Use FreeRTOS FATFS wrapper
SOAR_PRINT("Data Recieved\n");
SOAR_PRINT("temperature: %f", thermocouple_data.temperature);

break;
case DataBrokerMessageTypes :: INVALID:
SOAR_PRINT("Invalid data type");
default:
break;


}


}
Loading