Skip to content

Commit

Permalink
Corrected flash change mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasclaesson committed Jan 16, 2016
1 parent fe4cf71 commit 9d5c617
Showing 1 changed file with 63 additions and 5 deletions.
68 changes: 63 additions & 5 deletions TrionicCANFlasher/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ private void AddLogItem(string item)
private void btnFlashEcu_Click(object sender, EventArgs e)
{
DialogResult result = DialogResult.Cancel;
if(cbxEcuType.SelectedIndex == (int)ECU.TRIONIC8)
result = MessageBox.Show("Power on ECU",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
if (cbxEcuType.SelectedIndex == (int)ECU.TRIONIC8 || cbxEcuType.SelectedIndex == (int)ECU.MOTRONIC96)
result = MessageBox.Show("Attach a charger. Now turn key to ON to wakeup ECU.",
"Critical Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
else if (cbxEcuType.SelectedIndex == (int)ECU.TRIONIC7)
{
result = MessageBox.Show("Attach a charger. Turn key to ON wait a few seconds, turn to LOCK. Wait 15 to 20 seconds then initiate the flash operation in car.",
"Critical Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
}
if (result == DialogResult.Cancel)
{
return;
Expand All @@ -100,7 +105,30 @@ private void btnFlashEcu_Click(object sender, EventArgs e)
{
if (checkFileSize(ofd.FileName))
{
if (cbxEcuType.SelectedIndex == (int)ECU.TRIONIC8)
if (cbxEcuType.SelectedIndex == (int)ECU.TRIONIC7)
{
SetGenericOptions(trionic7);
trionic7.UseFlasherOnDevice = cbUseFlasherOnDevice.Checked;

AddLogItem("Opening connection");
EnableUserInput(false);
if (trionic7.openDevice())
{
Thread.Sleep(1000);
AddLogItem("Update FLASH content");
Application.DoEvents();
dtstart = DateTime.Now;
trionic7.WriteFlash(ofd.FileName);
}
else
{
AddLogItem("Unable to connect to Trionic 7 ECU");
trionic7.Cleanup();
EnableUserInput(true);
AddLogItem("Connection terminated");
}
}
else if (cbxEcuType.SelectedIndex == (int)ECU.TRIONIC8)
{
ChecksumResult checksum = ChecksumT8.VerifyChecksum(ofd.FileName);
if (checksum != ChecksumResult.Ok)
Expand All @@ -122,7 +150,37 @@ private void btnFlashEcu_Click(object sender, EventArgs e)
Application.DoEvents();
BackgroundWorker bgWorker;
bgWorker = new BackgroundWorker();
bgWorker.DoWork += new DoWorkEventHandler(trionic8.RestoreT8);
bgWorker.DoWork += new DoWorkEventHandler(trionic8.WriteFlash);
bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorker_RunWorkerCompleted);
bgWorker.WorkerReportsProgress = true;
bgWorker.ProgressChanged += new ProgressChangedEventHandler(bgWorker_ProgressChanged);
bgWorker.RunWorkerAsync(ofd.FileName);
}
else
{
AddLogItem("Unable to connect to Trionic 8 ECU");
trionic8.Cleanup();
EnableUserInput(true);
AddLogItem("Connection terminated");
}
}
else if (cbxEcuType.SelectedIndex == (int)ECU.MOTRONIC96)
{
SetGenericOptions(trionic8);

EnableUserInput(false);
AddLogItem("Opening connection");
trionic8.SecurityLevel = AccessLevel.AccessLevel01;
trionic8.ECU = ECU.MOTRONIC96;
if (trionic8.openDevice(false))
{
Thread.Sleep(1000);
dtstart = DateTime.Now;
AddLogItem("Update FLASH content");
Application.DoEvents();
BackgroundWorker bgWorker;
bgWorker = new BackgroundWorker();
bgWorker.DoWork += new DoWorkEventHandler(trionic8.WriteFlashME96);
bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorker_RunWorkerCompleted);
bgWorker.WorkerReportsProgress = true;
bgWorker.ProgressChanged += new ProgressChangedEventHandler(bgWorker_ProgressChanged);
Expand Down

0 comments on commit 9d5c617

Please sign in to comment.