CAN ISO-TP mapping error

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
Post Reply
RaduN
Posts: 4
Joined: Thu 9. Aug 2018, 15:23

CAN ISO-TP mapping error

Post by RaduN » Thu 9. Aug 2018, 16:02

Hello,
I am trying to implement CAN TP_ISO diagnose using a PCAN-USB FD interface.
I am getting an error on second mapping call.
Up to there everything is OK.
I have following code:

...
Byte N_SA = 0x01;
Byte N_TA_PHYS = 0x02;
Byte N_RA = 0x00;
pCANChannel = PCANTP_USBBUS1;//first channel of USB interface
pBaudRate = PCANTP_BAUD_500K ;
status = pCANTP_Initialize(pCANChannel, pBaudRate);
status = pCANTP_Reset(pCANChannel);
status = pCANTP_AddMapping(pCANChannel, 0x770, 0x710, PCANTP_ID_CAN_11BIT, PCANTP_FORMAT_NORMAL, PCANTP_MESSAGE_DIAGNOSTIC, N_TA_PHYS, N_SA, PCANTP_ADDRESSING_PHYSICAL, 0x00);
status = pCANTP_AddMapping(pCANChannel, 0x710, 0x770, PCANTP_ID_CAN_11BIT, PCANTP_FORMAT_NORMAL, PCANTP_MESSAGE_DIAGNOSTIC, N_SA, N_TA_PHYS, PCANTP_ADDRESSING_PHYSICAL, 0x00);

status is 2 after second addmapping call, 0 for all previous calls.
I apreciate any sugestions.

Thank you !

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

Re: CAN ISO-TP mapping error

Post by F.Vergnaud » Thu 9. Aug 2018, 16:44

Hello,

I've just tried your code and it works without any error with the latest version of the API.
Please check that you are using the latest version of PCAN-ISO-TP API: v2.0.2.102.
Best regards,
Fabrice

RaduN
Posts: 4
Joined: Thu 9. Aug 2018, 15:23

Re: CAN ISO-TP mapping error

Post by RaduN » Mon 13. Aug 2018, 12:21

Hello,
Thank you for the reply.
In original code I had a few other lines between the function calls but even with the code cleaned up and only function calls remaining I still get the status = 2 after the second mapping function call and the led on the interface is blinking red.
I use PCAN-ISO-TP v2.0.2.102 and PCANBasic version 4.3.0.150 with Borland C++ Builder on Win7.
I have a PCAN-USB FD interface with 2.3.1 firnware and 4.1.4.16279 driver version.
Any other possible causes or suggestions ?

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

Re: CAN ISO-TP mapping error

Post by F.Vergnaud » Mon 13. Aug 2018, 13:29

The function CANTP_AddMapping returns the error code PCANTP_ERROR_ALREADY_INITIALIZED (err=2) on those conditions only:
- the channel is not initialized. This seems unlikely since your previous call to CANTP_Addmapping succeeded.
- the new mapping corresponds to an already defined mapping: in your case (a diagnostic message using Normal addressing), the function only checks that the CAN ID (0x710) is not used by a previously defined mapping.

Also note that a blinking red LED on a PCAN-USB FD device indicates that you're having CAN Bus error. An initialized channel with status "OK" bus should have a green blinking LED.
Best regards,
Fabrice

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: CAN ISO-TP mapping error

Post by K.Wagner » Mon 13. Aug 2018, 14:30

Hello,

The versions you are using (driver, firmware, APIs) are OK. A red Led means, as Fabrice already wrote, that CAN errors are being generated because of sending messages...:
  • ...in an open network (no other participant)
  • ...using a bit rate that differs from the bit rate of other participant(s)
  • ...using a not well terminated connection.

As Fabrice did, I also tested the mappings you mentioned and I can set them without a problem. Could you try to do this with any of the example projects that are shipped with the ISO-TP package? Please set the mappings with it and try to do communication. Here a picture of how they look at my computer:
Mappings
Mappings
iso-tp.png (18.97 KiB) Viewed 8542 times
Best regards,
Keneth

RaduN
Posts: 4
Joined: Thu 9. Aug 2018, 15:23

Re: CAN ISO-TP mapping error

Post by RaduN » Mon 13. Aug 2018, 15:40

It's strange.
I used the PCANIsoTP CLR example for VS and it works normally, as it should. I can send requests and get responses from ECU.
I checked with debug the parameters values for the AddMapping function and they are identical to the values I have in C++ Builder call.
However I still get an error on second mapping call in C++ Builder.
I suspect it's a Builder issue since it's an old version (v5.0).

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: CAN ISO-TP mapping error

Post by PEAK-Support » Wed 15. Aug 2018, 08:38

Maybe any Byte Allingment settings in BB5 ? I remember that we had such problems when we use the BB4/5 Versions in the past.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

RaduN
Posts: 4
Joined: Thu 9. Aug 2018, 15:23

Re: CAN ISO-TP mapping error

Post by RaduN » Fri 17. Aug 2018, 15:04

I tried all C++ Builder settings for byte alignment but still no luck.

I removed a mapping and left only one to see if I can get to message sending even without response.

status = pCANTP_AddMapping(PCANTP_USBBUS1, 0x710, 0x770, PCANTP_ID_CAN_11BIT, PCANTP_FORMAT_NORMAL, PCANTP_MESSAGE_DIAGNOSTIC, N_SA, N_TA, PCANTP_ADDRESSING_PHYSICAL, N_RA);

status is 0 after call but the led turns red and begins flashing the moment the function is called.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: CAN ISO-TP mapping error

Post by K.Wagner » Fri 17. Aug 2018, 15:20

As I said in a previous post, red lightning means communication problems. Please activate the debug log of PCAN-Basic (check this post).

It will be generated in the same folder of the calling process. In there you can check if the bit rate used is correct. You also will see the raw CAN messages being sent from ISO-TP Api.
Best regards,
Keneth

Post Reply