How to send 11 and 29 bit identifier

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
Cappo
Posts: 14
Joined: Wed 19. Dec 2018, 14:19

How to send 11 and 29 bit identifier

Post by Cappo » Wed 7. Aug 2019, 12:18

Hello,

with UDSApi.Write how can I send an uudt 11 or 29 bit message id?
ie 0x100 in 11 bit format id and 0x100 in 29 bit format

Best Regards
cappo

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

Re: How to send 11 and 29 bit identifier

Post by F.Vergnaud » Wed 7. Aug 2019, 12:25

Dear cappo,

You will find a complete UUDT example in the documentation of the PCAN - UDS API :
- §4.3.3 "UUDT Read / Write example" p.343.

Code: Select all

void sample_rw_uudt(TPUDSCANHandle channelTx, TPUDSCANHandle channelRx) {
	TPUDSStatus status;
	int iBuffer;
	TPUDSMsg Message;
	int count;
	// Initializes UDS Communication for the transmitting channel
	status = UDS_Initialize(channelTx, PUDS_BAUD_500K, 0, 0, 0);
	printf("Initialize UDS: %i\n", (int)status);
	// Initializes UDS Communication for the receiving channel
	status = UDS_Initialize(channelRx, PUDS_BAUD_500K, 0, 0, 0);
	printf("Initialize ChannelRx: %i\n", (int)status);
	// Define "channelTx" Address as ECU #9
	iBuffer = 0xF9;
	status = UDS_SetValue(channelTx, PUDS_PARAM_SERVER_ADDRESS, &iBuffer, 1);
	printf("  Set ServerAddress: %i (0x%02x)\n", (int)status, iBuffer);
	// Define "channelRx" Address as External equipement
	iBuffer = 0xF1;
	status = UDS_SetValue(channelRx, PUDS_PARAM_SERVER_ADDRESS, &iBuffer, 1);
	printf("  Set ServerAddress: %i (0x%02x)\n", (int)status, iBuffer);

	// Prepare mapping configuration: 
  //  UUDT physical response from ECU_#9 to External_Equipment : ID=0x526
	Message.NETADDRINFO.SA = 0xF9;
	Message.NETADDRINFO.TA = 0xF1;
	Message.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
	Message.NETADDRINFO.RA = 0x00;
	Message.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_NONE;
	Message.LEN = 4;
	// data[0..3] holds CAN ID
	Message.DATA.RAW[0] = 0x00;
	Message.DATA.RAW[1] = 0x00;
	Message.DATA.RAW[2] = 0x05;
	Message.DATA.RAW[3] = 0x26;

	// Add "channelTx" mapping (in order to send message)
  //  for UUDT physical response from ECU_#9 to External_Equipment : ID=0x526
	status = UDS_SetValue(channelTx, PUDS_PARAM_MAPPING_ADD, &Message, sizeof(Message));
	printf("  Add UUDT mapping: 0x%04x\n", status);
	// Add "channelRx" mapping (in order to receive message)
  //  for UUDT physical response from ECU_#9 to External_Equipment : ID=0x526
	status = UDS_SetValue(channelRx, PUDS_PARAM_MAPPING_ADD, &Message, sizeof(Message));
	printf("  Add ChannelRx UUDT mapping: 0x%04x\n", status);

	// Write a message from "channelTx" to "channelRx"
	Message.LEN = 6;
	Message.DATA.RAW[4] = 0xCA;
	Message.DATA.RAW[5] = 0xB1;
	status = UDS_Write(channelTx, &Message);
	printf("  UDS_Write UUDT: 0x%04x\n", status);
	// Read message on channel Rx
	printf("  Reading message on ChannelRx...\n");
	memset(&Message, 0, sizeof(Message));
	count = 0;
	do {
		count++;
		Sleep(100);
		status = UDS_Read(channelRx, &Message);
	} while (status == PUDS_ERROR_NO_MESSAGE && count < 10);
	if (status == PUDS_ERROR_NO_MESSAGE)
		printf("Failed to read message on Channel RX !");
	else {
		// Received message will hold Network Address Information
		//  as defined by the mapping.
		// The CAN ID information is removed from the DATA.RAW field.
		displayMessage(NULL, &Message);
	}
	UDS_Uninitialize(channelTx);
}
Best regards,
Fabrice

