From 01cad30544cea94dc66b442df22564f53d6ba516 Mon Sep 17 00:00:00 2001 From: "[gracejang]" Date: Sat, 11 Nov 2023 12:05:05 -0700 Subject: [PATCH 1/2] test --- Components/FlightControl/FlightTask.cpp | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Components/FlightControl/FlightTask.cpp b/Components/FlightControl/FlightTask.cpp index aac6f0bf..60394d2e 100644 --- a/Components/FlightControl/FlightTask.cpp +++ b/Components/FlightControl/FlightTask.cpp @@ -23,11 +23,11 @@ FlightTask::FlightTask() : Task(FLIGHT_TASK_QUEUE_DEPTH_OBJS) { /** * @brief Initialize the FlightTask */ -void FlightTask::InitTask() { + void FlightTask::InitTask() { // Make sure the task is not already initialized SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize flight task twice"); - BaseType_t rtValue = xTaskCreate( + BaseType_t rtValue = xTaskCreate( (TaskFunction_t)FlightTask::RunTask, (const char*)"FlightTask", (uint16_t)FLIGHT_TASK_STACK_DEPTH_WORDS, (void*)this, (UBaseType_t)FLIGHT_TASK_RTOS_PRIORITY, (TaskHandle_t*)&rtTaskHandle); @@ -45,11 +45,11 @@ void FlightTask::Run(void* pvParams) { SPIFlash::Inst().Init(); //Initialize the Timer Transitions - TimerTransitions::Inst().Setup(); + TimerTransitions::Inst().Setup(); //Get the latest state from the system storage SystemState sysState; - bool stateReadSuccess = SystemStorage::Inst().Read(sysState); + bool stateReadSuccess = SystemStorage::Inst().Read(sysState); if (stateReadSuccess == true) { // Succeded to read state, initialize the rocket state machine @@ -61,7 +61,7 @@ void FlightTask::Run(void* pvParams) { } rsm_ = new RocketSM(sysState.rocketState, true); - } else { + } else { // Failed to read state, start in default state //TODO: Should implement a backup SimpleSectorStorage that is written to/read only once //TODO: where after the LAUNCH state, the default state becomes RS_COAST (or whatever is safest) @@ -69,7 +69,7 @@ void FlightTask::Run(void* pvParams) { rsm_ = new RocketSM(RS_ABORT, true); } - while (1) { + while (1) { // There's effectively 3 types of tasks... 'Async' and 'Synchronous-Blocking' and 'Synchronous-Non-Blocking' // Asynchronous tasks don't require a fixed-delay and can simply delay using xQueueReceive, it will immedietly run the next task // cycle as soon as it gets an event. @@ -89,9 +89,9 @@ void FlightTask::Run(void* pvParams) { // or maybe HID (Human Interface Device) task that handles both updating buzzer frequencies and LED states. //Process commands in blocking mode (TODO: Change to instant-processing once complete HID/DisplayTask) - Command cm; + Command cm; bool res = qEvtQueue->ReceiveWait(cm); - if (res) + if (res) HandleCommand(cm); //osDelay(FLIGHT_PHASE_DISPLAY_FREQ); @@ -129,15 +129,15 @@ void FlightTask::Run(void* pvParams) { } /** - * @brief Handle a command from the Command Queue + * @brief Handle a command from the Command Queue * @param cm Command to handle */ -void FlightTask::HandleCommand(Command& cm) { + void FlightTask::HandleCommand(Command& cm) { // If this is a request command, we handle it in the task (rocket state command must always be control actions) - if (cm.GetCommand() == REQUEST_COMMAND && + if (cm.GetCommand() == REQUEST_COMMAND && cm.GetTaskCommand() == FT_REQUEST_TRANSMIT_STATE) SendRocketState(); - else + else rsm_->HandleCommand(cm); // Make sure the command is reset @@ -147,16 +147,16 @@ void FlightTask::HandleCommand(Command& cm) { /** * @brief Sends rocket state commands to the RCU */ -void FlightTask::SendRocketState() { + void FlightTask::SendRocketState() { // For testing, generate a PROTOBUF message and send it to the Protocol Task Proto::ControlMessage msg; - msg.set_source(Proto::Node::NODE_DMB); - msg.set_target(Proto::Node::NODE_RCU); - msg.set_message_id(Proto::MessageID::MSG_CONTROL); - Proto::SystemState stateMsg; - stateMsg.set_sys_state(Proto::SystemState::State::SYS_NORMAL_OPERATION); - stateMsg.set_rocket_state(rsm_->GetRocketStateAsProto()); - msg.set_sys_state(stateMsg); + msg.set_source(Proto::Node::NODE_DMB); + msg.set_target(Proto::Node::NODE_RCU); + msg.set_message_id(Proto::MessageID::MSG_CONTROL); + Proto::SystemState stateMsg; + stateMsg.set_sys_state(Proto::SystemState::State::SYS_NORMAL_OPERATION); + stateMsg.set_rocket_state(rsm_->GetRocketStateAsProto()); + msg.set_sys_state(stateMsg); EmbeddedProto::WriteBufferFixedSize writeBuffer; From cfdb0bcadae41865d9decb8f2977c84eaaebd4f8 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 11 Nov 2023 19:05:56 +0000 Subject: [PATCH 2/2] Apply clang-format --- Components/FlightControl/FlightTask.cpp | 38 ++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Components/FlightControl/FlightTask.cpp b/Components/FlightControl/FlightTask.cpp index 60394d2e..b2c1953b 100644 --- a/Components/FlightControl/FlightTask.cpp +++ b/Components/FlightControl/FlightTask.cpp @@ -23,11 +23,11 @@ FlightTask::FlightTask() : Task(FLIGHT_TASK_QUEUE_DEPTH_OBJS) { /** * @brief Initialize the FlightTask */ - void FlightTask::InitTask() { +void FlightTask::InitTask() { // Make sure the task is not already initialized SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize flight task twice"); - BaseType_t rtValue = xTaskCreate( + BaseType_t rtValue = xTaskCreate( (TaskFunction_t)FlightTask::RunTask, (const char*)"FlightTask", (uint16_t)FLIGHT_TASK_STACK_DEPTH_WORDS, (void*)this, (UBaseType_t)FLIGHT_TASK_RTOS_PRIORITY, (TaskHandle_t*)&rtTaskHandle); @@ -45,11 +45,11 @@ void FlightTask::Run(void* pvParams) { SPIFlash::Inst().Init(); //Initialize the Timer Transitions - TimerTransitions::Inst().Setup(); + TimerTransitions::Inst().Setup(); //Get the latest state from the system storage SystemState sysState; - bool stateReadSuccess = SystemStorage::Inst().Read(sysState); + bool stateReadSuccess = SystemStorage::Inst().Read(sysState); if (stateReadSuccess == true) { // Succeded to read state, initialize the rocket state machine @@ -61,7 +61,7 @@ void FlightTask::Run(void* pvParams) { } rsm_ = new RocketSM(sysState.rocketState, true); - } else { + } else { // Failed to read state, start in default state //TODO: Should implement a backup SimpleSectorStorage that is written to/read only once //TODO: where after the LAUNCH state, the default state becomes RS_COAST (or whatever is safest) @@ -69,7 +69,7 @@ void FlightTask::Run(void* pvParams) { rsm_ = new RocketSM(RS_ABORT, true); } - while (1) { + while (1) { // There's effectively 3 types of tasks... 'Async' and 'Synchronous-Blocking' and 'Synchronous-Non-Blocking' // Asynchronous tasks don't require a fixed-delay and can simply delay using xQueueReceive, it will immedietly run the next task // cycle as soon as it gets an event. @@ -89,9 +89,9 @@ void FlightTask::Run(void* pvParams) { // or maybe HID (Human Interface Device) task that handles both updating buzzer frequencies and LED states. //Process commands in blocking mode (TODO: Change to instant-processing once complete HID/DisplayTask) - Command cm; + Command cm; bool res = qEvtQueue->ReceiveWait(cm); - if (res) + if (res) HandleCommand(cm); //osDelay(FLIGHT_PHASE_DISPLAY_FREQ); @@ -132,12 +132,12 @@ void FlightTask::Run(void* pvParams) { * @brief Handle a command from the Command Queue * @param cm Command to handle */ - void FlightTask::HandleCommand(Command& cm) { +void FlightTask::HandleCommand(Command& cm) { // If this is a request command, we handle it in the task (rocket state command must always be control actions) - if (cm.GetCommand() == REQUEST_COMMAND && + if (cm.GetCommand() == REQUEST_COMMAND && cm.GetTaskCommand() == FT_REQUEST_TRANSMIT_STATE) SendRocketState(); - else + else rsm_->HandleCommand(cm); // Make sure the command is reset @@ -147,16 +147,16 @@ void FlightTask::Run(void* pvParams) { /** * @brief Sends rocket state commands to the RCU */ - void FlightTask::SendRocketState() { +void FlightTask::SendRocketState() { // For testing, generate a PROTOBUF message and send it to the Protocol Task Proto::ControlMessage msg; - msg.set_source(Proto::Node::NODE_DMB); - msg.set_target(Proto::Node::NODE_RCU); - msg.set_message_id(Proto::MessageID::MSG_CONTROL); - Proto::SystemState stateMsg; - stateMsg.set_sys_state(Proto::SystemState::State::SYS_NORMAL_OPERATION); - stateMsg.set_rocket_state(rsm_->GetRocketStateAsProto()); - msg.set_sys_state(stateMsg); + msg.set_source(Proto::Node::NODE_DMB); + msg.set_target(Proto::Node::NODE_RCU); + msg.set_message_id(Proto::MessageID::MSG_CONTROL); + Proto::SystemState stateMsg; + stateMsg.set_sys_state(Proto::SystemState::State::SYS_NORMAL_OPERATION); + stateMsg.set_rocket_state(rsm_->GetRocketStateAsProto()); + msg.set_sys_state(stateMsg); EmbeddedProto::WriteBufferFixedSize writeBuffer;