No Flow Control Message

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
puser
Posts: 5
Joined: Mon 4. Apr 2016, 08:50

No Flow Control Message

Post by puser » Mon 4. Apr 2016, 09:54

Hello,

I want to send a CAN UDS Message with the following data:

CAN ID for ECU request is:0x744 data: 03 22 F1 91 55 55 55 55

CAN ID for ECU Response is 0x7AE.

With the following code, the data 03 22 F1 91 00 00 00 00 is send on the correct CAN ID(0x744)

My ECU Responds on this message.

The Problem is that my PEAK CAN USB Adapter does not send a Flow Control Message, after the first message.
So the ECU wont continue sending data.

Can you help me?

Here is my code:

Code: Select all

private void Initialize_Click(object sender, EventArgs e)
        {
            ushort Channel = UDSApi.PUDS_USBBUS1;
            TPUDSStatus result;
             TPUDSMsg response = new TPUDSMsg();
            

            byte remoteUds = 0x00;  
            byte ST_MIN = 10;
            byte N_SA = 0x05;
            byte N_TA = 0x05;
            byte N_RA = 0x00;
            uint stmin_old = 0;
            uint stmin_new = 10;
            UInt32 iBuffer = 0x01;

            // Define Address
            TPUDSStatus s3 = UDSApi.Initialize(UDSApi.PUDS_USBBUS1, TPUDSBaudrate.PUDS_BAUD_500K);

             s3 = UDSApi.SetValue(UDSApi.PUDS_USBBUS1, TPUDSParameter.PUDS_PARAM_SERVER_ADDRESS, ref iBuffer, sizeof(UInt32));
            
            TPCANTPStatus s = CanTpApi.AddMapping(Channel, 0x7AE, CanTpApi.CAN_ID_NO_MAPPING,
                                            TPCANTPIdType.PCANTP_ID_CAN_11BIT,
                                            TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
                                            TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
                                            0x01, 0x02,
                                            TPCANTPAddressingType.PCANTP_ADDRESSING_FUNCTIONAL, 0x00);

            s = CanTpApi.AddMapping(Channel, 0x7AE, 0x744,
                                           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
                                           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
                                           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
                                           0x0, 0x0,
                                           TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
                                           remoteUds);

            s = CanTpApi.AddMapping(Channel, 0x744, 0x7AE,
                                           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
                                           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
                                           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
                                           0x0, 0x0,
                                           TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, remoteUds);
           
                CanTpApi.SetValue(Channel, TPCANTPParameter.PCANTP_PARAM_SEPERATION_TIME, ref stmin_new, sizeof(uint));

            TPUDSMsg request = new TPUDSMsg();
 
            request.NETADDRINFO.SA = (byte)0x0;
            request.NETADDRINFO.TA = (byte)0x0;
            request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
            request.NETADDRINFO.RA = 0x00;
            request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;

           //send 0xF191
            // Sends a Physical ReadDataByIdentifier Request
            ushort[] buffer = { 0xF191, 0x5555, 0x5555 };

            result = UDSApi.SvcReadDataByIdentifier(UDSApi.PUDS_USBBUS1, ref request, buffer,1);
 
                   }
THANK YOU!

puser
Posts: 5
Joined: Mon 4. Apr 2016, 08:50

Re: No Flow Control Message

Post by puser » Mon 4. Apr 2016, 17:10

If I add the UDSApi.WaitForService() method after the UDSApi.SvcReadDataByIdentifier() method,
The flow control message is sent correctly, and i can see the data (consecutive frames) correctly sent by the ECU on the CAN bus.

My next Problem is:

How can i access the data contained in the response message?

I tried it via:

Code: Select all

foreach (byte b in response.DATA)
            {
                Console.Write(b.ToString("X"));
            }

But I always get Zeros(000000...) which isn't correct. Because i can see the correct data sent by the ECU on the CAN Bus with another Software tool.
I also get a messagebox saying: "error occured: 7" which means to me, that the PEAK USB Adapter didn't receive any messages.

What am I doing wrong?

Here is my code:

Code: Select all

private void Initialize_Click(object sender, EventArgs e)
        {
            ushort Channel = UDSApi.PUDS_USBBUS1;
            TPUDSStatus result;
             TPUDSMsg response = new TPUDSMsg();
            TPUDSMsg requestConfirmation = new TPUDSMsg();
 
            byte remoteUds = 0x00;  
            byte ST_MIN = 10;
            byte N_SA = 0x05;
            byte N_TA = 0x05;
            byte N_RA = 0x00;
            uint stmin_old = 0;
            uint stmin_new = 10;
            UInt32 iBuffer = 0x01;

            // Define Address
            TPUDSStatus s3 = UDSApi.Initialize(UDSApi.PUDS_USBBUS1, TPUDSBaudrate.PUDS_BAUD_500K);

             s3 = UDSApi.SetValue(UDSApi.PUDS_USBBUS1, TPUDSParameter.PUDS_PARAM_SERVER_ADDRESS, ref iBuffer, sizeof(UInt32));
            
            TPCANTPStatus s = CanTpApi.AddMapping(Channel, 0x7AE, CanTpApi.CAN_ID_NO_MAPPING,
                                            TPCANTPIdType.PCANTP_ID_CAN_11BIT,
                                            TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
                                            TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
                                            0x01, 0x02,
                                            TPCANTPAddressingType.PCANTP_ADDRESSING_FUNCTIONAL, 0x00);

            s = CanTpApi.AddMapping(Channel, 0x7AE, 0x744,
                                           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
                                           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
                                           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
                                           0x0, 0x0,
                                           TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
                                           remoteUds);

            s = CanTpApi.AddMapping(Channel, 0x744, 0x7AE,
                                           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
                                           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
                                           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
                                           0x0, 0x0,
                                           TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, remoteUds);
           
                CanTpApi.SetValue(Channel, TPCANTPParameter.PCANTP_PARAM_SEPERATION_TIME, ref stmin_new, sizeof(uint));

            TPUDSMsg request = new TPUDSMsg();

            request.NETADDRINFO.SA = (byte)0x0;
            request.NETADDRINFO.TA = (byte)0x0;
            request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
            request.NETADDRINFO.RA = 0x00;
            request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;

           //send 0xF191
            // Sends a Physical ReadDataByIdentifier Request
            ushort[] buffer = { 0xF191, 0x5555, 0x5555 };

            result = UDSApi.SvcReadDataByIdentifier(UDSApi.PUDS_USBBUS1, ref request, buffer,1);

             if (result == TPUDSStatus.PUDS_ERROR_OK)
                          result = UDSApi.WaitForService(UDSApi.PUDS_USBBUS1, out response, ref request,out requestConfirmation);
                if (result == TPUDSStatus.PUDS_ERROR_OK)
                        MessageBox.Show(String.Format("Response was received."));
                else
                // An error occurred
                     MessageBox.Show(String.Format("Error occured: {0}", (int)result));
}


Thank you!

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

Re: No Flow Control Message

Post by F.Vergnaud » Tue 5. Apr 2016, 10:51

Hello puser,

I see you are using some specific (i.e non standard) mappings to communicate with your ECU. Although you are able to see the flow control and consecutive frames those mappings are not totally right : there are some misconfigurations in the source and target adresses.

What's happening is that the UDS/ISO-TP APIs are receiving the CAN frames, but when the communication is complete it checks that the network addressing information of the message matches the "server" address. Since your mappings use 0x0 addresses for Source and Target addresses (which is wrong) and you defined the server address as 0x01, the addresses do not match.. so the message is discarded.

I will assume the following statements:
- the UDS address of your application is 0x01 (defined with the parameter PUDS_PARAM_SERVER_ADDRESS)
- the address of the ECU is 0x02
- the address for functional addressing is not known, I'll use 0x33

Then the mappings should be :

Code: Select all

// Define the functional mapping to send a request to all ECUs (functional requests)
TPCANTPStatus s = CanTpApi.AddMapping(Channel, 0x7AE, CanTpApi.CAN_ID_NO_MAPPING,
           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
           0x01, 0x033,
           TPCANTPAddressingType.PCANTP_ADDRESSING_FUNCTIONAL, 0x00);

// Define ISO-TP communication from ECU to Client (physical responses)
s = CanTpApi.AddMapping(Channel, 0x7AE, 0x744,
           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
           0x02, 0x01,
           TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
           0x00);

// Define ISO-TP communication from Client to ECU (physical requests)
s = CanTpApi.AddMapping(Channel, 0x744, 0x7AE,
           TPCANTPIdType.PCANTP_ID_CAN_11BIT,
           TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
           TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
           0x01, 0x02,
           TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);
Best regards,
Fabrice

puser
Posts: 5
Joined: Mon 4. Apr 2016, 08:50

Re: No Flow Control Message

Post by puser » Wed 6. Apr 2016, 08:28

Hello Fabrice,

thank you for your reply!
The communication to the ECU is working now. I am able to read e.g. the ECUs Hardware/Software number.

In the next step I want to read/clear error codes of the ECU. For this task I tried the "UDSApi.SvcReadDTCInformation()" method.

Code: Select all

result = UDSApi.SvcReadDTCInformation(UDSApi.PUDS_USBBUS1, ref request, UDSApi.TPUDSSvcParamRDTCI.PUDS_SVC_PARAM_RDTCI_RDTCBSM, 0x09);
            
            
            if (result == TPUDSStatus.PUDS_ERROR_OK)
                result = UDSApi.WaitForService(UDSApi.PUDS_USBBUS1, out response, ref request, out requestConfirmation);
            if (result == TPUDSStatus.PUDS_ERROR_OK)
                MessageBox.Show(String.Format("Response was received."));
            else
                // An error occurred
                MessageBox.Show(String.Format("Error occured: {0}", (int)result));

            Console.WriteLine(result);
On the bus I can see the following data for the Request(Single Frame):
ID: 0x744 DATA: 03 19 02 09 00 00 00 00

With the data above, the ECU does not respond.

To get a Response from the ECU, the DATA should look like this:

ID: 0x744 DATA: 03 19 02 09 55 55 55 55

Is it possible to achieve this?

For the UDSApi.SvcReadDataByIdentifier() method I got it working by adding 0x5555 0x5555 manually to the buffer.(see code below):

Code: Select all

ushort[] buffer = { (ushort)UDSApi.TPUDSSvcParamDI.PUDS_SVC_PARAM_DI_VMECUHNDID, 0x5555, 0x5555 };
                         
result = UDSApi.SvcReadDataByIdentifier(UDSApi.PUDS_USBBUS1, ref request, buffer,1);

             if (result == TPUDSStatus.PUDS_ERROR_OK)
                result = UDSApi.WaitForService(UDSApi.PUDS_USBBUS1, out response, ref request,out requestConfirmation);
             if (result == TPUDSStatus.PUDS_ERROR_OK)
                  MessageBox.Show(String.Format("Response was received."));
             else
                 // An error occurred
                 MessageBox.Show(String.Format("Error occured: {0}", (int)result));
Thanks in advance!

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

Re: No Flow Control Message

Post by F.Vergnaud » Wed 6. Apr 2016, 09:46

Hello puser,

Indeed some ECUs wants a specific value when using CAN data padding (not the default 0x00). Use the parameter "PUDS_PARAM_PADDING_VALUE" to set that custom value.

Code: Select all

iBuffer = 0x55
s3 = UDSApi.SetValue(UDSApi.PUDS_USBBUS1, TPUDSParameter.PUDS_PARAM_PADDING_VALUE, ref iBuffer, sizeof(byte));
Best regards,
Fabrice

puser
Posts: 5
Joined: Mon 4. Apr 2016, 08:50

Re: No Flow Control Message

Post by puser » Wed 6. Apr 2016, 10:24

Hello Fabrice,

thank you for your quick answer.

I can't find the Parameter "TPUDSParameter.PUDS_PARAM_PADDING_VALUE" in the PCAN-UDS Api Manual or in your *.cs - file:
PcanUDS.PNG
PcanUDS.PNG (18.53 KiB) Viewed 13847 times
With your example code I get an error from the Compiler:
error 12 'Peak.Can.Uds.TPUDSParameter' contains no Definition for 'PUDS_PARAM_PADDING_VALUE'.

Where is the Parameter accessible?

Thank you!

Best Regards,
puser

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

Re: No Flow Control Message

Post by F.Vergnaud » Wed 6. Apr 2016, 10:42

Indeed, I've checked the currently released version of PCAN-UDS and PCAN-ISO-TP APIs (respectively 1.2.0.7 and 1.4.1.16). But the features I have told you are respectively available in versions 1.2.0.8 and 1.4.2.1.

Sorry for the inconvenience, I will let you know when those new versions are released on our website.
Best regards,
Fabrice

puser
Posts: 5
Joined: Mon 4. Apr 2016, 08:50

Re: No Flow Control Message

Post by puser » Wed 6. Apr 2016, 13:06

Hello Fabrice,

thank you for that Information.

Can you estimate, when the new Version of the UDS-API will be released(weeks, months,...)?

Best Regards,
puser

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

Re: No Flow Control Message

Post by F.Vergnaud » Wed 6. Apr 2016, 15:50

The latest versions may be available shortly (in a few weeks), I will have more information next week.
Best regards,
Fabrice

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

Re: No Flow Control Message

Post by F.Vergnaud » Mon 25. Apr 2016, 10:32

Hello puser,

The automotive APIs have been updated,and will be updated in short on our website. The new versions are:
- PCAN-ISO-TP v1.4.2.28
- PCAN-UDS v1.2.1.17

You will find a new parameter "PUDS_PARAM_PADDING_VALUE" in enumeration TPUDSParameter that allows you to define the padding value of segmented CAN frames.
Best regards,
Fabrice

Post Reply