Cappo
Posts: 14
Joined: Wed 19. Dec 2018, 14:19

Re: How to send 11 and 29 bit identifier

Post by Cappo » Wed 7. Aug 2019, 12:34

Hello,

I wrote here after I read that example...
So take the example code

Code: Select all

   Message.NETADDRINFO.SA = 0xF9;
   Message.NETADDRINFO.TA = 0xF1;
   Message.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
   Message.NETADDRINFO.RA = 0x00;
   Message.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_NONE;
   Message.LEN = 4;
   // data[0..3] holds CAN ID
   Message.DATA.RAW[0] = 0x00;
   Message.DATA.RAW[1] = 0x00;
   Message.DATA.RAW[2] = 0x05;
   Message.DATA.RAW[3] = 0x26;

   // Add "channelTx" mapping (in order to send message)
  //  for UUDT physical response from ECU_#9 to External_Equipment : ID=0x526
   status = UDS_SetValue(channelTx, PUDS_PARAM_MAPPING_ADD, &Message, sizeof(Message));
0x256 can be an 11 or 29 bit identifier..... and how can I set this parameter?
To be claer the same thing that in isotp write is PCANTP_ID_CAN_29BIT or PCANTP_ID_CAN_11BIT.

Thanks
cappo

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

Re: How to send 11 and 29 bit identifier

Post by F.Vergnaud » Wed 7. Aug 2019, 14:51

You are right. Currently the PCAN-UDS UUDT mechanism does not handle 29 bit flag.
Nevertheless you can write your UUDT message with PCAN-ISO-TP API using the CAN handle initialized by PCAN-UDS as such:

Code: Select all

void sample_rw_uudt_29b(TPUDSCANHandle channelTx, TPUDSCANHandle channelRx) {
	...
	// Write a 11 bit message from "channelTx" to "channelRx" with PCAN-UDS
	//Message.LEN = 6;
	//Message.DATA.RAW[4] = 0xCA;
	//Message.DATA.RAW[5] = 0xB1;
	//status = UDS_Write(channelTx, &Message);

	// Write a 29 bit message from "channelTx" to "channelRx" with PCAN-ISO-TP
	TPCANTPMsg tpmsg = {};
	tpmsg.FORMAT = PCANTP_FORMAT_NONE;
	tpmsg.MSGTYPE = PCANTP_MESSAGE_UNKNOWN;
	tpmsg.IDTYPE = PCANTP_ID_CAN_29BIT;
	tpmsg.TA_TYPE = PCANTP_ADDRESSING_UNKNOWN;
	tpmsg.LEN = 6;
	tpmsg.DATA[0] = 0x00;
	tpmsg.DATA[1] = 0x00;
	tpmsg.DATA[2] = 0x05;
	tpmsg.DATA[3] = 0x26;
	tpmsg.DATA[4] = 0xCA;
	tpmsg.DATA[5] = 0xB1;
	status = CANTP_Write(channelTx, &tpmsg);
	printf("  UDS_Write UUDT: 0x%04x\n", status);
	...
The UDS_Read function will return a UDS message with CAN ID 0x526 in the DATA field, but you will not be able to tell if it is a 11bit or 29 bit CAN ID.
Best regards,
Fabrice

Cappo
Posts: 14
Joined: Wed 19. Dec 2018, 14:19

Re: How to send 11 and 29 bit identifier

Post by Cappo » Wed 7. Aug 2019, 14:55

Okay, thanks! :D

Best Regards
cappo

Post Reply