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

fault handler attempt #93

Merged
merged 7 commits into from
Nov 10, 2023
Merged

fault handler attempt #93

merged 7 commits into from
Nov 10, 2023

Conversation

Rand-Sai
Copy link
Contributor

@Rand-Sai Rand-Sai commented Nov 6, 2023

I modified the "fault.c" file, attempted to use a if loop to pop faults off the queue and made a switch statement to create priorities for tasks.

@Rand-Sai Rand-Sai requested a review from nwdepatie November 6, 2023 19:05
Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

Okay so there is def a bit of work to be done, but solid first attempt. I think I've sent a few reference commits but the typical flow of adding a task is:

  1. create a function with similar parameters to the other vSomething tasks in other files (particularly monitor.c)
  2. create a threadattributes struct, similar to the stuff implemented in monitor.h. These specify the attributes of each task
  3. Actually initialize the task in main.c, there is a bunch of functions grouped together in main that are all initializing the task

Core/Src/fault.c Outdated
@@ -1,3 +1,45 @@
#include "fault.h"

osMessageQueueId_t fault_handle_queue;

//Function to determine priority base on severity
void priority(void) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So this should be the main "task" which we will assign a priority and tell the kernel to schedule on boot. For references on other tasks, check the functions that start with vSomething in monitor.c. These have a thread attribute struct associated with them that we use to initialize in main.c

Core/Src/fault.c Outdated
//Function to determine priority base on severity
void priority(void) {
osThreadId_t id;
MSGQUEUE_OBJ_t msg;
Copy link
Contributor

Choose a reason for hiding this comment

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

So the type of the message that we receive depends on what we are actually queuing, in this case I believe the type is FaultStatus_t or something I forgot exactly what it is

Core/Src/fault.c Outdated
// Wait until a message is in the queue, send messages when they are in the queue
for(;;) {
status = osMessageQueueGet(fault_handle_queue, &msg, NULL, 0U); // wait for message
id = osThreadGetId(); // Obtain ID of current running thread
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to get the ID each time

Core/Src/fault.c Outdated
if (status == osOK) {

// process data
switch (fault_sev_t) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You want to access the severity field of the fault_t or whatever data type you get from the queue. The idea is that we are popping off a fault and then routing to a case for the severity

Core/Src/fault.c Outdated
// process data
switch (fault_sev_t) {
case 'DEFCON1': //Higest(1st) Priority
osThreadSetPriority(id, osPriorityHigh);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to set the priority here, tbh I would just leave this blank for now apart from the break;'s and we will handle faults in a later ticket

@Rand-Sai
Copy link
Contributor Author

Rand-Sai commented Nov 8, 2023

Made edits based on suggestions provided. Used functions from "https://www.keil.com/pack/doc/cmsis/RTOS2/html/group__CMSIS__RTOS__Message.html" as references.

Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

This looks like a solid start

Core/Src/fault.c Outdated
const osThreadAttr_t fault_handle_attributes = {
.name = "FaultHandler",
.stack_size = 128 * 4,
//.priority = (osPriority_t)osPriorityBelowNormal3,
Copy link
Contributor

Choose a reason for hiding this comment

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

Uncommon this

@nwdepatie nwdepatie merged commit 5753e7b into main Nov 10, 2023
1 check passed
@nwdepatie nwdepatie deleted the 83-fault-handler branch November 10, 2023 20:13
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