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

Refactor CDH RTOS Codebase #32

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

GrahamDrive
Copy link
Member

Pull Request: Refactor CDH RTOS Codebase

Hello everyone,

If you're listed as a reviewer, it means either you contributed input or this change impacts your task.

Note: The terms "Thread" and "Task" are used interchangeably.

Problem

@Koloss0 pointed out that the CDH RTOS codebase is currently convoluted, as all the code resides in the main function of the project board. This structure makes it challenging for new members to navigate and understand the code when assigned to specific tasks within a given thread.

Solution

To address this, we’ve refactored the code by separating the threads from the main file into their own dedicated files. The code has been organized into a new directory structure, as shown below:

Directory Structure

The top-level directory is named app, which contains both Inc and Src folders. These folders house various files as follows:

  • bdot_algorithm
    Contains all application code related to the B Dot Algorithm, which the ADCS will work on.

  • command_handling
    Contains application code for handling CAN messages and commands.

  • deployment_tasks
    Contains application code related to deploying the antenna and other deployables on the satellite.

  • rtc
    Contains tasks related to the Real-Time Clock (RTC).

  • task_control
    Contains tasks for interacting with other tasks, such as starting timed tasks and retrieving the number of tasks.

  • telemetry_handling
    Contains code for telemetry handling tasks.

  • unit_tests
    Contains unit tests for the various peripherals.

Next Steps

Merging will not occur until testing with physical hardware is also complete.

extern osThreadId_t timeTagTaskInitQueueHandle;
extern osThreadId_t setRTCQueueHandle;
extern osThreadId_t getRTCHandle;

Copy link
Member Author

Choose a reason for hiding this comment

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

Not a fan of these externs if people have suggestions lmk.

Copy link

@Koloss0 Koloss0 left a comment

Choose a reason for hiding this comment

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

Looks good. I wrote down my thoughts on some minor things:

  • consider renaming to App/
  • what is the void *argument for?
  • it's a matter of style, but 90% of what's in the .h files could be moved to the .c files (i.e. includes and externs). But psychologically I understand the desire to put dependencies in one file and implementation in the other. Personally I just put as much as I can in the implementation file until I get an error.
  • People using STM32IDE will have to refresh their file explorer to see the new directory. (just letting you know)
  • This PR includes a .vs/ directory into the NUCLEO project jsyk.
  • Also some CMake files in the NUCLEO project. Not sure if that's on purpose.
  • Looks like the build directory isn't in the gitignore of the NUCLEO project.

@GrahamDrive
Copy link
Member Author

Idk why those CMAKES are even there I didn't modify or build that project.

@GrahamDrive
Copy link
Member Author

Couldn't easily get rid of CMAKES giving up for this pull request.

@Koloss0
Copy link

Koloss0 commented Feb 17, 2025

😂 I understand your pain. You have to do it in a very specific way since it's already been committed. I'll see if I can remember how.

@Koloss0 Koloss0 force-pushed the Update-Threads-External branch from 5eb5e15 to df8e488 Compare February 17, 2025 19:20
@Koloss0 Koloss0 force-pushed the Update-Threads-External branch from df8e488 to 049eb36 Compare February 17, 2025 19:40
@Koloss0
Copy link

Koloss0 commented Feb 17, 2025

@GrahamDrive Fixed everything. I rebased the branch and deleted all the unnecessary commits so your branch will be out of sync and you'll have to do a reset.

This will reset to before the rebase. Note, all history proceeding it will be deleted, as well as any uncommitted changes.
git reset --hard be54371

You can then pull.
git pull

Now you might get an error like this. This is because Git behaves weirdly sometimes with capitalization.

error: The following untracked working tree files would be overwritten by merge:
        cdh-tsat-stm32project-board/App/Inc/bdot_algorithm.h
        cdh-tsat-stm32project-board/App/Inc/command_handling.h
        cdh-tsat-stm32project-board/App/Inc/deployment_tasks.h
        cdh-tsat-stm32project-board/App/Inc/rtc.h
        cdh-tsat-stm32project-board/App/Inc/task_control.h
        cdh-tsat-stm32project-board/App/Inc/telemetry_handling.h
        cdh-tsat-stm32project-board/App/Inc/unit_tests.h
        cdh-tsat-stm32project-board/App/Src/bdot_algorithm.c
        cdh-tsat-stm32project-board/App/Src/command_handling.c
        cdh-tsat-stm32project-board/App/Src/deployment_tasks.c
        cdh-tsat-stm32project-board/App/Src/rtc.c
        cdh-tsat-stm32project-board/App/Src/task_control.c
        cdh-tsat-stm32project-board/App/Src/telemetry_handling.c
        cdh-tsat-stm32project-board/App/Src/unit_tests.c
Please move or remove them before you merge.
Aborting

To fix it, delete the app/ folder from your file explorer. Then pull again.

Unfortunately, I think this error will likely occur for anyone who updates to the new folder name. So they will have to use the fix above as well.

@GrahamDrive
Copy link
Member Author

Awesome thanks @Koloss0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants