-
Notifications
You must be signed in to change notification settings - Fork 9k
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
pandad: refactor to consolidate threads, keep only one can_send thread #32680
Conversation
Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:
|
f4f3cf3
to
71fe95a
Compare
21dc1ba
to
c00f778
Compare
Nice work! I added to the 0.9.8 milestone and will try to get this merged soon. |
abd0028
to
8a06e68
Compare
8a06e68
to
8f516a9
Compare
trigger-jenkins |
improve comment
c019432
to
fde09a9
Compare
eb49626
to
f52a770
Compare
|
||
{ | ||
sm.update(0); |
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.
sm.update
should probably happen in the main pandad_run loop for readability
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.
There are two submasters updated at different frequencies. For now, keeping updates in their own functions provides better encapsulation. Moving to pandad_run would add complexity. We can address this in a future refactor or another PR.
2d46843
to
3ad75f0
Compare
3ad75f0
to
6d2fed1
Compare
#include "cereal/messaging/messaging.h" | ||
#include "common/swaglog.h" | ||
|
||
void PandaSafety::configureSafetyMode() { |
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 is cleaner than what we had before, but I think it'll be more readable as a single function like "safety_mode_tick"
@Quantizr can you verify this in the testing closet and merge if it looks good? |
commaai#32680) * single thread improve comment * Keep can_send() running in a separate thread * send send_peripheral_state in pandad_run * new PandaSafety class old-commit-hash: a4de873
To minimize changes and avoid introducing new issues, the original C-style functions have been retained.
Main Changes
send_peripheral_state
frompanda_state()
toperipheral_state()
for a better fit.safety_setter_thread
gracefully quits on exit.Additional Note
A possible better approach to eliminate the static variables is to declare classes for PeripheralState, PandaState, etc., and move the static variables to their member variables. The final code might look something like this:
However, since the pandad process always restarts after failures, keeping these variables as static in this PR is harmless.