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

Documentation is incomplete regarding how DTC are reported #31

Open
ep081106 opened this issue Jul 3, 2019 · 11 comments
Open

Documentation is incomplete regarding how DTC are reported #31

ep081106 opened this issue Jul 3, 2019 · 11 comments

Comments

@ep081106
Copy link

ep081106 commented Jul 3, 2019

i used the following code to read the DTC:
with Client(conn, request_timeout=10) as client:
DTC_list = client.get_dtc_by_status_mask(status_mask)
print("DTC list:", DTC_list)

but i didn't get the DTC code, i got :
DTC list :<PositiveResponse:[ReadDTCInformation]-61 data bytes at 0x0322ff0>;

could you please tell me how can i get the DTC code?

@pylessard
Copy link
Owner

pylessard commented Jul 4, 2019

Agree that the documentation is incomplete regarding how the DTC are reported.
In your case, DTCs are in response.service_data.dtcs which is an array of DTC object.

Example

response.service_data.dtcs[0].id
response.service_data.dtcs[0].status
response.service_data.dtcs[0].severity

For now, your best source of information will be the unit tests themselves. Each subfunction has a TestSuite associated.

def client_assert_response(self, response, expect_all_zero_third_dtc=False):
self.assertEqual(response.service_data.status_availability.get_byte_as_int(), 0xFB)
number_of_dtc = 3 if expect_all_zero_third_dtc else 2
self.assertEqual(len(response.service_data.dtcs), number_of_dtc)
self.assertEqual(response.service_data.dtc_count, number_of_dtc)
self.assertEqual(response.service_data.dtcs[0].id, 0x123456)
self.assertEqual(response.service_data.dtcs[0].status.get_byte_as_int(), 0x20)
self.assertEqual(response.service_data.dtcs[0].severity.get_byte_as_int(), 0x00)
self.assertEqual(response.service_data.dtcs[1].id, 0x123457)
self.assertEqual(response.service_data.dtcs[1].status.get_byte_as_int(), 0x60)
self.assertEqual(response.service_data.dtcs[1].severity.get_byte_as_int(), 0x00)

I will try to update the documentation on the short term to make this clearer.

@ep081106
Copy link
Author

ep081106 commented Jul 4, 2019

Sorry for trouble you again!
Based on your suggestions,My friend and me try our best to find the DTC list, but still cannot get them, maybe our methods are wrong.
we tried to use "print(response.service_data.dtcs)" to get the DTC list, but got the wrong message "name 'resonse' is not defined".
And we tried copy the code in "python-udsoncan/test/client/test_read_dtc_information.py" Lines 126 to 139, still worng.

could you please give us an example to find it? we have no any method now. thanks!
`
UDSdemo_0704.zip

`

@pylessard
Copy link
Owner

The error is simple. As it says, response doesn't exist. That's because in my example, response is what you get from get_dtc_by_status_mask(). Every client function return a Response object. In that response you have:

  • response.data : The raw data of the response
  • response.service_data : The data interpreted by the right service parser.

In the below image, you don't use the right variable.
image

Just do:

response = client.get_dtc_by_status_mask(status_mask)
print(response.service_data.dtcs)        # Will print an array of object
for dtc in response.service_data.dtcs:
    print("DTC : %06X" % dtc.id )         # Print the DTC number

@pylessard pylessard changed the title how can i get the DTC code Documentation is incomplete regarding how DTC are reported Jul 5, 2019
@pylessard pylessard self-assigned this Jul 5, 2019
@ep081106
Copy link
Author

ep081106 commented Jul 8, 2019

could you please add "how to read the DTC sanpshot" also? thanks!

@pylessard
Copy link
Owner

Hi, I will leave this issue opened. Documentation needs to be updated.

Thanks for pointing the issue

@jwdsoft
Copy link

jwdsoft commented Jan 16, 2020

