public override SymbolCollection parseFile(string filename, out List <CodeBlock> newCodeBlocks, out List <AxisHelper> newAxisHelpers) { newCodeBlocks = new List <CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List <AxisHelper>(); byte[] allBytes = File.ReadAllBytes(filename); string boschnumber = ExtractBoschPartnumber(allBytes); string softwareNumber = ExtractSoftwareNumber(allBytes); partNumberConverter pnc = new partNumberConverter(); VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks); for (int t = 0; t < allBytes.Length - 1; t += 2) { int len2skip = 0; if (CheckMap(t, allBytes, newSymbols, newCodeBlocks, out len2skip)) { if (len2skip > 2) { len2skip -= 2; // make sure we don't miss maps } if ((len2skip % 2) > 0) { len2skip -= 1; } if (len2skip < 0) { len2skip = 0; } // t += len2skip; // Console.WriteLine("map detected: " + t.ToString("X8")); } } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); BuildAxisIDList(newSymbols, newAxisHelpers); MatchAxis(newSymbols, newAxisHelpers); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } // check for must have maps... if there are maps missing, report it return(newSymbols); }
public override SymbolCollection parseFile(string filename, out List <CodeBlock> newCodeBlocks, out List <AxisHelper> newAxisHelpers) { newCodeBlocks = new List <CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List <AxisHelper>(); // Bosch EDC17 style mapdetection LL LL AXIS AXIS MAPDATA byte[] allBytes = File.ReadAllBytes(filename); // EDC17 = ReverseEndian allBytes = Tools.Instance.reverseEndian(allBytes); for (int i = 0; i < allBytes.Length - 32; i += 2) { int len2Skip = CheckMap(i, allBytes, newSymbols, newCodeBlocks); if ((len2Skip % 2) > 0) { if (len2Skip > 2) { len2Skip--; } else { len2Skip++; } } //i += len2Skip; //i += len2Skip - 2; // For now we don't skip since we can have false alarm and thereby jumping over the start of the "real" map. } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } return(newSymbols); }
public override SymbolCollection parseFile(string filename, out List <CodeBlock> newCodeBlocks, out List <AxisHelper> newAxisHelpers) { newCodeBlocks = new List <CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List <AxisHelper>(); // Bosch EDC16 style mapdetection LL LL AXIS AXIS MAPDATA byte[] allBytes = File.ReadAllBytes(filename); for (int i = 0; i < allBytes.Length - 32; i += 2) { int len2Skip = CheckMap(i, allBytes, newSymbols, newCodeBlocks); if ((len2Skip % 2) > 0) { if (len2Skip > 2) { len2Skip--; } else { len2Skip++; } } i += len2Skip; } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } return(newSymbols); }
public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers) { newCodeBlocks = new List<CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List<AxisHelper>(); byte[] allBytes = File.ReadAllBytes(filename); string boschnumber = ExtractBoschPartnumber(allBytes); string softwareNumber = ExtractSoftwareNumber(allBytes); string additionalInfo = ExtractInfo(allBytes); string partnumber = ExtractPartnumber(allBytes); partNumberConverter pnc = new partNumberConverter(); ECUInfo info = pnc.ConvertPartnumber(boschnumber, allBytes.Length); // check if V6 2.5 TDI/R4 1.9 TDI/R3 1.4 TDi int nrCylinders = pnc.GetNumberOfCylinders(info.EngineType, additionalInfo); // we can detect maps depending on ECUType/EngineType/nrCylinders/Filesize etc VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks); for (int t = 0; t < allBytes.Length - 1; t += 2) { int len2skip = 0; if (CheckMap(t, allBytes, newSymbols, newCodeBlocks, out len2skip)) { if (len2skip > 2) len2skip -= 2; // make sure we don't miss maps if ((len2skip % 2) > 0) len2skip -= 1; if (len2skip < 0) len2skip = 0; // t += len2skip; // Console.WriteLine("map detected: " + t.ToString("X8")); } } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); BuildAxisIDList(newSymbols, newAxisHelpers); MatchAxis(newSymbols, newAxisHelpers); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } // check for must have maps... if there are maps missing, report it return newSymbols; }
public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers) { newCodeBlocks = new List<CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List<AxisHelper>(); byte[] allBytes = File.ReadAllBytes(filename); string boschnumber = ExtractBoschPartnumber(allBytes); string softwareNumber = ExtractSoftwareNumber(allBytes); partNumberConverter pnc = new partNumberConverter(); VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks); for (int t = 0; t < allBytes.Length - 1; t+=2) { int len2skip = 0; if (CheckMap(t, allBytes, newSymbols, newCodeBlocks, out len2skip)) { if (len2skip > 2) len2skip -= 2; // make sure we don't miss maps if ((len2skip % 2) > 0) len2skip -= 1; if (len2skip < 0) len2skip = 0; t += len2skip; } } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); BuildAxisIDList(newSymbols, newAxisHelpers); MatchAxis(newSymbols, newAxisHelpers); RemoveNonSymbols(newSymbols, newCodeBlocks); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } // check for must have maps... if there are maps missing, report it return newSymbols; }
public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers) { newCodeBlocks = new List<CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List<AxisHelper>(); byte[] allBytes = File.ReadAllBytes(filename); string boschnumber = ExtractBoschPartnumber(allBytes); string softwareNumber = ExtractSoftwareNumber(allBytes); partNumberConverter pnc = new partNumberConverter(); VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks); for (int t = 0; t < allBytes.Length - 1; t++) { CheckMap(t, allBytes, newSymbols, newCodeBlocks); } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); FindMAPMAFSwitch(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } // check for must have maps... if there are maps missing, report it return newSymbols; }
public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers) { newCodeBlocks = new List<CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List<AxisHelper>(); // Bosch EDC17 style mapdetection LL LL AXIS AXIS MAPDATA byte[] allBytes = File.ReadAllBytes(filename); // EDC17 = ReverseEndian allBytes = Tools.Instance.reverseEndian(allBytes); for (int i = 0; i < allBytes.Length - 32; i += 2) { int len2Skip = CheckMap(i, allBytes, newSymbols, newCodeBlocks); if ((len2Skip % 2) > 0) { if (len2Skip > 2) len2Skip--; else len2Skip++; } //i += len2Skip; //i += len2Skip - 2; // For now we don't skip since we can have false alarm and thereby jumping over the start of the "real" map. } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } return newSymbols; }
private void simpleButton3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Binary files|*.bin"; if (ofd.ShowDialog() == DialogResult.OK) { m_current_comparefilename = ofd.FileName; SymbolTranslator translator = new SymbolTranslator(); string help = string.Empty; FileInfo fi = new FileInfo(m_current_comparefilename); fi.IsReadOnly = false; try { m_current_softwareversion = ""; } catch (Exception E2) { Console.WriteLine(E2.Message); } // show the dynograph xtraTabControl1.SelectedTabPage = xtraTabPage2; LoadGraphWithDetails(); // initial values from original bin } }
public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers) { newCodeBlocks = new List<CodeBlock>(); SymbolCollection newSymbols = new SymbolCollection(); newAxisHelpers = new List<AxisHelper>(); // Bosch EDC16 style mapdetection LL LL AXIS AXIS MAPDATA byte[] allBytes = File.ReadAllBytes(filename); for (int i = 0; i < allBytes.Length - 32; i+=2) { int len2Skip = CheckMap(i, allBytes, newSymbols, newCodeBlocks); if ((len2Skip % 2) > 0) { if (len2Skip > 2) len2Skip--; else len2Skip++; } i += len2Skip; } newSymbols.SortColumn = "Flash_start_address"; newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending; newSymbols.Sort(); NameKnownMaps(allBytes, newSymbols, newCodeBlocks); FindSVBL(allBytes, filename, newSymbols, newCodeBlocks); SymbolTranslator strans = new SymbolTranslator(); foreach (SymbolHelper sh in newSymbols) { sh.Description = strans.TranslateSymbolToHelpText(sh.Varname); } return newSymbols; }
private void TryToLoadAdditionalCSVSymbols(string filename, SymbolCollection coll2load) { // convert to CSV file format // ADDRESS;NAME;;; try { SymbolTranslator st = new SymbolTranslator(); char[] sep = new char[1]; sep.SetValue(';', 0); string[] fileContent = File.ReadAllLines(filename); foreach (string line in fileContent) { string[] values = line.Split(sep); try { string varname = (string)values.GetValue(1); int flashaddress = Convert.ToInt32(values.GetValue(0)); foreach (SymbolHelper sh in coll2load) { if (sh.Flash_start_address == flashaddress) { sh.Userdescription = varname; } } } catch (Exception lineE) { Console.WriteLine("Failed to import a symbol from CSV file " + line + ": " + lineE.Message); } } } catch (Exception E) { Console.WriteLine("Failed to import additional CSV symbols: " + E.Message); } }
private void TryToLoadAdditionalAS2Symbols(string filename, SymbolCollection coll2load) { // convert to AS2 file format try { SymbolTranslator st = new SymbolTranslator(); char[] sep = new char[1]; sep.SetValue(';', 0); string[] fileContent = File.ReadAllLines(filename); int symbolnumber = 0; foreach (string line in fileContent) { if (line.StartsWith("*")) { symbolnumber++; string[] values = line.Split(sep); try { string varname = (string)values.GetValue(0); varname = varname.Substring(1); int idxSymTab = 0; foreach (SymbolHelper sh in coll2load) { if (sh.Length > 0) idxSymTab++; if (idxSymTab == symbolnumber) { sh.Userdescription = varname; break; } } } catch (Exception lineE) { Console.WriteLine("Failed to import a symbol from AS2 file " + line + ": " + lineE.Message); } } } } catch (Exception E) { Console.WriteLine("Failed to import additional AS2 symbols: " + E.Message); } }
private bool ImportXMLFile(string filename, SymbolCollection coll2load, bool ImportFromRepository) { bool retval = false; SymbolTranslator st = new SymbolTranslator(); System.Data.DataTable dt = new System.Data.DataTable(Path.GetFileNameWithoutExtension(filename)); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); if (ImportFromRepository) { byte[] allBytes = File.ReadAllBytes(filename); string boschpartNumber = Tools.Instance.ExtractBoschPartnumber(allBytes); partNumberConverter pnc = new partNumberConverter(); ECUInfo info = pnc.ConvertPartnumber(boschpartNumber, allBytes.Length); string checkstring = boschpartNumber + "_" + info.SoftwareID; string xmlfilename = Tools.Instance.GetWorkingDirectory() + "\\repository\\" + Path.GetFileNameWithoutExtension(filename) + File.GetCreationTime(filename).ToString("yyyyMMddHHmmss") + checkstring + ".xml"; if (!Directory.Exists(Tools.Instance.GetWorkingDirectory() + "\\repository")) { Directory.CreateDirectory(Tools.Instance.GetWorkingDirectory() + "\\repository"); } if (File.Exists(xmlfilename)) { dt.ReadXml(xmlfilename); retval = true; } } else { string binname = GetFileDescriptionFromFile(filename); if (binname != string.Empty) { dt = new System.Data.DataTable(binname); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); if (File.Exists(filename)) { dt.ReadXml(filename); retval = true; } } } foreach (SymbolHelper sh in coll2load) { foreach (DataRow dr in dt.Rows) { try { //if (dr["SYMBOLNAME"].ToString() == sh.Varname) { if (sh.Flash_start_address == Convert.ToInt32(dr["FLASHADDRESS"])) { sh.Userdescription = dr["DESCRIPTION"].ToString(); break; } } } catch (Exception E) { Console.WriteLine(E.Message); } } } return retval; }
private void btnSearchMaps_ItemClick(object sender, ItemClickEventArgs e) { // ask the user for which value to search and if searching should include symbolnames and/or symbol description if (ValidateFile()) { SymbolCollection result_Collection = new SymbolCollection(); frmSearchMaps searchoptions = new frmSearchMaps(); if (searchoptions.ShowDialog() == DialogResult.OK) { frmProgress progress = new frmProgress(); progress.SetProgress("Start searching data..."); progress.SetProgressPercentage(0); progress.Show(); System.Windows.Forms.Application.DoEvents(); int cnt = 0; foreach (SymbolHelper sh in Tools.Instance.m_symbols) { progress.SetProgress("Searching " + sh.Varname); progress.SetProgressPercentage((cnt * 100) / Tools.Instance.m_symbols.Count); bool hit_found = false; if (searchoptions.IncludeSymbolNames) { if (searchoptions.SearchForNumericValues) { if (sh.Varname.Contains(searchoptions.NumericValueToSearchFor.ToString())) { hit_found = true; } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor != string.Empty) { if (sh.Varname.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } if (searchoptions.IncludeSymbolDescription) { if (searchoptions.SearchForNumericValues) { if (sh.Description.Contains(searchoptions.NumericValueToSearchFor.ToString())) { hit_found = true; } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor != string.Empty) { if (sh.Description.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } // now search the symbol data if (sh.Flash_start_address < Tools.Instance.m_currentfilelength) { byte[] symboldata = Tools.Instance.readdatafromfile(Tools.Instance.m_currentfile, (int)sh.Flash_start_address, sh.Length, Tools.Instance.m_currentFileType); if (searchoptions.SearchForNumericValues) { for (int i = 0; i < symboldata.Length / 2; i += 2) { float value = Convert.ToInt32(symboldata.GetValue(i)) * 256; value += Convert.ToInt32(symboldata.GetValue(i + 1)); value *= (float)GetMapCorrectionFactor(sh.Varname); value += (float)GetMapCorrectionOffset(sh.Varname); if (value == (float)searchoptions.NumericValueToSearchFor) { hit_found = true; } } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor.Length > symboldata.Length) { // possible... string symboldataasstring = System.Text.Encoding.ASCII.GetString(symboldata); if (symboldataasstring.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } if (hit_found) { // add to collection result_Collection.Add(sh); } cnt++; } progress.Close(); if (result_Collection.Count == 0) { frmInfoBox info = new frmInfoBox("No results found..."); } else { // start result screen dockManager1.BeginUpdate(); try { SymbolTranslator st = new SymbolTranslator(); DevExpress.XtraBars.Docking.DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); CompareResults tabdet = new CompareResults(); tabdet.ShowAddressesInHex = m_appSettings.ShowAddressesInHex; tabdet.SetFilterMode(m_appSettings.ShowAddressesInHex); tabdet.Dock = DockStyle.Fill; tabdet.UseForFind = true; tabdet.Filename = Tools.Instance.m_currentfile; tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelectForFind); dockPanel.Controls.Add(tabdet); dockPanel.Text = "Search results: " + Path.GetFileName(Tools.Instance.m_currentfile); dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Left, 1); dockPanel.Width = 500; System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean")); dt.Columns.Add("CATEGORY"); //0 dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double")); dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32")); dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double")); dt.Columns.Add("CATEGORYNAME"); dt.Columns.Add("SUBCATEGORYNAME"); dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32")); dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32")); dt.Columns.Add("CodeBlock1", Type.GetType("System.Int32")); dt.Columns.Add("CodeBlock2", Type.GetType("System.Int32")); string ht = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; foreach (SymbolHelper shfound in result_Collection) { string helptext = st.TranslateSymbolToHelpText(shfound.Varname); if (shfound.Varname.Contains(".")) { try { shfound.Category = shfound.Varname.Substring(0, shfound.Varname.IndexOf(".")); } catch (Exception cE) { Console.WriteLine("Failed to assign category to symbol: " + shfound.Varname + " err: " + cE.Message); } } dt.Rows.Add(shfound.Varname, shfound.Start_address, shfound.Flash_start_address, shfound.Length, shfound.Length, helptext, false, 0, 0, 0, 0, shfound.Category, "", shfound.Symbol_number, shfound.Symbol_number, shfound.CodeBlock, shfound.CodeBlock); } tabdet.CompareSymbolCollection = result_Collection; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); tabdet.gridControl1.DataSource = dt.Copy(); } catch (Exception E) { Console.WriteLine(E.Message); } dockManager1.EndUpdate(); } } } }