-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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:
- create a function with similar parameters to the other
vSomething
tasks in other files (particularly monitor.c) - create a threadattributes struct, similar to the stuff implemented in monitor.h. These specify the attributes of each task
- 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) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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. |
There was a problem hiding this 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommon this
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.