-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add core address claiming logic #15
Conversation
Minimum allowed coverage is Generated by 🐒 cobertura-action against a4b8068 |
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 promising 🔥 , for your questions:
- Is there a more idomatic way to do a finite state machine than match ?
I googled around a bit, and like this approach quite a bit. It should also help with the next question.
- Is there a setting we can adjust so the formatter doesn't make the entire state machine an unreadable blob of newlines?
Hmm, In my opinion refactoring the state machine into smaller concrete functions (for example as the state machine linked above, or by using early returns 😛) should be the first priority to battle this issue. Though I agree, it sometimes is unavoidable to have the longer line lengths and it may be increased just slightly (if there is an easy and standardized way to do so)
Oh, hey, that looks pretty nice... could tidy it up a fair bit. I'll experiment with that |
Am I missing something? That approach doesn't seem to compile.... |
Welp I missed the most important part of the post:
So that suggestion doesn't work hahah, sorry |
Bummer, it was so clean and nice! Regardless, I'll still try and make it more self-contained by moving logic into |
21b9296
to
480014b
Compare
Just want to add to this conversation. State machines can be modeled in Rust using using enum's, as one would normally do in c++. The best example, that i know of, explaining this concept for state machines can be found here (Pretty State Machine Patterns in Rust ) Note however that this relatively requires a lot of code. Luckily most of it will be abstracted away by the compiler. What do you think? --edit: |
@Thom-de-Jong that sounds interesting! I think we should at least try it, though I'm also fine with doing at a later stage with a seperate PR if that's easier for @ad3154
Personally that is fine with me, the large switch/match statements for some of the state machines we have over in AgIsoStack++ are hard to gasp IMO. So anything resulting is a somewhat smaller functions of code and especially with the "Rust's compile-time guarantees, making it impossible to program a transition to a state that we should not be in." I'm in for. |
Hmm, that does seem nice, but agreed it's a lot of code. I'd be fine with trying it but yeah maybe I can follow up this PR with a refactor. We have a ton of state machines in AgIsoStack++ so getting a nice pattern figured out will make our lives easier for other parts of the stack as well, so thanks for the suggestion! |
Added the basic address claiming logic. Needs still needs to be attached to the driver.
Moved a lot of the address claim logic into the control_function file. Cleaned up todos involving CanId encoding when creating address claim messages. Removed some clippy allows. Changed some manual bitshifting to use to_le_bytes. Changed some raw integers to be "Pgn" "Address" and other types in driver. Still WIP
a4b8068
to
ab08bfa
Compare
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
…ager additions Changed CFs to be stored differently. Added a function to send a CAN message. Added a way to create an ICF. Started adding receive message processing.
ab08bfa
to
384dc83
Compare
I think this is in a good enough state to merge now so we can keep making progress. Since last time, I rebased and updated all usages of NAME in each commit to match the latest implementation of NAME. Would be nice to get this in before #26, and will give us something I can test the driver layer with |
Questions I have:
match
?