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

Minor cleanups #223

Merged
merged 2 commits into from
Oct 27, 2023
Merged

Minor cleanups #223

merged 2 commits into from
Oct 27, 2023

Conversation

andlaus
Copy link
Collaborator

@andlaus andlaus commented Oct 18, 2023

This PR contains a few cleanups for stuff which I stumbled over yesterday:

  • Removal of is_functional for communication parameters
  • Make DiagLayer.protocols a cached property

Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH.
Provider Information

@andlaus andlaus requested a review from kayoub5 October 18, 2023 08:47
this computation is relatively expensive...

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
communication parameters themselfs do not provide this information and
determining it from the context does not work for all instances where
communication parameter references are needed (i.e. within
`DiagService`)

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
@kayoub5
Copy link
Collaborator

kayoub5 commented Oct 18, 2023

Removal of is_functional for communication parameters

Why?

@andlaus
Copy link
Collaborator Author

andlaus commented Oct 18, 2023

Removal of is_functional for communication parameters

Why?

mainly because DIAG-SERVICE tags may have a COMPARAM-REFS sub-element and it is completely impossible to determine if the parameter is supposed to be "functional" or not. besides that, I'm not sure what it even means for a communication parameter to be functional, and finally, there were no in-tree users or tests...

@kayoub5
Copy link
Collaborator

kayoub5 commented Oct 18, 2023

Removal of is_functional for communication parameters

Why?

mainly because DIAG-SERVICE tags may have a COMPARAM-REFS sub-element and it is completely impossible to determine if the parameter is supposed to be "functional" or not. besides that, I'm not sure what it even means for a communication parameter to be functional, and finally, there were no in-tree users or tests...

@dmholtz was the one who introduced the is_functional, maybe he can shed some light on the topic?

@@ -720,16 +717,13 @@ def get_doip_logical_ecu_address(self, protocol_name: Optional[str] = None) -> O
return int(ecu_addr)

def get_doip_logical_gateway_address(self,
protocol_name: Optional[str] = None,
is_functional: Optional[bool] = False) -> Optional[int]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the is_functional parameter in any of these methods is a breaking change and should result in a new major release of odxtools if the removal is really necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is still true IMO.

@@ -41,7 +39,6 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment],
else:
value = create_complex_value_from_et(odxrequire(et_element.find("COMPLEX-VALUE")))

is_functional = dl_type == DiagLayerType.FUNCTIONAL_GROUP
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the critical line of code where the parameter is set.

I used the DiagLayer's type to determine if a communication parameter is used for functional addressing or not. The reason for this heuristic is that all of the pdx files I worked with last year provided two almost indistinguishable communication parameters, one for functional addressing and one for non-functional addressing. Apart the surrounding DiagLayer and its type there is afair no other indication to what type of addressing the parameter refers to.

I suggest not to remove this heuristic unless a reasonable alternative is found, because some of our current projects use the query methods in the DiagLayer class, which depend on this parameter.

Copy link
Collaborator Author

@andlaus andlaus Oct 18, 2023

Choose a reason for hiding this comment

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

the problem is that DiagServices may also contain references to communication parameters and that there this heuristic is not available because diagnostic services are inherited, i.e., does the parameter change its "allegiance" if it is inherited by an ECU-VARIANT that is derived from a FUNCTIONAL-GROUP?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@andlaus the alternative to is_functional would be to expose to what DiagLayerType the comm param belongs to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest not to remove this heuristic unless a reasonable alternative is found, because some of our current projects use the query methods in the DiagLayer class, which depend on this parameter.

As this seems to be an issue with our PDX parameter naming conventions, I will forward this to my colleagues, who will eventually check if we can fix this internally without stopping the development of odxtools

Copy link
Contributor

@dmholtz dmholtz Oct 27, 2023

Choose a reason for hiding this comment

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

We have revisited our usage of this part of the API and found that there exists a fix for the behavior described above (at least) in the most recent version of odxtools. In case two communcation parameters have the same name, they can be distinguished by simply also providing the protocol name to the query.

The is_functional parameter / attribute is indeed no longer required and can be removed.

@andlaus
Copy link
Collaborator Author

andlaus commented Oct 27, 2023

cool! let's get this merged then!

@andlaus andlaus merged commit d5ca112 into mercedes-benz:main Oct 27, 2023
6 checks passed
@andlaus andlaus deleted the minor_cleanups branch December 7, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants