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
Changes from 1 commit
Commits
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
42 changes: 42 additions & 0 deletions Core/Src/fault.c
Original file line number Diff line number Diff line change
@@ -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

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

osStatus_t status;
// 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

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

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

osThreadSetPriority(id, osPriorityHigh);
break;
case 'DEFCON2': //2nd Highest Priority
osThreadSetPriority(id, osPriorityAboveNormal);
osThreadSetPriority(id, osPriorityAboveNormal);
break;
case 'DEFCON3': //3rd Highest Priority
osThreadSetPriority(id, osPriorityNormal);
osThreadSetPriority(id, osPriorityNormal);
break;
case 'DEFCON4': //Slight Above Lowest Priority
osThreadSetPriority(id, osPriorityBelowNormal);
osThreadSetPriority(id, osPriorityBelowNormal);
break;
case 'DEFCON5': //Lowest Priority
osThreadSetPriority(id, osPriorityLow);
osThreadSetPriority(id, osPriorityLow);
break;
default: //Unable To Identify 'fault_sev_t'
osThreadSetPriority(id, osPriorityIdle);
osThreadSetPriority(id, osPriorityIdle);
break;
}
}
}
}
Loading