Page 1 of 1

How to simulate ECU

Posted: Thu 27. Feb 2020, 16:50
by Fredouille
I am already using CCP API to communicate successfully with ECU.

Now, I want to use CCP API to create an application to simulate ECU side, to perform tests using a PCAN-USB Pro.
But I haven't found anything to respond to Connect API.

Please, do you have any examples to illustrate the way to follow ?

Thanking you in advance.

Re: How to simulate ECU

Posted: Fri 28. Feb 2020, 08:44
by K.Wagner

to create your ECU simulator (CCP slave) you just need to understand the protocol, which is actually very straightforward. Principally you should:
  1. Create an application that connects to the same CAN bus as your CCP master app, using the same bitrate.
  2. Define in your application the CAN Ids to be used for CRO and DTO messages.
  3. Define an "ECU Address" that identifies your App as ECU.
  4. Write a function that reads the CAN bus periodically for new messages.
  5. Write a function that, taking into account the CCP protocol, interprets the received CAN messages (CROs), so that you know which command is being required.
  6. Write a function to handle each CCP command.
  7. Be sure that each of those functions sends a response back (DTO).
For instance, the command CONNECT is intended to establish a logical point-to-point connection to the ECU. For this, it contains the address of the ECU to connect. You has to compare if this is the address of your App and accept the connection by sending a positive DTO:

This is an example on how a function that handle the CONNECT command could be:

Code: Select all

void HandleCommandConnect(TPCANMsg canMsg)
	if (MySlave.Connect(RetrieveAddressFromCANMessage(canMsg.DATA)))
		TPCANMsg resultMsg;

		resultMsg = FillMessageAsCro(ACKNOWLEDGE);
        	PCANBasic.Write(MySlave.Channel, ref resultMsg);
NOTE: we actually don't give help on the protocol itself but only for our API. If you need more help on this, please refer to the offcial CCP documentation from ASAM. You will find there examples for CROs and DTOs for each command, so you can easily implement the ECU.

I hope this helps you with your project.

Re: How to simulate ECU

Posted: Fri 20. Mar 2020, 16:17
by K.Wagner
- Closed -