Source Adress / Target Adress

A free API for the communication with control devices according to UDS (ISO 14229-1)
Daniel.
Posts: 4
Joined: Tue 5. Apr 2016, 15:40

Source Adress / Target Adress

Post by Daniel. » Tue 5. Apr 2016, 16:53

Hello,

I like to use the PCAN-USB-Interface and the UDS and ISO-TP API for communicate with UDS commands about the CAN-Bus. I have initialized the interface with the right baudrate and will send the testerPresent like the example in the documentation of the UDS API, but the answer is "NO_MESSAGE". With another Software it works fine, so that it isn't a hardware problem (I think ;) ).
I had read in the documentation of the UDS API and the ISO-TP API that I have to mapping the address with the command AddMapping. My problem is: What means the Source Adress and the Target Adress? Where from I know, what I have to set? And have I set the right Server Adress? Where from I know the correct address?
Can anyone explain me the correct mapping for a 29-Bit CAN-ID?

Thank you for help!
Daniel

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Source Adress / Target Adress

Post by F.Vergnaud » Tue 5. Apr 2016, 17:45

Hello Daniel,

When you communicate with an ECU using the UDS protocol, your application is usually what is called the "TesterClient", the standard address value associated to it is 0xF1.
On the other hand, the ECU's address is defined during its design.. For instance with OBD-II (a protocol above UDS), the standard states that there can be only 8 ECUs and there address is a range from 0x01 to 0x08.
You should check the specifications of your ECU to see how it is communicating via ISO-TP (address and addressing format).

The address is important because if a message is sent on the CAN bus, the ECU will/should check that the target address of the message matches its defined address (if not the message is ignored).
Yet based on how is designed the ECU, this can be completely ignored: may be the specifications of your ECU may only state that it listens to a specific CAN ID and responds with another CAN ID. In that case you have to configure your mappings with some dummy values:
First you have to check what ISO-TP addressing format the ECU is using. If it is:
  • * NORMAL FIXED or MIXED addressing then it is problematic because (with 29bit CAN IDs) the CAN ID is dynamically generated from the source address (TesterClient) and the target address (ECU),
    * Extended addressing is also a problem because the Target address is set in the first byte of the CAN data frame so it should be required too,
    * NORMAL addressing should be the only addressing available in your case..
With NORMAL addressing, you can define 2 mappings (one from Client to physically address ECU and another from ECU to physically address Client):
- can ID type is 29 bits
- canID is the CAN ID the ECU listens to (ex. 0xABC001)
- canIDResponse is the CAN ID the ECU responds with (ex. 0xABC002)
- format is NORMAL
- message type is diagnostic message
- source address is 0xF1 (client)
- target address is 0x01 (ECU)
- target type is physical addressing
- remote address is not used and is 0x00

the second mapping is almost the same you anly have to swap source and target address and canId/canIdresponse:
- canID is the CAN ID the ECU responds with (ex. 0xABC002)
- canIDResponse is CAN ID the ECU listens to (ex. 0xABC001)
- format is NORMAL
- message type is diagnostic message
- source address is 0x01 (ECU)
- target address is 0xF1 (CLIENT)

Let me know if this helps you.
Best regards,
Fabrice

Daniel.
Posts: 4
Joined: Tue 5. Apr 2016, 15:40

Re: Source Adress / Target Adress

Post by Daniel. » Wed 6. Apr 2016, 09:58

Hello Fabrice,

Thank you for your fast answer and your detailed explanation. I realized your example and corrected a bug in my tester present function. I have to use "29B_Normal" as protocol and not "29B". Now it works fine, the answer of the function is PUDS_Error_Ok and with the function ReadDATAbyIdentifier the response contains the right answer.

Thank you for your help.

Best regard,
Daniel

vddvss
Posts: 10
Joined: Wed 12. Jun 2019, 10:21

Re: Source Adress / Target Adress

Post by vddvss » Tue 18. Jun 2019, 11:13

Hello Fabrice,

I have a similar situation, where I need to send a CAN frame with a 29 bit CAN ID of 0x18EF70C9, in an UDS service: Write Data By Identifier. with data content of: (0x54, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0x42 0x00)

What I did in C# so far was:

Created a request structure:

Code: Select all

TPUDSMsg request29 = new TPUDSMsg();

// initialization of request29 structure
request29.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request29.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request29.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request29.NETADDRINFO.RA = 0x00;
request29.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_29B_NORMAL;
Added Mapping:

Code: Select all

TPUDSCANHandle CAN_Channel_ABH;

ISO_TP_result = CanTpApi.AddMapping(CAN_Channel_ABH, 0x18EF70C9, 0x18EF70CA, TPCANTPIdType.PCANTP_ID_CAN_29BIT, TPCANTPFormatType.PCANTP_FORMAT_NORMAL, TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC, 0xF1, 0x01, TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);

if (ISO_TP_result != TPCANTPStatus.PCANTP_ERROR_OK) return (int)result;

ISO_TP_result = CanTpApi.AddMapping(CAN_Channel_ABH, 0x18EF70CA, 0x18EF70C9, TPCANTPIdType.PCANTP_ID_CAN_29BIT, TPCANTPFormatType.PCANTP_FORMAT_NORMAL, TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC, 0x01, 0xF1, TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);

