-
Notifications
You must be signed in to change notification settings - Fork 0
Review Threads Operating Successfully #3
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
base: main
Are you sure you want to change the base?
Conversation
…fy EVT-core, gonna need to make a branch there for stuff to actually work. CMake is having issues finding tx_api.h, which I thought I had resolved but apparently it is not happy about it still.
…ad to do anything.
DiegoLHendrix
left a comment
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.
Looks good. I just got a few grammatical nitpicks and some questions.
| [[noreturn]] void accessoryCanReceiveThreadEntry(accessoryCanReceiveThreadArgs_t* args) { | ||
| log::LOGGER.log(core::log::Logger::LogLevel::DEBUG, "Accessory Can Thread Started."); | ||
| rtos::TXError error; | ||
| // while(true) { |
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 think I am missing something. Why is this while loop commented out?
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.
The Hardmon dictionary is super incomplete (I was using the MCuC one to figure out what we needed) so running it will probably result in a crash, or at least undefined behaviour. Added a todo so it's more obvious what's wrong.
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.
Is it safe to let a thread just exit like this without calling a thread delete or something? I would at least keep the loop and just put a suspend or long sleep in it to ensure it doesn't cause a problem.
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.
It's generally safe, I believe that when a thread reaches the end of it's entry function it is set to sleep automatically. Technically it's likely not the best solution, but this won't be how it works in the actual code (we definitely need the accessory can thread), so it will be fine for now.
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.
Yeah, but I was mostly thinking of leaving the loop and just sleeping for a really long time in it temporarily.
…nd cleaned up constructor in CPP.
mjh9585
left a comment
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.
Lots of nitpicky things but overall nice work. Have fun with this and I am sorry in advance. :)
| * Queue to store CAN messages. | ||
| */ | ||
| core::types::FixedQueue<POWERTRAIN_QUEUE_SIZE, IO::CANMessage> queue; | ||
| rtos::Queue queue; |
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 should probably be private.
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.
PowertrainCAN is contained entirely within either MCuC or Hardmon, it's mostly just an easy way for me to keep all of those sorts of relevant messages together. Thus, the queue being public is probably better cause it's only access within the mcuc or hardmon, and PowertrainCAN is private to those classes.
Explaining this made me realize this is probably not the best way to do it- do you think that both classes should privately inherit from PowertrainCAN instead? That's probably the correct object-oriented way to do it.
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 am not sure if inheritance is the right answer here since MCuC and Hardmon both use the accessory and powertrain busses. I was thinking some sort of access method would be better then inheritance. Then you can add any additional semephors before accessing the queue or preform any CAN state updates such as recording message time.
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.
Bear in mind that MCuC and Hardmon are mutually exclusive in the sense that the target for MCuC and the target for Hardmon are both uploaded to entirely different chips.
targets/REV3-Hardmon/main.cpp
Outdated
| auto* queue = (rtos::Queue*) priv; | ||
| if (queue != nullptr) { | ||
| //TODO: determine if WaitForever is what we want to do in the interrupt- could be bad | ||
| queue->send(static_cast<void*>(&message), rtos::TXWait::TXW_WAIT_FOREVER); |
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 do not want to wait forever although I don't think it matters since you are in interrupt context and I believe all methods return immediately.
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.
Also here in Hardmon you write directly to the Queue but in MCuC you write to the normal queue is there a reason for the difference?
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.
Also also, you pass in a fixed queue but interpret it as a rtos queue.
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.
Yeah the hardmon version was a little messed up. AccessoryCAN should be a fixedQueue.
I don't know what happens if a thread gets slept in the middle of an interrupt-- might be worth looking into.
| [[noreturn]] void accessoryCanReceiveThreadEntry(accessoryCanReceiveThreadArgs_t* args) { | ||
| log::LOGGER.log(core::log::Logger::LogLevel::DEBUG, "Accessory Can Thread Started."); | ||
| rtos::TXError error; | ||
| // while(true) { |
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.
Is it safe to let a thread just exit like this without calling a thread delete or something? I would at least keep the loop and just put a suspend or long sleep in it to ensure it doesn't cause a problem.
…' into feature/aclowmclaughlin/VCU_RTOS
…and sendToPowertrainQueue() methods instead of just a getPowertrainQueue() method changed the targets (mains) of both to work with the new methods.
…' into feature/aclowmclaughlin/VCU_RTOS
…th CAN library (the const gets dropped when sent)
…d of initializing them one by one. Also copied updated buffers for accessoryCAN from MCuC and Hardmon and changed corresponding methods.
…nd after the switch statement. Fixed typo in receiveFromPowertrainQueue (receive was spelled recieve) Switched the accessoryCanData_t to a union containing two structs in order to make memcpying separate parts of them more viable (then switched to using memcpy for both sendInputDataToSafeBuffer and sendOutputDataToUnsafeBuffer.
DiegoLHendrix
left a comment
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.
Good work
Co-authored-by: Diego <119289719+DiegoLHendrix@users.noreply.github.com>
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.
Ok all I found that I was concerned (besides prev mentioned things) about are things ive already altered in my local version, so i think this is good.
I copied all the concerns/ideas that people (mainly heller) gave, so they are now part of my VCU todo list
Initial RTOS thread setup- all the threads are at least templated out. Model thread is running.