Page 1 of 1

CANTP_InitializeFD_2016

Posted: Tue 11. Jun 2024, 14:35
by sandeepc
Hi, Thanks for PEAK Forum,
Now i am able to exchange huge amount of data between ECU and PC using PEAK CAN ISO TP API with Standard CAN and Extended ID, PCANTP_ISOTP_FORMAT_FIXED_NORMAL, addressing format.

SO we are facing to read and write huge data ST time delay is introducing for every 8 bytes, to avoid this delay for 8 bytes we planned to use CAN FD where we can transfer 64bytes, for every 64 bytes ST time will be added by using this we can speed up data exchange.

but i have not found any example except 3.7.2 CANTP_InitializeFD_2016 pg no:229

as i got previous reply add mapping is not required does it mean if i initialization CANTP_InitializeFD_2016 is it enough? when i use FIXED_NORMAL.? if not how can i initialize CANFD for ISO TP?

viewtopic.php?f=181&t=7635&p=19767#p19767
in above link saying
Mappings are not required when using format FIXED_NORMAL, see user manual p.263 ยง4.4 ISO-TP Network Addressing Format.

Present configuration:

Code: Select all

cantp_status ISOTP_init(cantp_mapping* mapping, cantp_handle client_handle)
{
	char version_buffer[500];
	cantp_status res;

	// Print version informations
	CANTP_GetValue_2016(PCANTP_HANDLE_NONEBUS, PCANTP_PARAMETER_API_VERSION, version_buffer, 500);
	printf("PCAN-ISO-TP API Version: %s\n\r", version_buffer);

	// Initialize channels: CAN2.0 - 500Kbit/s
	res = CANTP_Initialize_2016(client_handle, BAUDRATE, (cantp_hwtype)0, 0, 0);
	printf("Initialize BAUDRATE: %s\n", STATUS_OK_KO(res));

	// Change STmin value to 600us

	// Create a simple physical mapping: 
//    - Source 0xF1 (client), target 0x01 (server)
//    - Diagnostic message in a fixed normal format

	mapping->can_msgtype = PCANTP_CAN_MSGTYPE_EXTENDED;
	mapping->netaddrinfo.extension_addr = 0x00;
	mapping->netaddrinfo.format = PCANTP_ISOTP_FORMAT_FIXED_NORMAL;
	mapping->netaddrinfo.msgtype = PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
	mapping->netaddrinfo.source_addr = 0xF1;
	mapping->netaddrinfo.target_addr = 0x01;
	mapping->netaddrinfo.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;

	//printf("Can tp initialze success\n\r");
	return res;
}
for CAN FD how Can i initialize?

Re: CANTP_InitializeFD_2016

Posted: Tue 11. Jun 2024, 15:49
by sandeepc
I tried this configuration

Code: Select all

cantp_status ISOTP_FDinit(cantp_mapping* mapping, cantp_handle client_handle)
{
	char version_buffer[500];
	cantp_status res;
	uint32_t buffer = 15;

	// Print version informations
	CANTP_GetValue_2016(PCANTP_HANDLE_NONEBUS, PCANTP_PARAMETER_API_VERSION, version_buffer, 500);
	printf("PCAN-ISO-TP API Version: %s\n\r", version_buffer);

	// Initialize channels: CAN2.0 - 500Kbit/s
	// The Plug and Play channel (PCAN-USB) is initialized @500kbps/2Mbps.
	res = CANTP_InitializeFD_2016(client_handle, "f_clock=80000000, nom_brp=10,nom_tseg1 = 12, nom_tseg2 = 3, nom_sjw = 1, data_brp = 4, data_tseg1 = 7, data_tseg2 = 2, data_sjw = 1");

	if (!CANTP_StatusIsOk_2016(res, PCANTP_STATUS_OK, false))
		printf("Initialization failed\n");
	else
		printf("PCAN-USB was initialized\n");

	res = CANTP_SetValue_2016(client_handle, PCANTP_PARAMETER_CAN_TX_DL, &buffer, sizeof(buffer));
	if (!CANTP_StatusIsOk_2016(res, PCANTP_STATUS_OK, false))
		printf("PCANTP_PARAMETER_CAN_TX_DL failed\n");
	else
		printf("PCANTP_PARAMETER_CAN_TX_DL initialized\n");

	// Change STmin value to 600us

	// Create a simple physical mapping: 
	//    - Source 0xF1 (client), target 0x01 (server)
	//    - Diagnostic message in a fixed normal format

	mapping->can_msgtype = PCANTP_CAN_MSGTYPE_EXTENDED | PCANTP_CAN_MSGTYPE_FD;//d
	mapping->netaddrinfo.extension_addr = 0x00; //
	mapping->netaddrinfo.format = PCANTP_ISOTP_FORMAT_FIXED_NORMAL;
	mapping->netaddrinfo.msgtype = PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
	mapping->netaddrinfo.source_addr = 0xF1;
	mapping->netaddrinfo.target_addr = 0x01;
	mapping->netaddrinfo.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL; //dd
	mapping->can_tx_dlc = 15;

	//printf("Can tp initialze success\n\r");
	return res;
}

