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

Marcelo/protocol transport #7

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4df22cd
ported SOARProto from AvionicsSoftware
VioletLiGonzales May 6, 2023
3fde019
Merge branch 'main' into Marcelo/ProtocolTransport
VioletLiGonzales May 27, 2023
0a0f0d5
Merge branch 'main' into Marcelo/ProtocolTransport
VioletLiGonzales May 27, 2023
7873765
port RCUProtocolTask
VioletLiGonzales Jun 2, 2023
3724f0e
actually port protocol task
VioletLiGonzales Jun 2, 2023
7d5d6cc
changed PI UART to use 115200 baud rate and 8 bit words
VioletLiGonzales Jun 2, 2023
4303a6f
added UART task send cases, enabled interrupts on PI UART
VioletLiGonzales Jun 2, 2023
1080e77
enabled other UART lines interrupts
VioletLiGonzales Jun 2, 2023
60fca01
Update Avionics Core / Utils
cjchanx Jun 2, 2023
8e7f2e9
ported the correct repeater task template into SOBRxTask this time XD
VioletLiGonzales Jun 2, 2023
f6b94ec
Merge branch 'Chris/UpdateCoreUtils' into Marcelo/ProtocolTransport
VioletLiGonzales Jun 2, 2023
b4f3575
actually commited the file this time
VioletLiGonzales Jun 2, 2023
7f1d281
added cases for UART task and added DMBRx and PIRX tasks
VioletLiGonzales Jun 2, 2023
1924f5c
added DMBRx protobuf handles
VioletLiGonzales Jun 2, 2023
2d21020
added PIRx protobuf handles
VioletLiGonzales Jun 2, 2023
eef71df
updated git ignore
VioletLiGonzales Jun 2, 2023
dbe077b
updated SoarProto submodule commit pointer
VioletLiGonzales Jun 2, 2023
67e586d
changed baudrate to 57600 because 115200 is not working for some reason
VioletLiGonzales Jun 3, 2023
9c902f3
changed SUART3 to not have hardware control and to use 57600 baudrate
VioletLiGonzales Jun 3, 2023
d822ef1
fixed the dumbest bug in existance, right wrap it gals this is rock b…
VioletLiGonzales Jun 3, 2023
ffcf0fa
added minor comments
VioletLiGonzales Jun 3, 2023
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
40 changes: 36 additions & 4 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 @@ -22,6 +22,7 @@

# Executables
build/
Debug/*
*.exe
*.out
*.app
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Components/SoarProtocol/SoarProto"]
path = Components/SoarProtocol/SoarProto
url = [email protected]:StudentOrganisationForAerospaceResearch/SoarProto.git
4 changes: 2 additions & 2 deletions .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1110344888987081543" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-175912248659748409" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1110342408155303648" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-175911365609942034" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
4 changes: 2 additions & 2 deletions .settings/stm32cubeide.project.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
66BE74F758C12D739921AEA421D593D3=0
8DF89ED150041C4CBC7CB9A9CAA90856=20DC75955B86F89F3643A2AE9216343C
DC22A860405A8BF2F2C095E5B6529F12=20DC75955B86F89F3643A2AE9216343C
8DF89ED150041C4CBC7CB9A9CAA90856=FC9055A67881517C9FBBF9ADE1A1E100
DC22A860405A8BF2F2C095E5B6529F12=FC9055A67881517C9FBBF9ADE1A1E100
eclipse.preferences.version=1
6 changes: 5 additions & 1 deletion Components/Communication/Inc/UARTTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
enum UART_TASK_COMMANDS {
UART_TASK_COMMAND_NONE = 0,
UART_TASK_COMMAND_SEND_DEBUG,
UART_TASK_COMMAND_MAX
UART_TASK_COMMAND_MAX,
UART_TASK_COMMAND_SEND_DMB,
UART_TASK_COMMAND_SEND_SOB,
UART_TASK_COMMAND_SEND_PBB,
UART_TASK_COMMAND_SEND_PI
};


Expand Down
12 changes: 12 additions & 0 deletions Components/Communication/UARTTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ void UARTTask::HandleCommand(Command& cm)
case UART_TASK_COMMAND_SEND_DEBUG:
HAL_UART_Transmit(SystemHandles::UART_Debug, cm.GetDataPointer(), cm.GetDataSize(), DEBUG_SEND_MAX_TIME_MS);
break;
case UART_TASK_COMMAND_SEND_DMB:
HAL_UART_Transmit(SystemHandles::UART_Radio, cm.GetDataPointer(), cm.GetDataSize(), DEBUG_SEND_MAX_TIME_MS);
break;
case UART_TASK_COMMAND_SEND_SOB:
HAL_UART_Transmit(SystemHandles::UART_SOB, cm.GetDataPointer(), cm.GetDataSize(), DEBUG_SEND_MAX_TIME_MS);
break;
case UART_TASK_COMMAND_SEND_PBB:
HAL_UART_Transmit(SystemHandles::UART_Radio, cm.GetDataPointer(), cm.GetDataSize(), DEBUG_SEND_MAX_TIME_MS);
break;
case UART_TASK_COMMAND_SEND_PI:
HAL_UART_Transmit(SystemHandles::UART_PI, cm.GetDataPointer(), cm.GetDataSize(), DEBUG_SEND_MAX_TIME_MS);
break;
default:
SOAR_PRINT("UARTTask - Received Unsupported DATA_COMMAND {%d}\n", cm.GetTaskCommand());
break;
Expand Down
24 changes: 13 additions & 11 deletions Components/Core/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Command.hpp"
#include "SystemDefines.hpp"

#include <cstring> // Support for memcpy
#include <cstring> // Support for memcpy

/* Static Variable Init ------------------------------------------------------------------*/
std::atomic<uint16_t> Command::statAllocationCounter; // Static variable init
Expand Down Expand Up @@ -83,9 +83,9 @@ Command::Command(GLOBAL_COMMANDS command, uint16_t taskCommand)
/**
* @brief Dynamically allocates memory for the command with the given data size
* @param dataSize Size of array to allocate
* @return TRUE on success, FALSE on failure (mem already allocated)
* @return Pointer to data on success, nullptr on failure (mem already allocated)
*/
bool Command::AllocateData(uint16_t dataSize)
uint8_t* Command::AllocateData(uint16_t dataSize)
{
// If we don't have anything allocated, allocate and return success
if (this->data == nullptr && !bShouldFreeData) {
Expand All @@ -96,9 +96,9 @@ bool Command::AllocateData(uint16_t dataSize)

//TODO: May want to print out whenever we have an imbalance in statAllocationCounter by more than ~5 or so.
SOAR_ASSERT(statAllocationCounter < MAX_NUMBER_OF_COMMAND_ALLOCATIONS);
return true;
return this->data;
}
return false;
return nullptr;
}

/**
Expand Down Expand Up @@ -127,14 +127,14 @@ bool Command::SetCommandToStaticExternalBuffer(uint8_t* existingPtr, uint16_t si
*/
bool Command::CopyDataToCommand(uint8_t* dataSrc, uint16_t size)
{
// If we successfully allocate, copy the data and return success
// If we successfully allocate, copy the data and return success
if(this->AllocateData(size)
&& this->data != nullptr) {
memcpy(this->data, dataSrc, size);
return true;
}
&& this->data != nullptr) {
memcpy(this->data, dataSrc, size);
return true;
}

return false;
return false;
}

/**
Expand All @@ -145,6 +145,8 @@ void Command::Reset()
if(bShouldFreeData && data != nullptr) {
soar_free(data);
statAllocationCounter -= 1;
data = nullptr;
bShouldFreeData = false;
}
}

Expand Down
56 changes: 29 additions & 27 deletions Components/Core/Inc/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
******************************************************************************
* File Name : Command.hpp
* Description : Command is a unique object used to communicate information
* to and between tasks.
* to and between tasks.
******************************************************************************
*/
#ifndef AVIONICS_INCLUDE_SOAR_CORE_COMMAND_H
Expand All @@ -21,7 +21,8 @@ enum GLOBAL_COMMANDS : uint8_t
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
CONTROL_ACTION, // Control actions, used in Rocket State Machine, direct translation to RCU<->DMB Protocol
REQUEST_COMMAND // Request command
REQUEST_COMMAND, // Request command
PROTOCOL_COMMAND, // Protocol command, used for commands to the Protocol Task
};

