ISO-TP mapping problem

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)

ISO-TP mapping problem

Postby awild » Fri 5. Apr 2019, 18:14

Hello to all,
I have an ECU with ISO-TP/UDS with non standard CAN-ID 29Bit and normal adressing.
The ID´s for Request and Response are as follows:

Code: Select all
UInt32 Diag_BT_1_Req  = 0x17FC0647;
UInt32 Diag_BT_1_Resp = 0x17FE0647; //Please note source and target are still at same position which is correct
byte SourceAdr = 0x47;              //for this application (non standard ECU)
byte TargetAdr = 0x06;

With the following code I do a UDS Service request by ID (0x22). The response will contain 33 bytes.
The request is sent to the bus correct, even the Flow Control Frame is generated ok.
I checked also the response from the ECU: The 33 bytes can be seen on the bus with proper ISO-TP handling.

But the UDSApi.WaitForService() function obviously doesn´t see anything on the bus, because it returns with error 7 (no message).
I further found out that only the last added mapping is used for generating the requests to the ECU. That´s why in this last mapping I call: MappingStatus(Diag_BT_1_Req, Diag_BT_1_Resp, //Diag_BT_1_Req is first!!

So I think the mapping for the response part cannot be found by the library due to some reason. May be because it cannot be distinguished due to the NONE swapped source and target adresses?
So must likely I did some mistake in defining the two mappings below:

Code: Select all
        UInt32 iBuffer;
        TPUDSStatus stsResult;

        CanHdlUDS = UDSApi.PUDS_USBBUS1;
        stsResult = UDSApi.Initialize(CanHdlUDS, TPUDSBaudrate.PUDS_BAUD_500K);

        MappingStatus mapping2 = new MappingStatus(Diag_BT_1_Resp, Diag_BT_1_Req,
            TPCANTPIdType.PCANTP_ID_CAN_29BIT,
            TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
            TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
            TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
            SourceAdr,
            TargetAdr);
        mappingsAdd(CanHdlUDS, mapping2);

        MappingStatus mapping1 = new MappingStatus(Diag_BT_1_Req, Diag_BT_1_Resp,
              TPCANTPIdType.PCANTP_ID_CAN_29BIT,
              TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
              TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
              TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
              SourceAdr,
              TargetAdr);
        mappingsAdd(CanHdlUDS, mapping1);

        TPUDSMsg request = new TPUDSMsg();
        TPUDSMsg requestConfirmation = new TPUDSMsg();
        TPUDSMsg response = new TPUDSMsg();
        // initialization
        request.NETADDRINFO.SA = SourceAdr;
        request.NETADDRINFO.TA = TargetAdr;
        request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
        request.NETADDRINFO.RA = 0x00;
        request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_29B_NORMAL;

        // Sends a Physical ReadDataByIdentifier Request
        ushort[] buffer = { 0xFD54};
        stsResult = UDSApi.SvcReadDataByIdentifier(CanHdlUDS, ref request, buffer, (ushort)buffer.Length);

        if (stsResult == TPUDSStatus.PUDS_ERROR_OK)
            stsResult = UDSApi.WaitForService(CanHdlUDS, out response, ref request, out requestConfirmation);
        if (stsResult == TPUDSStatus.PUDS_ERROR_OK)
            new MsgBox("","Response was received.").Show();
        else
            // An error occurred
            new MsgBox("",String.Format("Error occured: {0}", (int)stsResult)).Show();

Thank you very much for your help
Andy
Last edited by K.Wagner on Mon 8. Apr 2019, 07:32, edited 1 time in total.
Reason: Format applied for better reading
awild
 
Posts: 17
Joined: Tue 2. Apr 2019, 12:29
Location: Herrsching, Germany

Re: ISO-TP mapping problem

Postby K.Wagner » Mon 8. Apr 2019, 10:44

Hello,

note that the default address for the "tester client" is 0xF1. Everything that is not addressed to the local address is discarded by the API. Since you are using 0x47 as source address, you need to change this within the API by using the parameter PUDS_PARAM_SERVER_ADDRESS and the function PUDS_SetValue. You find more information about this within the help file at the page 34.

Added to this, you can see the use of this parameter within the sample code, file "PCUClient.cpp", at the beginning of the function _tmain

Code: Select all
   // Define Address
   iBuffer = PUDS_SERVER_ADDR_TEST_EQUIPMENT;
   Status = UDS_SetValue(Channel, PUDS_PARAM_SERVER_ADDRESS, &iBuffer, 1);
   printf("  Set ServerAddress: %i (0x%02x)\n", (int)Status, iBuffer);
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 640
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: ISO-TP mapping problem

Postby awild » Mon 8. Apr 2019, 11:25

Hello Keneth,
thanks for this important hint!

I did it like this because there is UInt32 required as parameters in SetValue().
iBuffer = 0x47;
UDSApi.SetValue(CanHdlUDS, TPUDSParameter.PUDS_PARAM_SERVER_ADDRESS, ref iBuffer, sizeof(UInt32));

Unfortunately it still doesn´t work. I can say again: All the Requests (initiated from the Server 0x47) are all generated ok...
I attached a picture from the trace of the communication.
The UDS Library sends:
- 0x17FC0647 with Service 0x22
- the ECU answers correct with 0x17FE0647 (green colour)
- the UDS Library also sends the correct Flow Control Frame with 0x17FC0647

Just the recognition of the response is somehow not done by the UDS Library.

Thanks a lot
Andy
Attachments
Diag Response.png
Diag Response.png (21.72 KiB) Viewed 350 times
awild
 
Posts: 17
Joined: Tue 2. Apr 2019, 12:29
Location: Herrsching, Germany

Re: ISO-TP mapping problem

Postby awild » Mon 8. Apr 2019, 11:34

Hello Keneth,

I did the required mapping direct with the ISO-TP Library.
I found this UDS Parameter now: PUDS_PARAM_MAPPING_ADD
Maybe I have to perform the mapping via this parameter, therefore the UDS library gets notified about the mapping at all?

best regards
Andy
awild
 
Posts: 17
Joined: Tue 2. Apr 2019, 12:29
Location: Herrsching, Germany

Re: ISO-TP mapping problem

Postby K.Wagner » Mon 8. Apr 2019, 14:08

Hello,

awild wrote:I did the required mapping direct with the ISO-TP Library.

It is Ok to do so.

awild wrote:I found this UDS Parameter now: PUDS_PARAM_MAPPING_ADD
Maybe I have to perform the mapping via this parameter, therefore the UDS library gets notified about the mapping at all?

The call with UDS_SetValue(PUDS_PARAM_MAPPING_ADD) is a forwarding call to CANTP_AddMapping. This is just a shortcut for adding mappings, since they are used very often, and in this way you don't need to link the ISO-TP library directly.

awild wrote:So must likely I did some mistake in defining the two mappings below:

CODE: SELECT ALL
.....

        MappingStatus mapping2 = new MappingStatus(Diag_BT_1_Resp, Diag_BT_1_Req,
            TPCANTPIdType.PCANTP_ID_CAN_29BIT,
            TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
            TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
            TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
            SourceAdr,
            TargetAdr);
        mappingsAdd(CanHdlUDS, mapping2);

        MappingStatus mapping1 = new MappingStatus(Diag_BT_1_Req, Diag_BT_1_Resp,
              TPCANTPIdType.PCANTP_ID_CAN_29BIT,
              TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
              TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
              TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
              SourceAdr,
              TargetAdr);
        mappingsAdd(CanHdlUDS, mapping1);

.....

Yes, you have not swapped SA and TA in one of your mappings, so the API cannot understand one direction of the communication.

Try using this:
Code: Select all
MappingStatus mapping2 = new MappingStatus(Diag_BT_1_Resp, Diag_BT_1_Req,
            TPCANTPIdType.PCANTP_ID_CAN_29BIT,
            TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
            TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
            TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
            TargetAdr,
            SourceAdr);
        mappingsAdd(CanHdlUDS, mapping2);

        MappingStatus mapping1 = new MappingStatus(Diag_BT_1_Req, Diag_BT_1_Resp,
              TPCANTPIdType.PCANTP_ID_CAN_29BIT,
              TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
              TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
              TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
              SourceAdr,
              TargetAdr);
        mappingsAdd(CanHdlUDS, mapping1);
Last edited by K.Wagner on Mon 8. Apr 2019, 14:13, edited 1 time in total.
Reason: Code quote was simplified for better reading
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 640
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: ISO-TP mapping problem

Postby awild » Tue 9. Apr 2019, 07:22

Good morning Keneth,

It is working perfectly now, thank you so much for your help indeed!

Actually I was pretty aware of the fact that I did NOT swap Source and Target in the two mappings, because
in my non standard application they aren´t swapped on the bus either!
You gave me an example of a standard communication previously (see picture "standard").
In here your adresses 0x01 and 0x02 are swapped regarding request and response respectively.
But in my application the pairing target/source 0x0647 is always constant nevertheless it´s request or response.
(see picture "non standard"). Therefore I kept it non swapped in my mappings too...
I would never have had the idea to swap it in the mappings before you told me!
Anyhow I am happy it is working now, but there was also a lot of try and error.
I would very much appreciate some advices for further documentation how the mapping is handled in detail if available, so I can dig myself into it.

A nice day to you and your team
Andy

PS: There is a small spelling issue in the ISO-TP library and documentation:
On page 35 it says:
PCANTP_PARAM_SEPARATION_TIME 0xE2 Byte ISO-TP "SeparationTime" (STmin) parameter
which is correct.
However in the library itself as well as in the examples of the docu the parameter is spelled different:
PCANTP_PARAM_SEPERATION_TIME

I noticed this when a search for this parameter in the include file had no result.
Attachments
Non standard.png
Non standard.png (21.72 KiB) Viewed 341 times
Standard.PNG
Standard.PNG (23.15 KiB) Viewed 341 times
awild
 
Posts: 17
Joined: Tue 2. Apr 2019, 12:29
Location: Herrsching, Germany

Re: ISO-TP mapping problem

Postby K.Wagner » Tue 9. Apr 2019, 10:28

Hello,

awild wrote:Actually I was pretty aware of the fact that I did NOT swap Source and Target in the two mappings, because
in my non standard application they aren´t swapped on the bus either!
You gave me an example of a standard communication previously (see picture "standard").
In here your adresses 0x01 and 0x02 are swapped regarding request and response respectively.
But in my application the pairing target/source 0x0647 is always constant nevertheless it´s request or response.
(see picture "non standard").

Please note that the CAN-IDs used have nothing to do with the source and target address in your case. You are using a kind of communication where the CAN-Ids are customized, this means, you can use whatever you want use as IDs. On the other side, ISO-TP definitions clearly states, that the source and target of communication is well defined (Network addressing information).

As mentioned in an early post, you set the address of the client tester with "PUDS_SERVER_ADDR_TEST_EQUIPMENT". At this moment the API knows that the SA of outgoing messages and TA of incoming messages is to be compared to this value. If the information of SA and TA included in those messages don't match then messages are discarded. Since you didn't swapped the addresses, one direction was not well mapped.

awild wrote:I would very much appreciate some advices for further documentation how the mapping is handled in detail if available, so I can dig myself into it.

Please check the page 338 within the file "PCAN-UDS-API_UserMan_eng.pdf" for more information. Information about the parameters PUDS_PARAM_MAPPING_ADD and PUDS_PARAM_MAPPING_REMOVE at the pages 36 and 37 is also useful, since sometimes users need to change already defined mappings.

awild wrote:PS: There is a small spelling issue in the ISO-TP library and documentation:
On page 35 it says:
PCANTP_PARAM_SEPARATION_TIME 0xE2 Byte ISO-TP "SeparationTime" (STmin) parameter
which is correct.
However in the library itself as well as in the examples of the docu the parameter is spelled different:
PCANTP_PARAM_SEPERATION_TIME

This is a known issue, but thanks nevertheless.
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 640
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany


Return to PCAN-ISO TP



This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy