Function CANTP_AddMapping with a target type Functional

A free API for the communication with control devices according to UDS (ISO 14229-1)

Function CANTP_AddMapping with a target type Functional

Postby A.Julin » Tue 10. Oct 2017, 10:39

Hello,

I'm trying to use CANTP_AddMapping function for target type functional.
According to my ECU specification :
CAN Broadcast id : 0x223
CAN tester id : 0x12B

First I wrote the following code :
Code: Select all
        TPUDSStatus resultMap = CANTP_AddMapping(PCANTP_USBBUS1, //CanChannel
                                                 0x223, //canID
                                                 CAN_ID_NO_MAPPING, //canIDResponse
                                                 PCANTP_ID_CAN_11BIT, // canIdType
                                                 PCANTP_FORMAT_NORMAL, //formatType
                                                 PCANTP_MESSAGE_DIAGNOSTIC, // msgType
                                                 PUDS_SERVER_ADDR_TEST_EQUIPMENT, //sourceAddr
                                                 0xF5, // targetAddr
                                                 PCANTP_ADDRESSING_FUNCTIONAL, //targetType
                                                 0x00 // remoteAddr
                                                 );
...
        resultMap = CANTP_AddMapping(PCANTP_USBBUS1, //CanChannel
                                     0x12B, //canID
                                     CAN_ID_NO_MAPPING, //canIDResponse
                                     PCANTP_ID_CAN_11BIT, // canIdType
                                     PCANTP_FORMAT_NORMAL, //formatType
                                     PCANTP_MESSAGE_DIAGNOSTIC, // msgType
                                     0xF5, //sourceAddr
                                     PUDS_SERVER_ADDR_TEST_EQUIPMENT, // targetAddr
                                     PCANTP_ADDRESSING_PHYSICAL, //targetType
                                     0x00 // remoteAddr
                                     );


To use it, I just wrote UDS_SvcReadDataByIdentifier and UDS_WaitForServiceFunctional with the parameter request.NETADDRINFO.TA = 0xF5;

I got the following CAN communication
Code: Select all
;   Message Number
;   |         Time Offset (ms)
;   |         |        Type
;   |         |        |        ID (hex)
;   |         |        |        |     Data Length
;   |         |        |        |     |   Data Bytes (hex) ...
;   |         |        |        |     |   |
;---+--   ----+----  --+--  ----+---  +  -+ -- -- -- -- -- -- --
     1)      1403.4  Rx         0111  8  00 00 00 5D 6E 00 00 00 //not relevant
     2)      1949.4  Rx     00000123  8  00 00 00 00 00 00 00 00 //not relevant
     3)      2177.4  Rx         0223  8  03 22 FD 02 FF FF FF FF
     4)      2179.5  Rx         012B  8  07 62 FD 02 00 00 02 22
     5)      3950.4  Rx     00000123  8  00 00 00 00 00 00 00 00 //not relevant
     6)      5951.3  Rx     00000123  8  00 00 00 00 00 00 00 00 //not relevant
     7)      6404.2  Rx         0111  8  00 00 00 5D 6E 00 00 00 //not relevant


As expected, the tester equipment sent on 0x223 and the ECU answered on 0x12B
But, my second mapping is wrong because I can get the answer from the ECU
After some modification, the best I can catch is the request from the tester itself
Code: Select all
"UDS REQUEST from 0xF1 (to 0xF5, with RA 0x0) - result: 0 - OK !\n"
"     -> Length: 3, Data= 22 FD 02"


So due to my wrong mapping the tester ignore the ECU answer.
Could you explain me how to fix this?
Thank you in advance.
Best regards
Alexis
A.Julin
 
Posts: 6
Joined: Fri 30. Jun 2017, 12:57

Re: Function CANTP_AddMapping with a target type Functional

Postby F.Vergnaud » Tue 10. Oct 2017, 11:06

Hello Alexis,

The ECU response is physically addressed to the tester present so you need to specify the "CAN ID response" of the internal ISO-TP communication: behind the scene there are more than a single request and a single response, the messages are fragmented in several CAN frames.

To sum up:
1. the tester present "speaks" with listening ECUs on CAN ID 0x223 (it is a one-way communication),
2. ECU #0xF5 "speaks" with the tester present on CAN ID 0x12B,
3. the tester responds to ECU #0xF5 with CAN ID ??? (telling stuff about how to transmit),
4. ECU #0xF5 continue to speaks with the tester present on CAN ID 0x12B
5. if the message is quite big and depending on parameters, go back to 3 until message is fully transmitted.

So when you define the mapping, you need to change the canIdResponse value "CAN_ID_NO_MAPPING" to a correct ID (check the specification of your ECU, it corresponds to the physical request from Tester Present to the ECU):
Code: Select all
  resultMap = CANTP_AddMapping(PCANTP_USBBUS1, //CanChannel
                                     0x12B, //canID
                                     ????????, //canIDResponse
                                     PCANTP_ID_CAN_11BIT, // canIdType
                                     PCANTP_FORMAT_NORMAL, //formatType
                                     PCANTP_MESSAGE_DIAGNOSTIC, // msgType
                                     0xF5, //sourceAddr
                                     PUDS_SERVER_ADDR_TEST_EQUIPMENT, // targetAddr
                                     PCANTP_ADDRESSING_PHYSICAL, //targetType
                                     0x00 // remoteAddr
                                     );

Also note that this will define an automatic response mapping: tester present will only be able to respond to requests. But if you later need to send a physical request from TesterPresent to ECU#0xF5, you have to define another mapping:
Code: Select all
  resultMap = CANTP_AddMapping(PCANTP_USBBUS1, //CanChannel
                                     ????????, //canID
                                     0x12B, //canIDResponse
                                     PCANTP_ID_CAN_11BIT, // canIdType
                                     PCANTP_FORMAT_NORMAL, //formatType
                                     PCANTP_MESSAGE_DIAGNOSTIC, // msgType
                                     PUDS_SERVER_ADDR_TEST_EQUIPMENT, //sourceAddr
                                     0xF5, // targetAddr
                                     PCANTP_ADDRESSING_PHYSICAL, //targetType
                                     0x00 // remoteAddr
                                     );
Best regards,
Fabrice
F.Vergnaud
Software Development
Software Development
 
Posts: 81
Joined: Mon 9. Sep 2013, 11:21

Re: Function CANTP_AddMapping with a target type Functional

Postby A.Julin » Tue 10. Oct 2017, 13:34

Ok thank you for the fast answer, I will try to find the missing CAN id.

Best regards
Alexis

EDIT : I got the information and it works. Thank you very much for the help
A.Julin
 
Posts: 6
Joined: Fri 30. Jun 2017, 12:57


Return to PCAN-UDS