-
Notifications
You must be signed in to change notification settings - Fork 79
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
Conversation
f8296c4
to
e3fa99c
Compare
odxtools/udsbinner.py
Outdated
sid_to_name = { | ||
# diagnostic services that cannot be categorized in terms of | ||
# the UDS standard get `None` as their SID... | ||
None: "Not Applicable", |
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.
None: "Not Applicable", | |
None: "Unknown", |
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.
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...)
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.
- 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
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.
I refactored the code a bit. I hope these issues are solved with that...
odxtools/udsbinner.py
Outdated
""" | ||
result = StringIO() | ||
for sid, service_list in self.service_groups.items(): | ||
sid_name = self.sid_to_name.get(sid) |
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.
will throw for unknown service,
sid_name = self.sid_to_name.get(sid) | |
sid_name = self.sid_to_name.get(sid, hex(sid)) |
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.
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>
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:That said, bins can also be programmatically processed:
Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH.
Provider Information