Page 1 of 1

CAN ISO-TP mapping error

Posted: Thu 9. Aug 2018, 16:02
by RaduN
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 !

Re: CAN ISO-TP mapping error

Posted: Thu 9. Aug 2018, 16:44
by F.Vergnaud
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.

Re: CAN ISO-TP mapping error

Posted: Mon 13. Aug 2018, 12:21
by RaduN
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 ?

Re: CAN ISO-TP mapping error

Posted: Mon 13. Aug 2018, 13:29
by F.Vergnaud
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.

Re: CAN ISO-TP mapping error

Posted: Mon 13. Aug 2018, 14:30
by K.Wagner
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 8541 times

Re: CAN ISO-TP mapping error

Posted: Mon 13. Aug 2018, 15:40
by RaduN
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).

Re: CAN ISO-TP mapping error

Posted: Wed 15. Aug 2018, 08:38
by PEAK-Support
Maybe any Byte Allingment settings in BB5 ? I remember that we had such problems when we use the BB4/5 Versions in the past.

Re: CAN ISO-TP mapping error

Posted: Fri 17. Aug 2018, 15:04
by RaduN
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.

Re: CAN ISO-TP mapping error

Posted: Fri 17. Aug 2018, 15:20
by K.Wagner
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.