Page 1 of 1

send several frames in succession

Posted: Wed 22. Mar 2023, 14:21
by clem69
Hello,
I want to send several times a frame with the same identifier but with different data.

I use UDS_write_2013 function.

Code: Select all

void CAN_send(uds_msgconfig configuration ,unsigned char DataLength,unsigned char * Data)
{
	   
	
	int i=0;
		memset(&tx_msg, 0, sizeof(uds_msg));  
	
   	status = UDS_MsgAlloc_2013(&tx_msg, configuration,DataLength);
            
			if (UDS_StatusIsOk_2013(status, PUDS_STATUS_OK, false))
				{
				  for(i=0;i<DataLength;i++)
				  {
					 
					 tx_msg.msg.msgdata.can->data[i]=Data[i];
					  
				  }
			
				}
				
				
				else
					MessagePopup("Message allocation failed.", "Error");
			   
				
				   
	         status = UDS_Write_2013(PCANTP_HANDLE_USBBUS1, &tx_msg);
			   wait_result = WaitForSingleObject(receive_event,5);  
              UDS_MsgFree_2013(&tx_msg); 
}

I call my function next in this part of the program

Code: Select all

int j=0;
	

		config1.can_id =  0xC4;
                config1.can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;
                config1.nai.extension_addr = 0x0;
                config1.nai.protocol = PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
                config1.nai.source_addr = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
                config1.nai.target_addr = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
                config1.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
                config1.type = PUDS_MSGTYPE_UUDT;
					
			        trame[0]=0x88;
				trame[1]=0x00; 
				trame[2]=0x00; 
				trame[3]=0x00; 
				trame[4]=0x00; 
				trame[5]=0x00; 
				trame[6]=0x00;
				trame[7]=0x00;
				
				 CAN_send(config1 ,8, trame); 
				 
				trame[0]=0x88;
				trame[1]=0x56; 
				trame[2]=0x00; 
				trame[3]=0x00; 
				trame[4]=0x00; 
				trame[5]=0x00; 
				trame[6]=0x00;
				trame[7]=0x00;
										
			  CAN_send(config1 ,8, trame);  


the problem is that only the first frame is sent.
I noticed that it happens when the first data is identical for both frames.
if I modify the first data, the two frames are sent.

Thank you

Re: send several frames in succession

Posted: Wed 22. Mar 2023, 15:15
by F.Vergnaud
Hello,

When you send a UDS request, the API expects you to assert that the message was successfully transmitted and that you tried to read a UDS response.
Trying to send another request while a communication is not fully completed results in an error status "PUDS_STATUS_SERVICE_ALREADY_PENDING" (you MUST check the returned status in your function call...).
The first byte in a UDS message holds information on the service ID, this is why you can send several frames when you change the first byte.

You should use the provided "UDS_WaitForXXX" functions when dealing with UDS communication.

But my guess is that you simply want to send a CAN frame and not a UDS message:
- If that is the case and you still use UDS elsewhere in your application, then use PCAN-ISO-TP API to send a cantp_msg with the type PCANTP_MSGTYPE_CAN.
- If you never read/write segmented messages or UDS messages, then simply switch to PCANBasic API.

Re: send several frames in succession

Posted: Wed 22. Mar 2023, 17:41
by clem69
Thank you.
I can use PCAN ISO on the same port as PCAN UDS and keep the initialization of the UDS?

Re: send several frames in succession

Posted: Thu 23. Mar 2023, 08:56
by K.Wagner
Hello,

yes. Since PCAN-UDS internally uses PCAN-ISO-TP, the channel initialized with PCAN-UDS can be used with ISO-TP, for example with CANTP_Write_2016.