richClubb / python-uds

A uds library for python
MIT License
99 stars 55 forks source link

Vector VN1630 Interface Issue #47

Closed AasaiAlangaram closed 4 years ago

AasaiAlangaram commented 5 years ago

Hello, This is not an issue. I am looking for your help. I am trying to get diagnostic data from ECU. I have designed a panel using the PyQt5 framework. I've tried a few examples but nothing works out, it always throughs some exceptions. I am using VN1630 as a CAN Interface. This is the panel image

I tried using the raw send command example code

`from uds import Uds

ECU_Serial_no = Uds(transportProtocol="can", reqId=0x7E0, resId=0x7E8) a = ECU_Serial_no.send([0x22, 0xF1, 0x8C])`

Traceback (most recent call last): File "C:/Aasai/Python CAN Project/python-uds-master/python-uds-master/uds/Uds_CANoe_Test.py", line 19, in ECU_Serial_no = Uds(transportProtocol="can", reqId=0x7E0, resId=0x7E8) File "C:\Users\aasaialangaram\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uds\uds_communications\Uds\Uds.py", line 43, in init self.tp = tpFactory(self.__transportProtocol, configPath=configPath, **kwargs) File "C:\Users\aasaialangaram\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uds\uds_communications\TransportProtocols\TpFactory.py", line 49, in call raise Exception("Unknown transport type selected") Exception: Unknown transport type selected

It shows the Unknown transport type selected. Like that what are reqId and resId?

Could you help me to get the first response and solve this issue?

Thanks, Aasai

richClubb commented 5 years ago

Hi Aasai.

How familiar are you with UDS? From the code sample you sent you are trying to communicate with an ECU with the IDs the same as an Embed E400 bootloader.

What specific exception are you getting? If you print out the exception message in your catch it will give more of an idea as to the problem. It's likely either a timeout if you have the wrong IDs or a problem setting up the interface.

A few things to check:

  1. Have you set up an application in the vector hardware setup? If not then the sample code will likely fail.
  2. What are the request and response IDs of the device you are trying to communicate with? For example almost vehicle power train modules have IDs 0x7E0 for request and 0x7E8 for response.
AasaiAlangaram commented 5 years ago

Hello Rich,

The exception I'm getting when I run this code

from uds import Uds

ECU_Serial_no = Uds(transportProtocol="can", reqId=0x537, resId=0x53F) a = ECU_Serial_no.send([0x22, 0xF1, 0x8C])

image

I am working in a Headlamp ECU, trying to develop a compact diagnostic tool using pyqt5.

This is my hardware application setup in CANoe

image

In CANoe, there is no problem to send and receive msg.

I also changed the request and response Id but still, it shows the same exception. Exception: Unknown transport type selected

Thanks, Aasai.

richClubb commented 5 years ago

Hi Aasai.

Sorry, I sent that email when i got the first email but you've added more info since then.

it should be "CAN" instead of "can" in "transportProtocol=can"

ECU_Serial_no = Uds(transportProtocol="CAN", reqId=0x537, resId=0x53F)

Would be the correct format

It might be more sensible for me to do a toUpper or toLower on the string when creating the instance from the tpFactory class.

Try that and let me know if it works.

Rich.

AasaiAlangaram commented 5 years ago

Hello Rich,

your solution works

ECU_Serial_no = Uds(transportProtocol="CAN", reqId=0x537, resId=0x53F)

The problem solved after changed to CAN, this is the correct format.

Now, the Response timeout exception raised.

image

ID might be the issue here, i think.

Give me some solution to find the correct ID.

-Aasai.

richClubb commented 5 years ago

Hi Aasai.

Glad to hear the first is solved.

Looking at your constructor it would be using the config defaults for the interface, so you're not going to be using the vector interface. Try this.

Uds(transportProtocol="CAN", reqId=0x537, resId=0x53F, interface="vector", appName="pythonUds", channel=0)

I would doubt that changing the timeout time would help, but if you want to try add "P2_CAN_Client" to the Uds constructor, but the timing is currently at 1s which is more than enough for most ECUs

Uds(transportProtocol="CAN", reqId=0x537, resId=0x53F, P2_CAN_Client=3)

Would change the recv timeout to 3 seconds.

Let me know what happens.

Rich.

AasaiAlangaram commented 5 years ago

Hello Rich,

Uds(transportProtocol="CAN", reqId=0x537, resId=0x53F, interface="vector", appName="pythonUds", channel='0')

image

Now, it shows no hardware present.

The steps I followed to read the ECU serial no:

  1. Created an application pythonUds in Vector Hardware Config
  2. Added that application under VN1630 channel assignment image 3.Run below code

ECU_Serial_no = Uds(transportProtocol="CAN", reqId=0x5F3, resId=0x5FB, interface="vector", appName="pythonUds", channel='2') a = ECU_Serial_no.send([0x22, 0xF1, 0xA1]) print(a)

It shows XL error ( See above Image)

Is this code suitable for VN1630 CAN Interface?

How to identify the connection established with CANoe/Hardware?

Thanks, aasai

richClubb commented 5 years ago

Hi Aasai

I tested it on a 1630 and cancasexl.

Try changing the channel to 1 in the constructor. I think it might be zero indexed and you've assigned the interface to CAN 2. I'm not sure if it references the hardware channel or the logical channel.

Unfortunately I don't have access to a Vector Interface at the moment so I can't check it.

Rich

AasaiAlangaram commented 5 years ago

Hello rich,

The ECU module is connected on hardware channel 3. Can I change the channel to 3 in the constructor?

For your Information There are two ECU one is LH & other one is RH. Right now I'm working with RH connected on 1630 channel 3.

I'll change the channel to 3 and let you know or else connect the ECU on hardware channel 2 and test.

Thanks for your support👍🤝 Aasai.

richClubb commented 5 years ago

Hi Aasai.

No problems, always happy to help :) if it doesn't work try iterating over the different options. I remember it not being 100% straight forward on the Vector interfaces.

Let me know if you have any other problems. I will try and improve the documentation to make it clearer.

Thanks.

Rich

AasaiAlangaram commented 5 years ago

Hello Rich,

Happy to say that, Finally I'm getting a response.

Some things are changed in order to get the response.

  1. Assigned pythonUds channel to 3, previously it was 2. Because ECU connected on VN1630 channel 3.
  2. In the program, the channel should be assigned to the logical channel(i.e channel 2) In my case, LH Network channel: 1 RH Network channel: 2

In document example, the channel is an integer type but it should be a string. DID = Uds(transportProtocol="CAN", reqId=0x5F3, resId=0x5FB, interface="vector", appName="pythonUds", channel=2) Correct format DID = Uds(transportProtocol="CAN", reqId=0x5F3, resId=0x5FB, interface="vector", appName="pythonUds", channel='2')

Without your help, this might be quite difficult. Sometimes the simplest things mean the most.

I will be very grateful to you.

Thanks, Aasai,

richClubb commented 5 years ago

Hi Aasai.

That is a bug, the intention is that for any parameter which is numeric should be a numeric value rather than a string. I'll have a look into this.

If i create a branch for you could you test this for me? I don't have access to a vector interface at the moment.

Just a side questions;

AasaiAlangaram commented 5 years ago

Hello Rich,

I am happy to test for you.

Could you please tell me briefly what you want me to do?

I can't communicate with both modules through single channel. Rh Network one channel & Lh should be in another channel. Yes, we have CDD files.

Thanks, Aasai.

karamveerpratap commented 2 years ago

hello rich & Aasai , I am facing a issue while parsing cdd file is their a way to parse the cdd file and work with it using this library