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

Miscellaneous fixes #386

Merged
merged 23 commits into from
Feb 20, 2025
Merged

Miscellaneous fixes #386

merged 23 commits into from
Feb 20, 2025

Conversation

andlaus
Copy link
Member

@andlaus andlaus commented Feb 12, 2025

This PR contains a large number of patches for smaller issues which IMO do not merit separate pull requests. Since all patches of this series are self-contained, please let me know if you prefer it to be split into two or three PRs...

Andreas Lauser <[email protected]>, on behalf of MBition GmbH.
Provider Information

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
…inition

if the specification has not yet been resolved when accesing
`.short_name` an exception will be raised (though luck)

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
@andlaus andlaus requested a review from kayoub5 February 12, 2025 14:44
@@ -1094,7 +1096,8 @@ class SomersaultSID(IntEnum):
oid=None,
odx_id=OdxLinkId("somersault.struct.recall.forward_flips_grudgingly_done", doc_frags),
parameters=somersault_positive_responses["forward_flips_grudgingly_done"].parameters,
byte_size=None),
byte_size=None,
is_visible_raw=None),
Copy link
Collaborator

Choose a reason for hiding this comment

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

And this is why I hate when they are not used

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add them to whole codebase if you want, but that's for another PR...


# ODXLINK IDs allow dots and hyphens, but short names do not.
# (This should not happen anyway in a correct PDX...)
return self.spec_ref.ref_id.replace(".", "__").replace("-", "_")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

because accessing the short name before reference resolution IMO ought not to be supported. In particular because the short name would change depending on references have been resolved or not, so this IMO constitutes a medium-sized footgun...

Copy link
Collaborator

@kayoub5 kayoub5 Feb 12, 2025

Choose a reason for hiding this comment

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

self.spec is not available during object creation, but short name is used during object creation to populate the named list

Copy link
Member Author

Choose a reason for hiding this comment

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

this is what I mean with "footgun": if this was done this way, the NamedList would feature incorrect names because after reference resolution, the short_name attributes change whilst the list stays the same. This is the reason why the NamedItemList of ComparamInstance objects is only created after ODXLINK resolution. My point is that is better to get an exception if the code is incorrect rather than incorrect results...

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
this is probably quite difficult to implement

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Gerrit Ecke <[email protected]>
i.e., add deprecated properties using the old name for `.dop`.

thanks to [at]kayoub5 for the catch.

Signed-off-by: Andreas Lauser <[email protected]>
the nesting was wrong...

Signed-off-by: Andreas Lauser <[email protected]>
@andlaus
Copy link
Member Author

andlaus commented Feb 13, 2025

@kayoub5: do you see any issues which should prevent merging this?

@kayoub5
Copy link
Collaborator

kayoub5 commented Feb 13, 2025

@nada-ben-ali could you cross this PR against the files we have?

I have a feeling one of those many small changes that are standard compliant may not align with real world files.

@nada-ben-ali
Copy link
Collaborator

@nada-ben-ali could you cross this PR against the files we have?

I have a feeling one of those many small changes that are standard compliant may not align with real world files.

@kayoub5 the tests failed for three DIDs. I'm checking the root cause...

@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

any news on this front @nada-ben-ali?

@nada-ben-ali
Copy link
Collaborator

nada-ben-ali commented Feb 19, 2025

any news on this front @nada-ben-ali?

I got the following error while encoding:

image

@andlaus I think it's:
raw_value = internal_value
instead of:
internal_value = raw_value

right?

@kayoub5
Copy link
Collaborator

kayoub5 commented Feb 19, 2025

@nada-ben-ali what was the "base_type_encoding" used by the ODX file?

@nada-ben-ali
Copy link
Collaborator

@nada-ben-ali what was the "base_type_encoding" used by the ODX file?

one DID has:
image

and the other:
image

thanks to [at]nada-ben-ali for finding this!

Signed-off-by: Andreas Lauser <[email protected]>
@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

these encoding issues are probably due to #381, not this PR!? Do you have any idea what actually goes wrong? IIRC, I added comprehensive unit tests for all base type encodings (cf https://github.com/mercedes-benz/odxtools/blob/main/tests/test_encoding.py#L93-L437), but possibly I made a few mistakes there...

@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

@andlaus I think it's:
raw_value = internal_value
instead of:
internal_value = raw_value

right?

right. fixed: 3b807eb

@nada-ben-ali
Copy link
Collaborator

@andlaus I think it's:
raw_value = internal_value
instead of:
internal_value = raw_value
right?

right. fixed: 3b807eb

I think we need to fix it here too

internal_value = raw_value

as the previous commit, this only affects the non-strict mode. (This
time I also checked that there are no more instances of this and that
the the reverse does not happen in the inverse function of `DecodeState`...

again, thanks to [at]nada-ben-ali for finding this!

Signed-off-by: Andreas Lauser <[email protected]>
@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

oops, right. Fixed: a8edd4b (I hope that I did not miss another instance of this...)

@nada-ben-ali
Copy link
Collaborator

these encoding issues are probably due to #381, not this PR!? Do you have any idea what actually goes wrong? IIRC, I added comprehensive unit tests for all base type encodings (cf https://github.com/mercedes-benz/odxtools/blob/main/tests/test_encoding.py#L93-L437), but possibly I made a few mistakes there...

yes it must be due to #381 , we didn't get this issue using release 9.3.0.

@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

yes it must be due to #381 , we didn't get this issue using release 9.3.0.

let's get it fixed ASAP...

@nada-ben-ali
Copy link
Collaborator

nada-ben-ali commented Feb 19, 2025

yes it must be due to #381 , we didn't get this issue using release 9.3.0.

let's get it fixed ASAP...

@andlaus but I think it's a Pdx file issue, for :

  • A_INT32, we don't have the encoding BCD-P
  • A_UINT32, we don't have the encoding 2C

Introducing all encodings of base data type highlighted the Pdx issue, but using the latest fix for raw_value = internal_value will prevent the UnboundLocalError issue and will use the internal value as a fallback in non-strict mode.

@kayoub5 what do you think?

@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

I agree.

Maybe we can allow the BCD encodings for INT32. The spec disallows this, probably because BCD cannot represent negative values, but I have a feeling that negative values are rarely transmitted over the wire anyway...

UINT32 using two-complement encoding obviously does not make any sense because UINT32 obviously only works for positive numbers. The question is what ought to happen in such a case if a value where the most significant bit is set is encountered.

@kayoub5
Copy link
Collaborator

kayoub5 commented Feb 19, 2025

UINT32 using two-complement encoding obviously does not make any sense because UINT32 obviously only works for positive numbers. The question is what ought to happen in such a case if a value where the most significant bit is set is encountered.

My feeling on this is that someone is not likely to put 2C as encoding by accident (since it's optional), but they may put UINT32 instead of INT32 by accident.

@andlaus
Copy link
Member Author

andlaus commented Feb 19, 2025

My feeling on this is that someone is not likely to put 2C as encoding by accident (since it's optional), but they may put UINT32 instead of INT32 by accident.

sounds reasonable. That said, what do the existing commercial tools do in that case and do all that claim to be compliant behave the same? Since this is undefined behaviour, I think odxtools should continue to raise a DecodeError in strict mode, while in non-strict mode we should probably always switch to "no encoding" if the base type is unsigned but the specified encoding is 1C or 2C. what do you think?

@kayoub5
Copy link
Collaborator

kayoub5 commented Feb 20, 2025

My feeling on this is that someone is not likely to put 2C as encoding by accident (since it's optional), but they may put UINT32 instead of INT32 by accident.

sounds reasonable. That said, what do the existing commercial tools do in that case and do all that claim to be compliant behave the same? Since this is undefined behaviour, I think odxtools should continue to raise a DecodeError in strict mode, while in non-strict mode we should probably always switch to "no encoding" if the base type is unsigned but the specified encoding is 1C or 2C. what do you think?

that's ok as well

@andlaus andlaus merged commit 90b8b96 into mercedes-benz:main Feb 20, 2025
7 checks passed
@nada-ben-ali
Copy link
Collaborator

@andlaus Could we please have a new release today? The latest changes are urgently required.

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