CCP API Program ECU Method C#

A free API for the Communication with Control Units based on the CAN Calibration Protocol (CCP) by ASAM for Windows®

CCP API Program ECU Method C#

Postby agasystems » Tue 29. Jan 2019, 23:11

I am developing an application using the Peak CAN to USB interface for programming and ECU. I am having trouble getting the Program ECU method to work. Can you send me an example of a call to this method. Does the entire data file need to be sent to the method or does it go in as a stream?
agasystems
 
Posts: 2
Joined: Tue 29. Jan 2019, 23:07

Re: CCP API Program ECU Method C#

Postby K.Wagner » Wed 30. Jan 2019, 09:35

Hello,

the PCAN-CCP API contains one function per CCP command. If with "programming my ECU" you mean using the CCP commands PROGRAM or PROGRAM_6, then you should use the PCAN-CCP functions CCP_Programm and/or CCP_Program_6. Both of these start programming the given data into non-volatile memory, starting at current MTA0.

agasystems wrote:I am having trouble getting the Program ECU method to work.

Could you be more specific? What does it means "trouble" in this? Which function are you calling? How is the return code of calling the function?

agasystems wrote:Does the entire data file need to be sent to the method or does it go in as a stream?

As stated in the help, each CCP command is represented 1:1 as an API function. This means, limit in data size of each command is the same for the function that is representing it. For instance, the commands PROGRAM and PROGRAM_6 take a maximum of 5 and 6 data bytes respectively pro call. In other words, you need to parse the file yourself and send chunks of 5/6 bytes using the respective function (CCP_Program, or CCP_Program_6).

agasystems wrote:Can you send me an example of a call to this method.

I can give a very basic sample on how use the programm function, but note that we actually don't have any device to check this. The API is well tested and is being used by several customers for ECU flashing. The CCP knowledge come from the user, not from us. The following code is in C#
Code: Select all
TCCPResult result;
byte[] IdArray;
byte MTAext;
uint MTAaddr;

// Set the start address on memory
SetMTA0();

// Use a way to get the data bytes in chunks from your file,
// for instance GetNextFiveBytes
//
IdArray = GetNextFiveBytes();

// Use a loop to get all data from the file and send it in chunks
// using for instance the PROGRAM command
//
while(IdArray.Length > 0)
{
    // Send each chunk of 5 or less bytes
    //
    result = CCPApi.Program(m_PccpHandle, IdArray, 6, out MTAext, out MTAaddr, 0);
    if (result == TCCPResult.CCP_ERROR_ACKNOWLEDGE_OK)
        IdArray = GetNextFiveBytes();
    else
    {
        // If an error occurred, handle it
        MessageBox.Show("Error while programming: " + result.ToString());
        HandleError(result);
        return;
    }
}
MessageBox.Show("Programming data successfully sent. MTA0 is now: 0x" + MTAaddr.ToString("X"));


If you need help by using a CCP command or for any programming sequence, please refer to the ASAP CCP specification. It is free and can be found in the internet (Last Version was CCP v2.1).
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 640
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: CCP API Program ECU Method C#

Postby agasystems » Wed 30. Jan 2019, 20:47

Kenneth,

Thanks for the information. I was not parsing the data file. I will re-write the function and parse it in, then let you know the results from that including the function call i'm using.
agasystems
 
Posts: 2
Joined: Tue 29. Jan 2019, 23:07


Return to PCAN-CCP



This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy