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

[DP] Refactor away from diagnosticProtocolList #281

Merged
merged 7 commits into from
Jul 2, 2023

Conversation

GwnDaan
Copy link
Member

@GwnDaan GwnDaan commented Jun 23, 2023

Changes:

Major:

  • Refactor away from the diagnosticProtocolList and let the user create objects instead
  • Refactor away from extending CANLibProtocol to be more inline with newly added interfaces (Guidance/speed/maintain power) to have a more "The library should only do work when it is explicitly asked to" experience.
  • Add dedicated NetworkType configuration parameter
  • Introduced initialize / terminate as replacements for assign_... / deassign_....

Minor:

  • Use in-class initializers where possible
  • Fixed several typos
  • Apply reference-to-const variables and const functions where possible
  • Remove redundant case ' clauses'
  • Remove redundant parenthesis
  • Moved parse_j1939_network_states function from public to private

@ad3154, note that I don't have any way of testing if this actually works. I just refactored up to a point where I think I can better fix #161. Also we need to expand on the unit test cases for this diagnostic protocol, but I'm not really familiar with the documentation. Any chance you have time to take this over?

@GwnDaan GwnDaan added the enhancement New feature or request label Jun 23, 2023
@GwnDaan GwnDaan requested a review from ad3154 June 23, 2023 18:37
@GwnDaan GwnDaan self-assigned this Jun 23, 2023
@GwnDaan GwnDaan temporarily deployed to Integrate Pull Request June 23, 2023 18:37 — with GitHub Actions Inactive
@ad3154
Copy link
Member

ad3154 commented Jun 25, 2023

Any chance you have time to take this over?

I'll do what I can, I have some travel coming up soon-ish but I might be able to make headway before then. I have a reliable way to test this interface.

I think generally it's probably a good idea to make this more like our other interfaces. It needed some updates to be sure, especially to support #161.
I guess the reason this was done different in the first place was that users basically need this interface to be ISOBUS compatible, so it felt like making it optional might result in people not knowing they need it. Many ISOBUS applications will query everyone's functionalities, software ID, and ECU ID, so if we're going down this path of refactoring it, we may need to be extra clear in the examples and tutorial docs that this is super strongly suggested haha.

@GwnDaan
Copy link
Member Author

GwnDaan commented Jun 28, 2023

I guess the reason this was done different in the first place was that users basically need this interface to be ISOBUS compatible, so it felt like making it optional might result in people not knowing they need it.

I see what you mean here, and I agree, but as far as I can see it never has been not optional? As one still needed to use the assign_diagnostic_protocol_to_internal_control_function for the protocol to do anything at all. Or am I missing something here? I'm not against enabling the diagnostics functionality by default, but then we should probably let the CANNetworkManager handle it as the DiagnosticsProtocol requires at least a single ICF to be registered?

@ad3154
Copy link
Member

ad3154 commented Jun 28, 2023

as far as I can see it never has been not optional?

Totally agree, that was a shortcoming in the old implementation, so I had made it a protocol to get automatic updates from the stack but failed to make it truly automatic...

I am not sure if we can make the network manager really handle it, unless it automatically attaches an instance of this class to every ICF, which is still not super intuitive then that users need to configure it... plus the manager is already so big... I guess for the moment I'm happy enough with making it like our other, nicer interfaces if you are.

Side note, I am working unit tests for this in my evening free time and found some other smaller issues that I'll open as other PRs soon...

ad3154 and others added 5 commits June 28, 2023 18:56
Fixed an issue where we'd incorrectly allow multiple BAM Tx sessions
at one time for a given ICF, which is not allowed by the standard.
The issue here was that when we were checking for extant sessions, we
were calling only the destination specific session getter.
Fixed order of operations when nulling out an evicted CF.
- Stop using CANLibProtocol to be more inline with newly added interfaces (Guidance/speed/maintain power)
- Add dedicated NetworkType configuration parameter
- use in-class initializers where possible
- Fixed several typos
- Moved `parse_j1939_network_states` function from public to private
- Introduced `initialize` / `terminate` as replacements for `assign_...` / `deassign_....`
- Remove redundant case ' clauses'
- Remove redundant parenthesis

These changes were suggested by SonarCloud
Added numerous DP unit tests.
Fixed DP example not saving the periodic event dispatcher.
Added example use of ECUID Type.
Added a way to get the broadcast state and init state of the diagnostic
protocol.
Added processing of the suspend type for DM13 to allow for custom
broadcast suspension times.
Added support for PGN requests for the DM1 PGN.
Fixed issues with ECU ID sending too many fields when operating in
J1939 mode.
Enhanced message queuing for requests for ECU and software ID.
Fixed busload unit test which was affected by adding DP tests.
Slightly increased the timeout on language command timestamp unit test.
Fixed an intermittent issue with TC unit tests that came from changing
to shared ptr for control functions due to the tests claiming the same
address with no network manager updates between destroying a partner
and claiming a new one.
@ad3154 ad3154 force-pushed the improve-diagnostics-protocol branch from b51350d to 0c269c9 Compare June 29, 2023 04:06
@ad3154 ad3154 deployed to Integrate Pull Request June 29, 2023 04:06 — with GitHub Actions Active
Added additional diagnostic protocol tests.
Fixed issues with DTC getters returning false all the time.
@ad3154 ad3154 temporarily deployed to Integrate Pull Request June 30, 2023 04:15 — with GitHub Actions Inactive
Added some additional unit tests to diagnostic protocol to catch a few
more cases with DM2, 22, and 13.
Added a missing doxygen comment in ControlFunction's constructor.
@ad3154 ad3154 temporarily deployed to Integrate Pull Request July 2, 2023 16:39 — with GitHub Actions Inactive
@sonarcloud
Copy link

sonarcloud bot commented Jul 2, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

78.6% 78.6% Coverage
4.4% 4.4% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Member

@ad3154 ad3154 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ready now - the file itself it up to 80% coverage, I've tested each message, and fixed a number of issues that testing uncovered. @GwnDaan if you're good with it I think we can merge it.

@GwnDaan
Copy link
Member Author

GwnDaan commented Jul 2, 2023

Yeah LGTM, can be merged :)

@ad3154 ad3154 merged commit ec4e583 into main Jul 2, 2023
5 of 6 checks passed
@ad3154 ad3154 deleted the improve-diagnostics-protocol branch July 2, 2023 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor away from CANNetworkManager singleton
2 participants