still its not working?

Re: CANTP_InitializeFD_2016

Posted: Wed 12. Jun 2024, 10:36
by F.Vergnaud
Hello,

You can check example "08_canfd_read_write" to have an example of CANFD initialization.

When you initialize your ISOTP message, make sure to set the flag PCANTP_CAN_MSGTYPE_FD:

Code: Select all

[...]
 // Code based on Sample 08_canfd_read_write
 // Define Bitrate: SAE J2284-4: High-Speed CAN (HSC) for Vehicle Applications at 500 kbps with CAN FD Data at 2 Mbps 
 #define PCAN_BITRATE_SAE_J2284_4     "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4"
	res = CANTP_InitializeFD_2016(client_handle, PCAN_BITRATE_SAE_J2284_4);
 [...]

 // Code based on Sample 04_client_ISO15765-2_fixed_normal_addressing
 [...]
	// Allocate tx message
	res = CANTP_MsgDataAlloc_2016(&tx_msg, PCANTP_MSGTYPE_ISOTP);
	printf("Allocate tx message: %s\n", STATUS_OK_KO(res));

	// configure FIXED_NORMAL physical mapping: 
	//    - Source 0xF1 (client), target 0x01 (server)
	//    - Diagnostic message in a fixed normal format
	mapping.can_msgtype = PCANTP_CAN_MSGTYPE_EXTENDED | PCANTP_CAN_MSGTYPE_FD;   <----- FD flag
	mapping.netaddrinfo.extension_addr = 0x00;
	mapping.netaddrinfo.format = PCANTP_ISOTP_FORMAT_FIXED_NORMAL;
	mapping.netaddrinfo.msgtype = PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
	mapping.netaddrinfo.source_addr = 0xF1;
	mapping.netaddrinfo.target_addr = 0x01;
	mapping.netaddrinfo.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;

	// Initialize Tx message
	res = CANTP_MsgDataInit_2016(&tx_msg, mapping.can_id, mapping.can_msgtype, MSG_SIZE, MSG, &mapping.netaddrinfo);
	printf("Initialize tx message: %s\n", STATUS_OK_KO(res));
[...]
You configured the parameter PCANTP_PARAMETER_CAN_TX_DL, this value will be used by default in your Tx ISOTP communication.
If you want to override this value, you have to set it in the "tx_msg.can_info.dlc" after the call to CANTP_MsgDataInit_2016(..).

Re: CANTP_InitializeFD_2016

Posted: Fri 14. Jun 2024, 16:16
by sandeepc
Hi thanks now its working fine.


Regards,
Sandeep C

Re: CANTP_InitializeFD_2016

Posted: Fri 14. Jun 2024, 16:26
by M.Heidemann
Hi Sandeep,

Thank you for letting us know!

Best Regards

Marvin

- Topic closed -