diff --git a/.cproject b/.cproject
index f6da38a..127b1e6 100644
--- a/.cproject
+++ b/.cproject
@@ -55,6 +55,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -98,6 +109,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -141,6 +163,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -296,6 +315,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -338,6 +368,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -398,4 +439,4 @@
-
+
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 77aa44f..f607ab2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,6 +61,7 @@ STM32L152-Discovery.elf.launch
# VS2022
.vs/
+.vscode/
# OS Specific
**/.DS_Store
diff --git a/.gitmodules b/.gitmodules
index fec813e..e83611b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -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
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ea88dd5..c4767f4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -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
diff --git a/Components/Core/Inc/Logging_Task_M.hpp b/Components/Core/Inc/Logging_Task_M.hpp
new file mode 100644
index 0000000..cae8251
--- /dev/null
+++ b/Components/Core/Inc/Logging_Task_M.hpp
@@ -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_ */
diff --git a/Components/Core/Logging_Task_M.cpp b/Components/Core/Logging_Task_M.cpp
new file mode 100644
index 0000000..2e09058
--- /dev/null
+++ b/Components/Core/Logging_Task_M.cpp
@@ -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(this);
+ DataBroker::Subscribe(this);
+ DataBroker::Subscribe(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(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(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(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;
+
+
+ }
+
+
+}
diff --git a/Components/FSBProtocol/FSBProtocolTask.cpp b/Components/FSBProtocol/FSBProtocolTask.cpp
new file mode 100644
index 0000000..04fcb98
--- /dev/null
+++ b/Components/FSBProtocol/FSBProtocolTask.cpp
@@ -0,0 +1,119 @@
+/**
+ ********************************************************************************
+ * @file FSBProtocolTask.cpp
+ * @author jaddina
+ * @date Sep 13, 2025
+ * @brief
+ ********************************************************************************
+ */
+
+/************************************
+ * INCLUDES
+ ************************************/
+#include "FSBProtocolTask.hpp"
+#include "SystemDefines.hpp"
+#include "Command.hpp"
+
+#include "DataBroker.hpp"
+#include "Task.hpp"
+/*
+#include "WriteBufferFixedSize.h"
+#include "ReadBufferFixedSize.h"
+#include "cobs.h"
+*/
+/************************************
+ * PRIVATE MACROS AND DEFINES
+ ************************************/
+
+/************************************
+ * VARIABLES
+ ************************************/
+
+/************************************
+ * FUNCTION DECLARATIONS
+ ************************************/
+
+
+
+/************************************
+ * FUNCTION DEFINITIONS
+ ************************************/
+FSBProtocolTask::FSBProtocolTask():Task(TASK_FSB_PROTOCOL_DEPTH_OBJS)
+{
+
+}
+
+/**
+ * @brief Initialize the FSBProtocolTask
+ * Do not modify this function aside from adding the task name
+ */
+void FSBProtocolTask::InitTask()
+{
+ // Make sure the task is not already initialized
+ SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize watchdog task twice");
+
+ BaseType_t rtValue =
+ xTaskCreate((TaskFunction_t)FSBProtocolTask::RunTask,
+ (const char*)"FSBProtocolTask",
+ (uint16_t)TASK_FSB_PROTOCOL_DEPTH_WORDS,
+ (void*)this,
+ (UBaseType_t)TASK_FSB_PROTOCOL_PRIORITY,
+ (TaskHandle_t*)&rtTaskHandle);
+
+ SOAR_ASSERT(rtValue == pdPASS, "FSBProtocolTask::InitTask() - xTaskCreate() failed");
+}
+
+void FSBProtocolTask::Run(void * pvParams){
+
+ while (1) {
+ /* Process commands in blocking mode */
+ Command cm;
+ bool res = qEvtQueue->ReceiveWait(cm);
+ if(res){
+
+ HandleCommand(cm);
+ }
+ }
+}
+
+void FSBProtocolTask::HandleCommand(Command& cm){
+
+
+ switch(cm.GetTaskCommand()){
+
+ case PUBLISH_PRESSURE:
+ {
+
+ PressureData pd;
+ pd.pressure = 140;
+ SOAR_PRINT("Pressure published");
+
+ DataBroker::Publish(&pd);
+ break;
+ }
+
+ case PUBLISH_IMU:
+ {
+
+
+ AccelerometerData acceleration = {100, 150, 200};
+ SOAR_PRINT("IMU published");
+ DataBroker::Publish(&acceleration);
+ break;
+ }
+
+ case PUBLISH_THERMOCOUPLE:
+ {
+
+ ThermocoupleData tc;
+ tc.temperature = 150;
+ SOAR_PRINT("Temperature published");
+
+ DataBroker::Publish(&tc);
+ break;
+ }
+ }
+
+}
+
+
diff --git a/Components/FSBProtocol/Inc/FSBProtocolTask.hpp b/Components/FSBProtocol/Inc/FSBProtocolTask.hpp
new file mode 100644
index 0000000..1b23858
--- /dev/null
+++ b/Components/FSBProtocol/Inc/FSBProtocolTask.hpp
@@ -0,0 +1,62 @@
+/**
+ ********************************************************************************
+ * @file FSBProtocolTask.hpp
+ * @author jaddina
+ * @date Sep 13, 2025
+ * @brief
+ ********************************************************************************
+ */
+
+#ifndef FSBPROTOCOL_INC_FSBPROTOCOLTASK_HPP_
+#define FSBPROTOCOL_INC_FSBPROTOCOLTASK_HPP_
+
+/************************************
+ * INCLUDES
+ ************************************/
+#include "Task.hpp"
+/************************************
+ * MACROS AND DEFINES
+ ************************************/
+enum FSB_TASK_COMMANDS {
+ PUBLISH_IMU =0,
+ PUBLISH_PRESSURE,
+ PUBLISH_THERMOCOUPLE,
+};
+
+/************************************
+ * TYPEDEFS
+ ************************************/
+
+/************************************
+ * CLASS DEFINITIONS
+ ************************************/
+
+/************************************
+ * FUNCTION DECLARATIONS
+ ************************************/
+class FSBProtocolTask: public Task
+{
+ public:
+ static FSBProtocolTask& Inst() {
+ static FSBProtocolTask inst;
+ return inst;
+ }
+
+ void InitTask();
+
+
+
+ protected:
+ bool RecieveData();
+ static void RunTask(void* pvParams) { FSBProtocolTask::Inst().Run(pvParams); } // Static Task Interface, passes control to the instance Run();
+ void Run(void * pvParams); // Main run code
+ void HandleCommand(Command& cm);
+ //uint8_t debugBuffer[LOGGING_RX_BUFFER_SZ_BYTES + 1];
+
+ private:
+ // Private Functions
+ FSBProtocolTask(); // Private constructor
+ FSBProtocolTask(const FSBProtocolTask&); // Prevent copy-construction
+ FSBProtocolTask& operator=(const FSBProtocolTask&); // Prevent assignment
+};
+#endif /* FSBPROTOCOL_INC_FSBPROTOCOLTASK_HPP_ */
diff --git a/Components/PubSubTest/Inc/PubSubReceive.hpp b/Components/PubSubTest/Inc/PubSubReceive.hpp
new file mode 100644
index 0000000..17a5165
--- /dev/null
+++ b/Components/PubSubTest/Inc/PubSubReceive.hpp
@@ -0,0 +1,58 @@
+/**
+ ********************************************************************************
+ * @file PubSubReceive.hpp
+ * @author Shivam Desai
+ * @date Dec 14, 2024
+ * @brief
+ ********************************************************************************
+ */
+
+#ifndef PUBSUB_RECEIEVE_HPP_
+#define PUBSUB_RECEIEVE_HPP_
+
+/************************************
+ * INCLUDES
+ ************************************/
+#include "Task.hpp"
+#include "SystemDefines.hpp"
+
+/************************************
+ * MACROS AND DEFINES
+ ************************************/
+
+/************************************
+ * TYPEDEFS
+ ************************************/
+
+/************************************
+ * CLASS DEFINITIONS
+ ************************************/
+class PubSubReceive : public Task {
+ public:
+ static PubSubReceive& Inst() {
+ static PubSubReceive inst;
+ return inst;
+ }
+
+ void InitTask();
+
+ protected:
+ static void RunTask(void* pvParams) {
+ PubSubReceive::Inst().Run(pvParams);
+ } // Static Task Interface, passes control to the instance Run();
+ void Run(void* pvParams); // Main run code
+ void HandleCommand(Command& cm);
+ void HandleDataBrokerCommand(const Command& cm);
+
+ private:
+ // Private Functions
+ PubSubReceive(); // Private constructor
+ PubSubReceive(const PubSubReceive&); // Prevent copy-construction
+ PubSubReceive& operator=(const PubSubReceive&); // Prevent assignment
+};
+
+/************************************
+ * FUNCTION DECLARATIONS
+ ************************************/
+
+#endif /* PUBSUB_RECEIEVE_HPP_ */
diff --git a/Components/PubSubTest/Inc/PubSubSend.hpp b/Components/PubSubTest/Inc/PubSubSend.hpp
new file mode 100644
index 0000000..ef09d94
--- /dev/null
+++ b/Components/PubSubTest/Inc/PubSubSend.hpp
@@ -0,0 +1,57 @@
+/**
+ ********************************************************************************
+ * @file PubSubSend.hpp
+ * @author Shivam Desai
+ * @date Dec 14, 2024
+ * @brief
+ ********************************************************************************
+ */
+
+#ifndef PUBSUB_SEND_HPP_
+#define PUBSUB_SEND_HPP_
+
+/************************************
+ * INCLUDES
+ ************************************/
+#include "Task.hpp"
+#include "SystemDefines.hpp"
+
+/************************************
+ * MACROS AND DEFINES
+ ************************************/
+
+/************************************
+ * TYPEDEFS
+ ************************************/
+
+/************************************
+ * CLASS DEFINITIONS
+ ************************************/
+class PubSubSend : public Task {
+ public:
+ static PubSubSend& Inst() {
+ static PubSubSend inst;
+ return inst;
+ }
+
+ void InitTask();
+
+ protected:
+ static void RunTask(void* pvParams) {
+ PubSubSend::Inst().Run(pvParams);
+ } // Static Task Interface, passes control to the instance Run();
+ void Run(void* pvParams); // Main run code
+ void HandleCommand(Command& cm);
+
+ private:
+ // Private Functions
+ PubSubSend(); // Private constructor
+ PubSubSend(const PubSubSend&); // Prevent copy-construction
+ PubSubSend& operator=(const PubSubSend&); // Prevent assignment
+};
+
+/************************************
+ * FUNCTION DECLARATIONS
+ ************************************/
+
+#endif /* PUBSUB_SEND_HPP_ */
diff --git a/Components/PubSubTest/PubSubReceive.cpp b/Components/PubSubTest/PubSubReceive.cpp
new file mode 100644
index 0000000..e0c51f7
--- /dev/null
+++ b/Components/PubSubTest/PubSubReceive.cpp
@@ -0,0 +1,118 @@
+/**
+ ********************************************************************************
+ * @file PubSubReceive.cpp
+ * @author Shivam Desai
+ * @date Dec 14, 2024
+ * @brief
+ ********************************************************************************
+ */
+
+/************************************
+ * INCLUDES
+ ************************************/
+#include "PubSubReceive.hpp"
+#include "SystemDefines.hpp"
+#include "SensorDataTypes.hpp"
+#include "DataBroker.hpp"
+
+/************************************
+ * PRIVATE MACROS AND DEFINES
+ ************************************/
+
+/************************************
+ * VARIABLES
+ ************************************/
+
+/************************************
+ * FUNCTION DECLARATIONS
+ ************************************/
+
+/************************************
+ * FUNCTION DEFINITIONS
+ ************************************/
+
+/**
+ * @brief Constructor for PubSubReceive
+ */
+PubSubReceive::PubSubReceive() : Task(PUBSUB_RECEIVE_TASK_QUEUE_DEPTH_OBJS) {}
+
+/**
+ * @brief Initialize the PubSubReceive
+ * Do not modify this function aside from adding the task name
+ */
+void PubSubReceive::InitTask() {
+ // Make sure the task is not already initialized
+ SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize watchdog task twice");
+
+ BaseType_t rtValue = xTaskCreate((TaskFunction_t)PubSubReceive::RunTask, (const char*)"PubSubReceive",
+ (uint16_t)PUBSUB_RECEIVE_TASK_STACK_DEPTH_WORDS, (void*)this,
+ (UBaseType_t)PUBSUB_RECEIVE_TASK_RTOS_PRIORITY, (TaskHandle_t*)&rtTaskHandle);
+
+ SOAR_ASSERT(rtValue == pdPASS, "PubSubReceive::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 PubSubReceive::Run(void* pvParams) {
+ // SOAR_PRINT("PUBSUB RECIEVE STARTED\n");
+ DataBroker::Subscribe(this);
+ // DataBroker::Unsubscribe(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 PubSubReceive::HandleCommand(Command& cm) {
+ switch (cm.GetCommand()) {
+ case DATA_BROKER_COMMAND:
+ HandleDataBrokerCommand(cm);
+ break;
+
+ default:
+ SOAR_PRINT("PubSubReceive - Received Unsupported Command {%d}\n", cm.GetCommand());
+ break;
+ }
+
+ // No matter what we happens, we must reset allocated data
+ cm.Reset();
+}
+
+/**
+ * @brief Handle all data broker commands
+ * @param cm The command object with the data
+ * Use cm.GetTaskCommand() to get the message type
+ * Message types must be cast back into DataBrokerMessageTypes enum
+ * Use cm.GetDataPointer() to get the pointer to the data
+ */
+void PubSubReceive::HandleDataBrokerCommand(const Command& cm) {
+ DataBrokerMessageTypes messageType = DataBroker::getMessageType(cm);
+ switch (messageType) {
+ case DataBrokerMessageTypes::IMU_DATA: {
+ IMUData imu_data = DataBroker::ExtractData(cm);
+ SOAR_PRINT("\n IMU DATA : \n");
+ SOAR_PRINT(" X -> %d \n", imu_data.imu_stuff);
+
+ SOAR_PRINT("--DATA_END--\n\n");
+ break;
+ }
+
+ case DataBrokerMessageTypes::THERMOCOUPLE_DATA:
+ break;
+
+ case DataBrokerMessageTypes::INVALID:
+ [[fallthrough]];
+ default:
+ break;
+ }
+}
diff --git a/Components/PubSubTest/PubSubSend.cpp b/Components/PubSubTest/PubSubSend.cpp
new file mode 100644
index 0000000..5f2d03e
--- /dev/null
+++ b/Components/PubSubTest/PubSubSend.cpp
@@ -0,0 +1,92 @@
+/**
+ ********************************************************************************
+ * @file PubSubSend.cpp
+ * @author Shivam Desai
+ * @date Dec 14, 2024
+ * @brief
+ ********************************************************************************
+ */
+
+/************************************
+ * INCLUDES
+ ************************************/
+#include "PubSubSend.hpp"
+#include "SystemDefines.hpp"
+#include "SensorDataTypes.hpp"
+#include "DataBroker.hpp"
+
+/************************************
+ * PRIVATE MACROS AND DEFINES
+ ************************************/
+
+/************************************
+ * VARIABLES
+ ************************************/
+
+/************************************
+ * FUNCTION DECLARATIONS
+ ************************************/
+
+/************************************
+ * FUNCTION DEFINITIONS
+ ************************************/
+
+/**
+ * @brief Constructor for PubSubSend
+ */
+PubSubSend::PubSubSend() : Task(PUBSUB_SEND_TASK_QUEUE_DEPTH_OBJS) {}
+
+/**
+ * @brief Initialize the PubSubSend
+ * Do not modify this function aside from adding the task name
+ */
+void PubSubSend::InitTask() {
+ // Make sure the task is not already initialized
+ SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize watchdog task twice");
+
+ BaseType_t rtValue = xTaskCreate((TaskFunction_t)PubSubSend::RunTask, (const char*)"PubSubSend",
+ (uint16_t)PUBSUB_SEND_TASK_STACK_DEPTH_WORDS, (void*)this,
+ (UBaseType_t)PUBSUB_SEND_TASK_RTOS_PRIORITY, (TaskHandle_t*)&rtTaskHandle);
+
+ SOAR_ASSERT(rtValue == pdPASS, "PubSubSend::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 PubSubSend::Run(void* pvParams) {
+ // SOAR_PRINT("\nPUBSUB SEND STARTED\n");
+
+ while (1) {
+ Command cm;
+ if (qEvtQueue->Receive(cm, 5000)) {
+ HandleCommand(cm);
+ } else {
+ IMUData imuData = {
+ .imu_stuff = 100
+ };
+ DataBroker::Publish(&imuData);
+
+ ThermocoupleData thermData = {
+ .temperature = -52,
+ };
+ DataBroker::Publish(&thermData);
+ }
+ }
+}
+
+/**
+ * @brief Handles a command
+ * @param cm Command reference to handle
+ */
+void PubSubSend::HandleCommand(Command& cm) {
+ switch (cm.GetCommand()) {
+ default:
+ SOAR_PRINT("PubSubSend - Received Unsupported Command {%d}\n", cm.GetCommand());
+ break;
+ }
+
+ // No matter what we happens, we must reset allocated data
+ cm.Reset();
+}
diff --git a/Components/RateDistributor/Inc/RateDistributor.hpp b/Components/RateDistributor/Inc/RateDistributor.hpp
new file mode 100644
index 0000000..27f8359
--- /dev/null
+++ b/Components/RateDistributor/Inc/RateDistributor.hpp
@@ -0,0 +1,63 @@
+/*
+ * RateDistributor.hpp
+ *
+ * Created on: Mar 15, 2025
+ * Author: Local user
+ */
+
+#ifndef INC_RATEDISTRIBUTOR_HPP_
+#define INC_RATEDISTRIBUTOR_HPP_
+
+#define MAX_RATED_SUBSCRIBERS 10
+#define MAX_RAW_SAMPLES 1000
+#include
+
+ // is called by a rated subscriber when it wants a sample
+ void RatedCallback(TimerHandle_t timer) {
+
+ RatedSubscriber* subs = static_cast(pvTimerGetTimerID(timer));
+
+ Command brokerData(DATA_BROKER_COMMAND);
+
+ uint8_t* messsageData = reinterpret_cast(subs->getDataArray());
+
+ // copy data to command
+ brokerData.CopyDataToCommand(messsageData, subs->getDataSize());
+
+ subs->getSubscriber().getSubscriberQueueHandle()->Send(brokerData);
+
+
+ }
+
+template
+class RateDistributor {
+public:
+
+ bool Subscribe(Queue* subscriber, uint16_t msPerRequest) {
+ SOAR_ASSERT(numRatedSubs < MAX_RATED_SUBSCRIBERS, "Too many subscribers");
+
+ ratedsubs[numRatedSubs] = RatedSubscriber{Subscriber(),msPerRequest,&ratedsubs[numRatedSubs],RatedCallback,sizeof(T),&rawsamples};
+ ratedsubs[numRatedSubs].getSubscriber().Init(subscriber);
+ numRatedSubs++;
+
+ return true;
+ }
+
+ void AddSample(T& sample) {
+ SOAR_ASSERT(numSamples < MAX_RAW_SAMPLES,"Too many samples. todo: circular buffer");
+
+ rawsamples[numSamples] = sample;
+ numSamples++;
+ }
+
+private:
+
+ RatedSubscriber ratedsubs[MAX_RATED_SUBSCRIBERS];
+ uint16_t numRatedSubs = 0;
+ T rawsamples[MAX_RAW_SAMPLES];
+ uint32_t numSamples;
+
+};
+
+
+#endif /* INC_RATEDISTRIBUTOR_HPP_ */
diff --git a/Components/RateDistributor/Inc/RatedSubscriber.hpp b/Components/RateDistributor/Inc/RatedSubscriber.hpp
new file mode 100644
index 0000000..733b236
--- /dev/null
+++ b/Components/RateDistributor/Inc/RatedSubscriber.hpp
@@ -0,0 +1,67 @@
+/*
+ * RatedSubscriber.hpp
+ *
+ * Created on: Mar 15, 2025
+ * Author: Local user
+ */
+
+#ifndef INC_RATEDSUBSCRIBER_HPP_
+#define INC_RATEDSUBSCRIBER_HPP_
+
+#include "Subscriber.hpp"
+
+class RatedSubscriber {
+public:
+
+ RatedSubscriber(Subscriber subscriber, uint16_t msPerRequest, RatedSubscriber* subscriberID, TimerCallbackFunction_t callback, uint32_t dataSize, void* dataArray)
+ : msPerRequest(msPerRequest), subscriber(subscriber), dataSize(dataSize), dataArray(dataArray) {
+ timer = xTimerCreate("ratetimer", msPerRequest, pdTRUE, (void*)subscriberID, callback);
+ xTimerStart(timer,0);
+
+ }
+
+ RatedSubscriber()
+ : msPerRequest(0), subscriber(), dataSize(0)
+ {
+
+ }
+
+ const uint16_t getMsPerRequest() const {
+ return msPerRequest;
+ }
+
+ Subscriber& getSubscriber() {
+ return subscriber;
+ }
+
+ void operator=(const RatedSubscriber& other) {
+ this->msPerRequest = other.msPerRequest;
+ subscriber = other.subscriber;
+ xTimerDelete(this->timer,0);
+ this->timer = other.timer;
+
+ }
+
+ const uint32_t getDataSize() const {
+ return dataSize;
+ }
+
+ void* getDataArray() const {
+ return dataArray;
+ }
+
+private:
+
+ uint16_t msPerRequest;
+ Subscriber subscriber;
+
+ TimerHandle_t timer;
+
+ const uint32_t dataSize;
+ void* dataArray;
+
+
+};
+
+
+#endif /* INC_RATEDSUBSCRIBER_HPP_ */
diff --git a/Components/RateDistributor/RateDistributor.cpp b/Components/RateDistributor/RateDistributor.cpp
new file mode 100644
index 0000000..70e1eb6
--- /dev/null
+++ b/Components/RateDistributor/RateDistributor.cpp
@@ -0,0 +1,10 @@
+/*
+ * RateDistributor.cpp
+ *
+ * Created on: Mar 15, 2025
+ * Author: Local user
+ */
+
+
+
+
diff --git a/Components/RateDistributor/RateSubscriber.cpp b/Components/RateDistributor/RateSubscriber.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/Components/SoarDebug/DebugTask.cpp b/Components/SoarDebug/DebugTask.cpp
index 31db9ba..e88b036 100644
--- a/Components/SoarDebug/DebugTask.cpp
+++ b/Components/SoarDebug/DebugTask.cpp
@@ -76,6 +76,7 @@ void DebugTask::Run(void* pvParams) {
}
cm.Reset();
+
}
}
diff --git a/Components/SystemDefines.hpp b/Components/SystemDefines.hpp
index 11200f2..0445461 100644
--- a/Components/SystemDefines.hpp
+++ b/Components/SystemDefines.hpp
@@ -28,13 +28,13 @@
/* Cube++ Required Configuration
* ------------------------------------------------------------------*/
#include "CubeDefines.hpp"
-constexpr UARTDriver* const DEFAULT_DEBUG_UART_DRIVER =
- UART::Debug; // UART Handle that ASSERT messages are sent over
+constexpr UARTDriver* const DEFAULT_DEBUG_UART_DRIVER = UART::Debug; // UART Handle that ASSERT messages are sent over
enum GLOBAL_COMMANDS : uint8_t {
COMMAND_NONE = 0, // No command, packet can probably be ignored
TASK_SPECIFIC_COMMAND, // Runs a task specific command when given this object
- DATA_COMMAND, // Data command, used to send data to a task. Target is stored
- // in taskCommand
+ DATA_COMMAND, // Data command, used to send data to a task. Target is stored
+ // in taskCommand
+ DATA_BROKER_COMMAND,
};
/* Cube++ Optional Code Configuration
@@ -46,17 +46,34 @@ enum GLOBAL_COMMANDS : uint8_t {
* ---------------------------------*/
// UART TASK
-constexpr uint8_t UART_TASK_RTOS_PRIORITY = 2; // Priority of the uart task
-constexpr uint8_t UART_TASK_QUEUE_DEPTH_OBJS =
- 10; // Size of the uart task queue
-constexpr uint16_t UART_TASK_STACK_DEPTH_WORDS =
- 512; // Size of the uart task stack
+constexpr uint8_t UART_TASK_RTOS_PRIORITY = 2; // Priority of the uart task
+constexpr uint8_t UART_TASK_QUEUE_DEPTH_OBJS = 10; // Size of the uart task queue
+constexpr uint16_t UART_TASK_STACK_DEPTH_WORDS = 512; // Size of the uart task stack
// DEBUG TASK
-constexpr uint8_t TASK_DEBUG_PRIORITY = 2; // Priority of the debug task
-constexpr uint8_t TASK_DEBUG_QUEUE_DEPTH_OBJS =
- 10; // Size of the debug task queue
-constexpr uint16_t TASK_DEBUG_STACK_DEPTH_WORDS =
- 512; // Size of the debug task stack
+constexpr uint8_t TASK_DEBUG_PRIORITY = 2; // Priority of the debug task
+constexpr uint8_t TASK_DEBUG_QUEUE_DEPTH_OBJS = 10; // Size of the debug task queue
+constexpr uint16_t TASK_DEBUG_STACK_DEPTH_WORDS = 512; // Size of the debug task stack
+
+//FSB PROTOCOL
+constexpr uint8_t TASK_FSB_PROTOCOL_PRIORITY = 2; // Priority of the fsb task
+constexpr uint8_t TASK_FSB_PROTOCOL_DEPTH_OBJS = 10; // Size of the fsb task queue
+constexpr uint16_t TASK_FSB_PROTOCOL_DEPTH_WORDS = 512; // Size of the fsb task stack
+
+//LOGGING TASK
+constexpr uint8_t LOGGING_TASK_PRIORITY = 2; // Priority of the task
+constexpr uint8_t LOGGING_TASK_DEPTH_OBJS = 10; // Size of the fsb task queue
+constexpr uint16_t LOGGING_TASK_DEPTH_WORDS = 512; // Size of the fsb task stack
+
+
+// PUBSUB SEND Task
+constexpr uint8_t PUBSUB_SEND_TASK_RTOS_PRIORITY = 1; // Priority of the pubsub send task
+constexpr uint8_t PUBSUB_SEND_TASK_QUEUE_DEPTH_OBJS = 10; // Size of the pubsub send task queue
+constexpr uint16_t PUBSUB_SEND_TASK_STACK_DEPTH_WORDS = 512; // Size of the pubsub send task stack
+
+// PUBSUB RECEIVE Task
+constexpr uint8_t PUBSUB_RECEIVE_TASK_RTOS_PRIORITY = 1; // Priority of the pubsub receive task
+constexpr uint8_t PUBSUB_RECEIVE_TASK_QUEUE_DEPTH_OBJS = 10; // Size of the pubsub receive task queue
+constexpr uint16_t PUBSUB_RECEIVE_TASK_STACK_DEPTH_WORDS = 512; // Size of the pubsub receive task stack
#endif // CUBE_MAIN_SYSTEM_DEFINES_H
diff --git a/Components/SystemTypes/SensorDataTypes.hpp b/Components/SystemTypes/SensorDataTypes.hpp
deleted file mode 100644
index fade876..0000000
--- a/Components/SystemTypes/SensorDataTypes.hpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- ********************************************************************************
- * @file SensorDataTypes.hpp
- * @author Shivam Desai
- * @date Nov 3, 2024
- * @brief General sensor data structure to pass around in the system or
- *log it to flash memory
- ********************************************************************************
- */
-
-#ifndef SENSORDATATYPES_HPP_
-#define SENSORDATATYPES_HPP_
-
-/************************************
- * MACROS AND DEFINES
- ************************************/
-
-/************************************
- * TYPEDEFS
- ************************************/
-
-#endif /* SENSORDATATYPES_HPP_ */
diff --git a/Components/SystemTypes/SystemCommunicationTypes.hpp b/Components/SystemTypes/SystemCommunicationTypes.hpp
deleted file mode 100644
index e3d046b..0000000
--- a/Components/SystemTypes/SystemCommunicationTypes.hpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- ********************************************************************************
- * @file SystemCommunicationTypes.hpp
- * @author Shivam Desai
- * @date Nov 3, 2024
- * @brief Data structures to pass around other system information such as
- * commands, events or state information
- ********************************************************************************
- */
-
-#ifndef SYSTEMCOMMUNICATIONTYPES_HPP_
-#define SYSTEMCOMMUNICATIONTYPES_HPP_
-
-/************************************
- * MACROS AND DEFINES
- ************************************/
-
-/************************************
- * TYPEDEFS
- ************************************/
-
-#endif /* SYSTEMCOMMUNICATIONTYPES_HPP_ */
diff --git a/Components/SystemTypes/SystemConfigTypes.hpp b/Components/SystemTypes/SystemConfigTypes.hpp
deleted file mode 100644
index 578f097..0000000
--- a/Components/SystemTypes/SystemConfigTypes.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- ********************************************************************************
- * @file SystemConfigTypes.hpp
- * @author Shivam Desai
- * @date Nov 3, 2024
- * @brief Defines that allow the system to build with different
- *functionality by changing the value of the define in this file
- ********************************************************************************
- */
-
-#ifndef SYSTEMCONFIGTYPES_HPP_
-#define SYSTEMCONFIGTYPES_HPP_
-
-/************************************
- * MACROS AND DEFINES
- ************************************/
-
-#endif /* SYSTEMCONFIGTYPES_HPP_ */
diff --git a/Components/main_avionics.cpp b/Components/main_avionics.cpp
index fa0164b..9d1a497 100644
--- a/Components/main_avionics.cpp
+++ b/Components/main_avionics.cpp
@@ -10,6 +10,8 @@
#include "SystemDefines.hpp"
#include "UARTDriver.hpp"
#include "CubeTask.hpp"
+#include "PubSubReceive.hpp"
+#include "PubSubSend.hpp"
/* Drivers ------------------------------------------------------------------*/
namespace Driver {
@@ -26,16 +28,15 @@ void run_main() {
// Init Tasks
CubeTask::Inst().InitTask();
DebugTask::Inst().InitTask();
+ PubSubReceive::Inst().InitTask();
+ PubSubSend::Inst().InitTask();
// Print System Boot Info : Warning, don't queue more than 10 prints before
// scheduler starts
SOAR_PRINT("\n-- CUBE SYSTEM --\n");
- SOAR_PRINT(
- "System Reset Reason: [TODO]\n"); // TODO: System reset reason can be
- // implemented via. Flash storage
+ SOAR_PRINT("System Reset Reason: [TODO]\n"); // TODO: System reset reason can be implemented via. Flash storage
SOAR_PRINT("Current System Free Heap: %d Bytes\n", xPortGetFreeHeapSize());
- SOAR_PRINT("Lowest Ever Free Heap: %d Bytes\n\n",
- xPortGetMinimumEverFreeHeapSize());
+ SOAR_PRINT("Lowest Ever Free Heap: %d Bytes\n\n", xPortGetMinimumEverFreeHeapSize());
// Start the Scheduler
// Guidelines:
diff --git a/SoarOS b/SoarOS
index 038a687..3548484 160000
--- a/SoarOS
+++ b/SoarOS
@@ -1 +1 @@
-Subproject commit 038a687ec48f894996084122b590058398fffc7d
+Subproject commit 35484847eb9796223014863b2044d413c7719a77
diff --git a/SoarProtobufs b/SoarProtobufs
new file mode 160000
index 0000000..711d668
--- /dev/null
+++ b/SoarProtobufs
@@ -0,0 +1 @@
+Subproject commit 711d668f5680ec801389f98f42d8ab1a55fbd2e7