/* Class -----------------------------------------------------------------*/
Expand All @@ -36,44 +37,45 @@ enum GLOBAL_COMMANDS : uint8_t
class Command
{
public:
Command(void);
Command(GLOBAL_COMMANDS command);
Command(uint16_t taskCommand);
Command(GLOBAL_COMMANDS command, uint16_t taskCommand);
Command(void);
Command(GLOBAL_COMMANDS command);
Command(uint16_t taskCommand);
Command(GLOBAL_COMMANDS command, uint16_t taskCommand);

//~Command(); // We can't handle memory like this, since the object would be 'destroyed' after copying to the RTOS queue
//~Command(); // We can't handle memory like this, since the object would be 'destroyed' after copying to the RTOS queue

// Functions
bool AllocateData(uint16_t dataSize); // Dynamically allocates data for the command
bool CopyDataToCommand(uint8_t* dataSrc, uint16_t size); // Copies the data into the command, into newly allocated memory
bool SetCommandToStaticExternalBuffer(uint8_t* existingPtr, uint16_t size); // Set data pointer to a pre-allocated buffer, if bFreeMemory is set to true, responsibility for freeing memory will fall on Command
// Functions
uint8_t* AllocateData(uint16_t dataSize); // Dynamically allocates data for the command
bool CopyDataToCommand(uint8_t* dataSrc, uint16_t size); // Copies the data into the command, into newly allocated memory
bool SetCommandToStaticExternalBuffer(uint8_t* existingPtr, uint16_t size); // Set data pointer to a pre-allocated buffer, if bFreeMemory is set to true, responsibility for freeing memory will fall on Command

void Reset(); // Reset the command, equivalent of a destructor that must be called, counts allocations and deallocations, asserts an error if the allocation count is too high
void Reset(); // Reset the command, equivalent of a destructor that must be called, counts allocations and deallocations, asserts an error if the allocation count is too high

// Getters
uint16_t GetDataSize() const;
uint8_t* GetDataPointer() const { return data; }
GLOBAL_COMMANDS GetCommand() const { return command; }
uint16_t GetTaskCommand() const { return taskCommand; }
// Getters
uint16_t GetDataSize() const;
uint8_t* GetDataPointer() const { return data; }
GLOBAL_COMMANDS GetCommand() const { return command; }
uint16_t GetTaskCommand() const { return taskCommand; }

// Setters
void SetTaskCommand(uint16_t taskCommand) { this->taskCommand = taskCommand; }
// Setters
void SetTaskCommand(uint16_t taskCommand) { this->taskCommand = taskCommand; }
void SetDataSize(uint16_t size) { dataSize = size; }


protected:
// Data -- note each insertion and removal from a queue will do a full copy of this object, so this data should be as small as possible
GLOBAL_COMMANDS command; // General GLOBAL command, each task must be able to handle these types of commands
uint16_t taskCommand; // Task specific command, the task this command event is sent to needs to handle this
// Data -- note each insertion and removal from a queue will do a full copy of this object, so this data should be as small as possible
GLOBAL_COMMANDS command; // General GLOBAL command, each task must be able to handle these types of commands
uint16_t taskCommand; // Task specific command, the task this command event is sent to needs to handle this

uint8_t* data; // Pointer to optional data
uint16_t dataSize; // Size of optional data
uint8_t* data; // Pointer to optional data
uint16_t dataSize; // Size of optional data

private:
bool bShouldFreeData; // Should the Command handle freeing the data pointer (necessary to enable Command object to handle static memory ptrs)
bool bShouldFreeData; // Should the Command handle freeing the data pointer (necessary to enable Command object to handle static memory ptrs)

static std::atomic<uint16_t> statAllocationCounter; // Static allocation counter shared by all command objects
static std::atomic<uint16_t> statAllocationCounter; // Static allocation counter shared by all command objects

Command(const Command&); // Prevent copy-construction
Command(const Command&); // Prevent copy-construction
};

#endif /* AVIONICS_INCLUDE_SOAR_CORE_COMMAND_H */
82 changes: 0 additions & 82 deletions Components/Core/Inc/Command.hpp.orig

This file was deleted.

14 changes: 7 additions & 7 deletions Components/Core/Inc/DMAController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
class DMAController
{
public:
// Constructors
DMAController(void);
// Constructors
DMAController(void);

// Functions
// Functions

// Getters
// Getters

// Setters
// Setters

// Static/Setup
static void SetupCallbacks(); // Register the DMA callbacks
// Static/Setup
static void SetupCallbacks(); // Register the DMA callbacks

protected:

Expand Down
14 changes: 7 additions & 7 deletions Components/Core/Inc/Mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
class Mutex
{
public:
// Constructors / Destructor
Mutex();
~Mutex();
// Constructors / Destructor
Mutex();
~Mutex();

// Public functions
bool Lock(uint32_t timeout_ms = portMAX_DELAY);
bool Unlock();
// Public functions
bool Lock(uint32_t timeout_ms = portMAX_DELAY);
bool Unlock();

private:
SemaphoreHandle_t rtSemaphoreHandle;
SemaphoreHandle_t rtSemaphoreHandle;

};

Expand Down
1 change: 1 addition & 0 deletions Components/Core/Inc/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Task {

Queue* GetEventQueue() const { return qEvtQueue; }
void SendCommand(Command cmd) { qEvtQueue->Send(cmd); }
void SendCommandReference(Command& cmd) { qEvtQueue->Send(cmd); }

protected:
//RTOS
Expand Down
Loading