Source and Target address

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
Post Reply
sandeepc
Posts: 14
Joined: Thu 4. Apr 2024, 08:56

Source and Target address

Post by sandeepc » Thu 16. May 2024, 14:23

Hi,

I can able to receive and transmit the frame, through callback function.
But when i try to read the data from ECU i could not able to read the same data in polling method.

CAN ISO TP configuration:

Code: Select all

uint32_t ISOTP_init(cantp_mapping *mapping, cantp_handle client_handle, cantp_msg *tx_msg, cantp_msg* crc_msg)
{
	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, PCANTP_BAUDRATE_125K, (cantp_hwtype)0, 0, 0);
	printf("Initialize: %s\n", STATUS_OK_KO(res));

	// Change STmin value to 600us


	// Allocate tx message
	res = CANTP_MsgDataAlloc_2016(tx_msg, PCANTP_MSGTYPE_ISOTP);
	printf("Allocate tx message: %s\n\r", STATUS_OK_KO(res));

	res = CANTP_MsgDataAlloc_2016(crc_msg, PCANTP_MSGTYPE_ISOTP);
	printf("Allocate crc_msg message: %s\n\r", STATUS_OK_KO(res));

	// Set priority (add message options)
	res = CANTP_MsgDataInitOptions_2016(tx_msg, 1);
	tx_msg->msgdata.any->options->buffer[0].name = PCANTP_OPTION_J1939_PRIORITY;
	tx_msg->msgdata.any->options->buffer[0].value = 0x02;
	printf("Set message priority option: %s\n\r", STATUS_OK_KO(res));

	res = CANTP_MsgDataInitOptions_2016(crc_msg, 1);
	crc_msg->msgdata.any->options->buffer[0].name = PCANTP_OPTION_J1939_PRIORITY;
	crc_msg->msgdata.any->options->buffer[0].value = 0x02;
	printf("Set message priority option: %s\n\r", STATUS_OK_KO(res));

	// 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 1;
}
ECU configuration:

Code: Select all

n_req_t dummy_frame =
{
	.n_ai.n_pr = 0x08,                            /* Network Address Priority */
	.n_ai.n_sa = 0xF1,                           /* Network Source Address */
	.n_ai.n_ta = 0x01,                           /* Network Target Address */
	.n_ai.n_ae = 0x00,                         /* Network Address Extension */
	.n_ai.n_tt = N_TA_T_PHY,             /* Network Target Address type */
	.fr_fmt = CBUS_FR_FRM_STD,        /* CANBus Frame format */
	.
};
Is it above configuration is correct or is it required swap source and target address in ECU side to exchange source and target address?
can you elaborate on these configuration.


Regards,
Sandeep C
Last edited by F.Vergnaud on Thu 16. May 2024, 15:42, edited 1 time in total.
Reason: added code formatting

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

Re: Source and Target address

Post by F.Vergnaud » Thu 16. May 2024, 15:59

Hello,

Mappings are not required when using format FIXED_NORMAL, see user manual p.263 §4.4 ISO-TP Network Addressing Format.
You should check sample 04_client_ISO15765-2_fixed_normal_addressing.
Best regards,
Fabrice

sandeepc
Posts: 14
Joined: Thu 4. Apr 2024, 08:56

Re: Source and Target address

Post by sandeepc » Fri 17. May 2024, 10:40

Thanks for the reply,

Which addressing format is better to exchange data between pc and ECU?
Can you give an example for better mapping between ECU and PC?

Regards,
sandeep C

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

Re: Source and Target address

Post by F.Vergnaud » Fri 17. May 2024, 11:43

The choice of adressing format is out of scope of our API, this design process is based on multiple factors (support of 29 bit CAN ID or not, need to have the target address in the data content, etc.) and should be defined by the architect of the CAN/ISOTP network .
Check document ISO-15765-2 if you need to learn more about ISOTP network addressing.

The PCAN-ISO-TP package already includes examples with mappings like 01 and 02 or with automated mappings like 03 and 04.
Best regards,
Fabrice

Post Reply