CCP API Program ECU Method C#
-
- Posts: 2
- Joined: Tue 29. Jan 2019, 23:07
CCP API Program ECU Method C#
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?
Re: CCP API Program ECU Method C#
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.
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).
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.
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:I am having trouble getting the Program ECU method to work.
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:Does the entire data file need to be sent to the method or does it go in as a stream?
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#agasystems wrote:Can you send me an example of a call to this method.
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"));
Best regards,
Keneth
Keneth
-
- Posts: 2
- Joined: Tue 29. Jan 2019, 23:07
Re: CCP API Program ECU Method C#
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.
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.