Can you please tell me which hardware could I use in order to use this library ?
also I want to know if this library support trucks also ? since I will test it on a truck ECU
(I did't want to open an issue about these question since they are not issues)

@pylessard
Copy link
Owner

Hi @jwdsoft , I think your question deserve a new issue. I've created #44 to help answers.
Honnestly, I personnaly am not aware of what commercial platform uses it. I know about some electric buses and delivery trucks; UDS is trending in the world of EV.

Heavy trucks mostly uses J1939. Hopefully, #44 will gather some useful informations to answer this.

@ep081106
Copy link
Author

hi pylessard, i try to read the DID by using ReadDataByIdentifier, but i get the error: "ConfigError – If didlist parameter or response contains a DID not defined in didconfig";
form the document, i found the example for DidConfig:

Example of DidConfig
.. code-block:: python
didconfig = {
0x1111 : '<H', # Strings are processed by struct.unpack
0x2222 : MyCustomDidCodec, # Inherits the udsoncan.DidCodec,
0x3333 : MyCustomDidCodec(param1='hello') # Instance can also be provided
0x4444 : dict(key1='val1', key2='val2', codec=MyCustomDidCodec} # If dict is given, a key named "codec" will be searched for
}

i think the DidConfig shall be added in "udsoncan/init.py/class DidCodec", but i still don't know how to add them;
could you please tell me where shall i add those codes and what things shall i take care (e.g. D030 has 4 bytes with 2、3 or 4 siangls)? thanks!

@pylessard
Copy link
Owner

Hi,
This issue is dedicated to DTC. If you have additional problems, creates new issues.
There is no error message that says If didlist parameter or response contains a DID not defined in didconfig

The didconfig must be given to the client. You should start by looking at the documentation before looking at the code.
There is an example here : https://udsoncan.readthedocs.io/en/latest/udsoncan/examples.html#reading-a-did-with-readdatabyidentifier

Regards

@MasterCodeIT
Copy link

The error is simple. As it says, response doesn't exist. That's because in my example, response is what you get from get_dtc_by_status_mask(). Every client function return a Response object. In that response you have:

* `response.data` : The raw data of the response

* `response.service_data` : The data interpreted by the right service parser.

In the below image, you don't use the right variable.
image

Just do:

response = client.get_dtc_by_status_mask(status_mask)
print(response.service_data.dtcs)        # Will print an array of object
for dtc in response.service_data.dtcs:
    print("DTC : %06X" % dtc.id )         # Print the DTC number

Still trying to work on this DTC service. So I used the following:

response = client.get_dtc_by_status_mask(status_mask)
        print(response.service_data.dtcs)  # Will print an array of object
        for dtc in response.service_data.dtcs:
            print("DTC : %06X" % dtc.id)  # Print the DTC number

any I get this error below:

response = client.get_dtc_by_status_mask(status_mask)
NameError: name 'status_mask' is not defined

@Kaeptn-G
Copy link

The error is simple. As it says, response doesn't exist. That's because in my example, response is what you get from get_dtc_by_status_mask(). Every client function return a Response object. In that response you have:

* `response.data` : The raw data of the response

* `response.service_data` : The data interpreted by the right service parser.

In the below image, you don't use the right variable.
image
Just do:

response = client.get_dtc_by_status_mask(status_mask)
print(response.service_data.dtcs)        # Will print an array of object
for dtc in response.service_data.dtcs:
    print("DTC : %06X" % dtc.id )         # Print the DTC number

Still trying to work on this DTC service. So I used the following:

response = client.get_dtc_by_status_mask(status_mask)
        print(response.service_data.dtcs)  # Will print an array of object
        for dtc in response.service_data.dtcs:
            print("DTC : %06X" % dtc.id)  # Print the DTC number

any I get this error below:

response = client.get_dtc_by_status_mask(status_mask) NameError: name 'status_mask' is not defined

Is this maybe because you did not define 'status_mask'?
I think you might want to have a look here: https://automotive.wiki/index.php/ISO_14229#DTC_Status_Byte
Example: in case you like to get any DTC, regardless of the status, just define 'status_mask' as 0xff. If you like to see only DTC which have actually been confirmed to be stored non volatile, take 0x8. If you like to only see DTC which are currently failed, take 0x1.
Is this what you were missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants