Skip to content

Startup tasks#8

Open
Derv6464 wants to merge 2 commits intomainfrom
startup_tasks
Open

Startup tasks#8
Derv6464 wants to merge 2 commits intomainfrom
startup_tasks

Conversation

@Derv6464
Copy link
Copy Markdown
Member

@Derv6464 Derv6464 commented Apr 5, 2026

No description provided.

@Derv6464 Derv6464 requested review from a team, batrick905 and Copilot and removed request for a team April 5, 2026 15:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces “startup” initialization hooks for the firmware tasks and begins standardizing task loop delays via named constants, while also removing editor-specific VS Code configuration files.

Changes:

  • Add init() methods to CAN, Logger, and Canards Controller tasks and invoke them from main().
  • Replace hardcoded osDelay(...) values with header-defined delay constants.
  • Remove auto-generated .vscode configuration files from the firmware directory.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
firmware/src/tasks/logger.h Adds LOGGER_HZ constant and Logger::init() declaration.
firmware/src/tasks/logger.cpp Uses LOGGER_HZ in task loop delay; adds Logger::init() stub.
firmware/src/tasks/canards_controller.h Adds CANARD_HZ constant and Canards_Controller::init() declaration.
firmware/src/tasks/canards_controller.cpp Uses CANARD_HZ in task loop delay; adds Canards_Controller::init() stub.
firmware/src/tasks/can.h Adds CAN_HZ constant and CAN::init() declaration.
firmware/src/tasks/can.cpp Uses CAN_HZ in task loop delay; adds CAN::init() stub.
firmware/src/main.cpp Calls the new init() methods and stores their results.
firmware/.vscode/launch.json Removed PlatformIO debug launch configuration.
firmware/.vscode/extensions.json Removed VS Code extension recommendations.
firmware/.vscode/c_cpp_properties.json Removed auto-generated IntelliSense configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 23 to +27
uint32_t msg;
osMessageQueueGet(&logger_queue_, &msg, 0, 0);
//storage_.write(&msg);
printf("Logged message: %u\n", msg);
osDelay(200);
osDelay(LOGGER_HZ);
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

Logger queue usage looks incorrect and can lead to undefined behavior:

  • The logging queue is created with element size sizeof(task::Logger::LogMessage) (see main.cpp), but here you receive into a uint32_t.
  • osMessageQueueGet expects an osMessageQueueId_t (not the address of it) and should have its return status checked (especially with a 0 timeout) before using/printing the received value.
    Consider receiving a LogMessage (or change the queue element type) and call osMessageQueueGet(logger_queue_, ...) with a blocking timeout or an osOK check.

Copilot uses AI. Check for mistakes.
Comment on lines +13 to 15
#define LOGGER_HZ 200U //ticks

namespace task{
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

LOGGER_HZ is defined as a delay in RTOS ticks (//ticks) but the name suggests a frequency in Hertz. This is easy to misread and can cause incorrect timing changes later (e.g., someone might set it to 200 expecting 200 Hz when it actually delays 200 ticks). Consider renaming to something like LOGGER_DELAY_TICKS/LOGGER_PERIOD_TICKS and prefer static constexpr/inline constexpr over a global #define in a header to avoid macro pollution.

Suggested change
#define LOGGER_HZ 200U //ticks
namespace task{
namespace task{
static constexpr uint32_t LOGGER_PERIOD_TICKS = 200U; // ticks

Copilot uses AI. Check for mistakes.
#include "cmsis_os.h"
#include <cstdio>

#define CANARD_HZ 100U //ticks
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

CANARD_HZ is used as an osDelay(...) argument (ticks/period), but the name reads like a frequency in Hz. This ambiguity is likely to cause incorrect scheduling/timing adjustments. Consider renaming to CANARD_DELAY_TICKS/CANARD_PERIOD_TICKS and using a constexpr constant instead of a global #define in the header.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to 12
#define CAN_HZ 100U //ticks

namespace task{
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

CAN_HZ is passed to osDelay(...) (ticks/period), but the name suggests a frequency in Hertz. This makes the timing semantics unclear and easy to misuse. Consider renaming to CAN_DELAY_TICKS/CAN_PERIOD_TICKS and using a constexpr constant (ideally scoped to the class/translation unit) instead of a header-level #define.

Suggested change
#define CAN_HZ 100U //ticks
namespace task{
namespace task{
inline constexpr uint32_t CAN_DELAY_TICKS = 100U; // ticks

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +66
bool status[3];
status[0] = can_task.init();
status[1] = logger.init();
status[2] = canards_controller.init();

//send status along CAN for telemetry, unless CAN faulty, then oops

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

status is written but never read. If warnings are enabled this becomes an unused-variable warning, and it also obscures whether init failures are handled. Consider either acting on these return values immediately (e.g., abort/enter safe mode, log, or transmit telemetry) or remove the array until the handling is implemented (or explicitly mark it unused).

Suggested change
bool status[3];
status[0] = can_task.init();
status[1] = logger.init();
status[2] = canards_controller.init();
//send status along CAN for telemetry, unless CAN faulty, then oops
if (!can_task.init()) {
Error_Handler();
}
if (!logger.init()) {
Error_Handler();
}
if (!canards_controller.init()) {
Error_Handler();
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants