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

diag_layer: allow to access services according to their UDS service group (SID) #226

Merged
merged 5 commits into from
Oct 23, 2023

Conversation

andlaus
Copy link
Collaborator

@andlaus andlaus commented Oct 20, 2023

This is a convenience functionality to quickly find the diagnostic services one is interested in for ECUs offering lots of services. The simplest way to use it is using the .print_info() method:

ecu.uds_service_groups.print_info()

That said, bins can also be programmatically processed:

session_services = ecu.uds_service_groups[0x10]
print("The services concerning diagnostic sessions are:")
for session in session_services:
    print(f"  {service.short_name}")

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

@andlaus andlaus requested a review from kayoub5 October 20, 2023 14:44
@andlaus andlaus force-pushed the uds_binner branch 3 times, most recently from f8296c4 to e3fa99c Compare October 20, 2023 15:11
sid_to_name = {
# diagnostic services that cannot be categorized in terms of
# the UDS standard get `None` as their SID...
None: "Not Applicable",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
None: "Not Applicable",
None: "Unknown",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMO, in this case, "not applicable" is -- err -- more applicable: This is meant for all services which do not conform to the UDS specification at all, i.e., the first byte of their request cannot be statically determined. "Unknown" SIDs are SIDs which have not (yet?) been specified by UDS (or ones which I missed to add...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • there are other standard diag services other than UDS, for example OBD II (range 1 to 0xa)
  • assigning all services that you don't recognize the same name is not nice, instead return sid as hex

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored the code a bit. I hope these issues are solved with that...

odxtools/udsbinner.py Outdated Show resolved Hide resolved
odxtools/udsbinner.py Outdated Show resolved Hide resolved
"""
result = StringIO()
for sid, service_list in self.service_groups.items():
sid_name = self.sid_to_name.get(sid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

will throw for unknown service,

Suggested change
sid_name = self.sid_to_name.get(sid)
sid_name = self.sid_to_name.get(sid, hex(sid))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored this code with the goals of including the OBD services and using the existing .uds and .obd sub-packages...

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
… determine the size

this is the intended mechanism for this. Retrieving the `.bit_length`
attribute from the objects where it is available is a pretty fragile
hack...

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
…ce group (SID)

This is a convenience functionality to quickly find the diagnostic
services one is interested in for ECUs offering lots of services. The
simplest way to use it is using the `.print_info()` method:

```python
ecu.uds_service_groups.print_info()
```

That said, bins can also be programmatically processed:

```python
session_services = ecu.uds_service_groups[0x10]
print("The services concerning diagnostic sessions are:")
for session in session_services:
    print(f"  {service.short_name}")
```

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
thanks, [at]kayoub5!

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
- also categorize OBD services. As a consequence, rename the class from
  `UdsServiceBinner` to `ServiceBinner`
- use the `.obd` and `.uds` sub-packages
- add `__repr__()` and `__iter__()` methods

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Alexander Walz <alexander.walz@mbition.io>
@andlaus andlaus merged commit 128c323 into mercedes-benz:main Oct 23, 2023
6 checks passed
@andlaus andlaus deleted the uds_binner 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.

2 participants