Looking for help with PCAN_UDS functional response handleing

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
tlamb
Posts: 2
Joined: Fri 17. Jun 2016, 19:18

Looking for help with PCAN_UDS functional response handleing

Post by tlamb » Thu 23. Jun 2016, 17:11

To start, I am new to working with PCAN-UDS API, and I am working with a project I did not create. So, I still have much to learn.

I have a C++ VS2010 application I am using to communicate with an embedded device over CAN using PCAN-UDS API. I send a functional message with service $28 with this project, and I expect a delayed response from my embedded device of $68. While waiting for my embedded device to respond, other devices on the bus will respond because the request is functional. The problem occurs, when my application accepts other responses before my ECU responds. I suspect my PCAN-UDS application must acknowledge all the responses because the request is functional. I would find this acceptable and could work around it but I do not see how to get each message ID and test for them. I want to act upon the response only from my ECU which is ID = 0x7EB. The other responses are 0x7E8, 0x7E9, and 0x7ED.
I have tried PUDS_SERVER_FILTER_IGNORE for one response message ID and it does not work for me.
I may be missing what I need in the NETADDRINFO type, but its not clear to me yet.

I have a simplified view of the code below.

Code: Select all

  TPUDSMsg Msg = {};
  TPUDSMsg Resp = {};
 
  Msg.MSGTYPE = PUDS_MESSAGE_TYPE_REQUEST;
  Msg.NETADDRINFO.SA = (byte)PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
  Msg.NETADDRINFO.TA = (byte)PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
  Msg.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
  Msg.NETADDRINFO.RA = 0x00;
  Msg.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;

Status = UDS_SvcCommunicationControl(pcanChan, &Msg, 0x03, 0x01);
if (Status == PUDS_ERROR_OK) 
{
//10 second timeout and wait for ACK/NACK
 Status = UDS_WaitForSingleMessage(pcanChan, &Resp, &Msg, false, 1, 10000); 
}
Any help is appreciated.
Terry

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Looking for help with PCAN_UDS functional response handl

Post by K.Wagner » Fri 24. Jun 2016, 11:42

Hello,

since you are using a functional request that, as you described, ends with several responses, then you need to use UDS_WaitForServiceFunctional. This function waits first for a transmit confirmation, and then for responses. Here is an example:

Code: Select all

TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
WORD MessageArraySize = 5;
TPUDSMsg MessageArray[5];
DWORD count;

// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(MessageArray, 0, sizeof(TPUDSMsg) * MessageArraySize);
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;

// Sends the Service Communication Control rqeuest message
result = UDS_SvcCommunicationControl(PUDS_USBBUS1, &request, PUDS_SVC_PARAM_CC_ERXTX, PUDS_SVC_PARAM_CC_FLAG_APPL | PUDS_SVC_PARAM_CC_FLAG_NWM | PUDS_SVC_PARAM_CC_FLAG_DENWRIRO);

if (result == PUDS_ERROR_OK)
    result = UDS_WaitForServiceFunctional(PUDS_USBBUS1, MessageArray, MessageArraySize, &count, true, &request, &requestConfirmation);

if (result == PUDS_ERROR_OK)
{
    if (count > 0)
        MessageBox(NULL, "Responses were received", "Success", MB_OK);
    else
        MessageBox(NULL, "No response was received", "Error", MB_OK);
}
else
    // An error occurred
    MessageBox(NULL, "An error occured", "Error", MB_OK);
Best regards,
Keneth

tlamb
Posts: 2
Joined: Fri 17. Jun 2016, 19:18

Re: Looking for help with PCAN_UDS functional response handl

Post by tlamb » Fri 24. Jun 2016, 15:10

Kenneth,
Thank you, I will give it a try. It was not intuitive to me because the response is physical. I see how this will work because of the request message is passed in as one of the arguments to the wait routines.
Terry

Post Reply