if (ISO_TP_result != TPCANTPStatus.PCANTP_ERROR_OK) return (int)result;
Initialized Can Channel:

Code: Select all

TPUDSBaudrate CanBaud = TPUDSBaudrate.PUDS_BAUD_500K;
TPUDSStatus Status;

Status = UDSApi.Initialize(CAN_Channel_ABH, CanBaud, 0, 0, 0);
But when I get to the actual Write Data By Identifier, I see that the Identifier is only of ushort type, which does not allow my CAN ID (0x18EF70C9) to be fitted into it.

Caller in C# code:

Code: Select all

int status = 0;
var buffer = new byte[] { 0x54, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0x42, 0x00 };
TPUDSCANHandle CAN_CH = 0x52;

status = t.PEAK_UDS_wdbi29(CAN_CH, (ushort)UDSApi.TPUDSSvcParamDI.PUDS_SVC_PARAM_RSI_FLEXMAC, buffer);
The called function in C# code:

Code: Select all

public int PEAK_UDS_wdbi29(TPUDSCANHandle C_CH, ushort id, byte[] dataBuffer)
{
    int iter = 0;

    do
    {
        result = UDSApi.SvcWriteDataByIdentifier(C_CH, ref request29, id, dataBuffer, (ushort)dataBuffer.Length);
        if (result == TPUDSStatus.PUDS_ERROR_OK) result = UDSApi.WaitForService(C_CH, out response, ref request29, out requestConfirmation29);
        Thread.Sleep(++iter * sleepRaster);
    }
    while ((response.LEN == 3) && (response.DATA[2] == 0x21) && (iter < iterMax)); // checking for the 0x21, "busy, repeat request" situation

    if (result == TPUDSStatus.PUDS_ERROR_OK) return 0;
    else return (int)result;
}
How can I make this WDBI work from UDS level?
Maybe I need to manipulate my request29 structure directly?

Thank you for your response, Best Regards:
Balazs

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Source Adress / Target Adress

Post by F.Vergnaud » Tue 18. Jun 2019, 11:52

Hello Balazs,

Sorry but aren't you confusing the 29 bit CAN Identifier with the UDS Data Identifier for the UDS service SvcWriteDataByIdentifier?
Or do you mean that your DataIdentifier "PUDS_SVC_PARAM_RSI_FLEXMAC" is bigger than a ushort? ISO-14229 (UDS) standard defines that value only on 2 bytes.
Best regards,
Fabrice

vddvss
Posts: 10
Joined: Wed 12. Jun 2019, 10:21

Re: Source Adress / Target Adress

Post by vddvss » Tue 18. Jun 2019, 12:15

Hello Fabrice,

Yes, indeed, you were right, there was a mistake on my side. In fact I do not need to use the WDBI service, I just need to send the message as the data bytes listed.

If my understanding is correct, I could just use "UDS_Write" from UDS level, or "PCANBasic.Write" directly on PCAN Basic level, correct?

Is everything else correct in my setup to achieve the 29Bit CAN TX ID message sending?

Thank you and Best Regards:
Balazs

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Source Adress / Target Adress

Post by F.Vergnaud » Tue 18. Jun 2019, 13:05

You are right: simply use the Write function to send a UDS message.
And your configuration is alright, note that you can also directly use the UDS API to configure mappings. You can find an example in the documentation §4.3.3 p.342.
Best regards,
Fabrice

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Source Adress / Target Adress

Post by F.Vergnaud » Tue 18. Jun 2019, 13:13

Note: Unless you know exactly what is being transmitted on your CAN bus, I discourage to directly use PCANBasic while using UDS/ISOTP API as you could interrupt the transmission of pending fragmented messages.

Off-topic: btw have you received my email regarding your issue with a UDS delay and your network configuration?
Best regards,
Fabrice

ashoksam
Posts: 1
Joined: Mon 5. Aug 2019, 07:42

29 bit identifer

Post by ashoksam » Mon 5. Aug 2019, 07:50

hi all,
I am working on OBD-II with 11 bit and 29 bit identifier.I have only one ECU which consists of a custom CAN-Identifier.
Right now i am facing a problem like this custom CAN-Id's are not even working with the another ECU's which was used in Trucks which consists of same 29-bit but i don't know what is the CAN-Identifier for that module.
I am trying to implement my code to work with all kind of vehicles which consists of 29-bit identifiers.
Is there any document (or) any forum to find out solution for this kind of problems?

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Source Adress / Target Adress

Post by F.Vergnaud » Mon 5. Aug 2019, 09:52

Hello Ashoksam,

Sorry but I don't really understand your exact issue. If you are trying to use 29 bits mappings that supersedes standardized 29 bits fixed-normal network addressing, please make sure you are using the latest PCAN-UDS and PCAN-ISO-TP APIs: a patch was released to allow such behaviour.
We have also updated the UDS documentation to include more examples and use-cases (see §4.3 p.338).
Best regards,
Fabrice

Post Reply