Address mapping

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

Address mapping

Post by sandeepc » Thu 23. May 2024, 07:22

** Edit by Admin - please read Forum Rules ! code need to be tagged - next time Post will be deleted if you do not follow the basic rules **
Hi,
i am facing regarding address mapping,

I am using normal address mode, so for can ISO tp side I configured as below

Code: Select all

int main()
{
	// Local variables
	cantp_status res;
	cantp_msg tx_msg, rx_msg, crc_msg;
	cantp_mapping mapping;
	cantp_handle client_handle;
	uint32_t opt;
	cantp_mapping reverse_mapping;


	// Initialize structs 
	client_handle = PCANTP_HANDLE_USBBUS1; // TODO: modify the value according to your available PCAN devices.
	memset(&tx_msg, 0, sizeof(cantp_msg));
	memset(&mapping, 0, sizeof(cantp_mapping));
	memset(&reverse_mapping, 0, sizeof(cantp_mapping));

	memset(&crc_msg, 0, sizeof(cantp_msg));
	//noram address mapping

	mapping.can_id = 0xA1;
	mapping.can_id_flow_ctrl = 0xA2;
	mapping.can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;
	mapping.can_tx_dlc = 0x0;									//NA
	mapping.netaddrinfo.extension_addr = 0x00;					//NA
	mapping.netaddrinfo.format = PCANTP_ISOTP_FORMAT_NORMAL;	//normal addressing mode
	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;

	// Create the associated reversed mapping: 
	reverse_mapping = mapping;
	reverse_mapping.can_id = mapping.can_id_flow_ctrl;
	reverse_mapping.can_id_flow_ctrl = mapping.can_id;
	reverse_mapping.netaddrinfo.source_addr = mapping.netaddrinfo.target_addr;
	reverse_mapping.netaddrinfo.target_addr = mapping.netaddrinfo.source_addr;
	// Initialize channels: CAN2.0 - 500Kbit/s
	res = CANTP_Initialize_2016(client_handle, BAUDRATE, (cantp_hwtype)0, 0, 0);
	printf("Initialize: %s\n", STATUS_OK_KO(res));


	// Add mappings on channels
	res = CANTP_AddMapping_2016(client_handle,&mapping);
	res = CANTP_AddMapping_2016(client_handle, &reverse_mapping);
	configuretimeout(client_handle);

	CanISOTPCallback();

	configuretimeout(client_handle);
	
	uint8_t buff[1000];

	for (int i = 0; i < 1000; i++)
	{
		buff[i] = 0x01;
	}
	SendISOTPData(client_handle, &mapping, buff, 100);
	while (1)
	{
		

	}
}

//function definition
uint32_t SendISOTPData(cantp_handle client_handle, cantp_mapping* mapping, uint8_t* buff, uint32_t len)
{
	cantp_msg tx_msg;
	cantp_status res;

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

	//res = CANTP_MsgDataInitOptions_2016(&tx_msg, 1);
	//printf("Set message priority option: %s\n", STATUS_OK_KO(res));

	res = CANTP_MsgDataInit_2016(&tx_msg, mapping->can_id, mapping->can_msgtype, len, buff, &mapping->netaddrinfo);
	res = CANTP_Write_2016(client_handle, &tx_msg);
	Sleep(20);

	// Free message space
	res = CANTP_MsgDataFree_2016(&tx_msg);
	//printf("Free SendISOTPData tx_msg message: %s\n", STATUS_OK_KO(res));
	return res;

}

i will read data through callback method, but when i try to send more than 8 bytes iam facing timeout problem.

Mapping 1: From tester (e.g., 0xA1) to ECU (e.g., 0xA2) – Used for sending initial requests.
Mapping 2: From ECU (e.g., 0xA2) to tester (e.g., 0xA1) – Used for receiving responses.

By above mapping i am able to read the bytes from ECU, but i couldn't able to send more than 8byes from Tester to ECU.

what is configuration problem

Regards,
Sandeep C
Attachments
frame1_tester_toecu.png
frame1_tester_toecu.png (100.71 KiB) Viewed 1431 times
ecutotester.png
ecutotester.png (46.43 KiB) Viewed 1431 times
time delay between two frames
time delay between two frames
forum__2.png (56.31 KiB) Viewed 1431 times
forum__1.png
forum__1.png (33.51 KiB) Viewed 1431 times

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Address mapping

Post by M.Heidemann » Thu 23. May 2024, 09:16

Hello,

Please try to A) read the documentation and B) check the examples, this is due to your mapping not handling messages larger than 8 bytes,
here an excerpt from Sample _02_client_ISO15765_2_normal_addressing

Code: Select all

            // Allocate tx message
            res = CanTpApi.MsgDataAlloc_2016(out tx_msg, cantp_msgtype.PCANTP_MSGTYPE_ISOTP);
            Console.WriteLine("Allocate tx message : {0}", STATUS_OK_KO(res));

            // Create a simple physical mapping: 
            //    - Source 0xF1 (client), target 0x01 (server), CAN id 0xA1, CAN ID flow control 0xA2
            //    - Diagnostic message in a classic format
            mapping.can_id = 0xA1;
            mapping.can_id_flow_ctrl = 0xA2;
            mapping.can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_STANDARD;
            mapping.netaddrinfo.extension_addr = 0x00;
            mapping.netaddrinfo.format = cantp_isotp_format.PCANTP_ISOTP_FORMAT_NORMAL;
            mapping.netaddrinfo.msgtype = cantp_isotp_msgtype.PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
            mapping.netaddrinfo.source_addr = 0xF1;
            mapping.netaddrinfo.target_addr = 0x01;
            mapping.netaddrinfo.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;

            // Add mapping on channel
            res = CanTpApi.AddMapping_2016(client_handle, ref mapping);
            Console.WriteLine("Add a simple mapping : {0}", STATUS_OK_KO(res));

            if (MSG_SIZE > 7)
            {
                cantp_mapping mappingSegmented = new cantp_mapping();
                // data is too big to fit in an ISO-TP "Single Frame",
                //	Communication will be segmented a mapping to receive communications from the receiver: 
                //    - Source 0x01 (server), target 0xF1 (client), CAN id 0xA2, CAN ID flow control 0xA1
                //    - Diagnostic message in a classic format
                mappingSegmented.can_id = 0xA2;
                mappingSegmented.can_id_flow_ctrl = 0xA1;
                mappingSegmented.can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_STANDARD;
                mappingSegmented.netaddrinfo.extension_addr = 0x00;
                mappingSegmented.netaddrinfo.format = cantp_isotp_format.PCANTP_ISOTP_FORMAT_NORMAL;
                mappingSegmented.netaddrinfo.msgtype = cantp_isotp_msgtype.PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
                mappingSegmented.netaddrinfo.source_addr = 0x01;
                mappingSegmented.netaddrinfo.target_addr = 0xF1;
                mappingSegmented.netaddrinfo.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;

                // Add mapping on channels
                res = CanTpApi.AddMapping_2016(client_handle, ref mappingSegmented);
                Console.WriteLine("Add a simple mapping : {0}", STATUS_OK_KO(res));
            }
Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Post Reply