public void DefineRRLogEcuFromMap(string mapFile, string ident)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(mapFile);
            DefineRRLogEcu(im.Locs, ident);
        }
Exemple #2
0
        public void ImportMapText(string text, ECU image)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(text);
            ReadMap(im, image);
        }
Exemple #3
0
 public void ReadMap(EcuMap idaMap, ECU image)
 {
     //loop through base def and search for table names in map
     foreach (var romtable in AggregateBaseRomTables)
     {
         foreach (var idan in idaMap.CleanLocs)
         {
             if (romtable.Key.EqualsDefineString(idan.Key))
             {
                 ExposeTable(romtable.Key, LookupTableFactory.CreateLookupTable(romtable.Key, uint.Parse(idan.Value.ToString(), NumberStyles.AllowHexSpecifier), image.imageStream));
                 break;
             }
         }
     }
     ////TODO RAMTABLES
     //foreach (var ramtable in baseDef.RamTableList)
     //{
     //    foreach (var idan in idaMap.IdaCleanNames)
     //    {
     //        if (ramtable.Key.EqualsIdaString(idan.Key))
     //        {
     //            break;
     //        }
     //    }
     //}
 }
Exemple #4
0
        public void ImportMapFile(string filepath, ECU image)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(filepath);
            ReadMap(im, image);
        }
        public IMessage[] Parse(params string[] lines)
        {
            var obdLines    = new List <string>();
            var nonOBDLines = new List <string>();

            foreach (var line in lines)
            {
                var lineNoSpaces = line.Replace(Space, string.Empty);

                if (Utils.IsHex(lineNoSpaces))
                {
                    obdLines.Add(lineNoSpaces);
                }
                else
                {
                    nonOBDLines.Add(line); // pass the original, un-scrubbed line
                }
            }

            // ---------------------- handle valid OBD lines ----------------------

            // # parse each frame (each line)
            var frames = new List <IFrame>();

            foreach (var line in obdLines)
            {
                var frame = new Frame(line);

                //# subclass function to parse the lines into Frames
                //# drop frames that couldn't be parsed
                if (ParseFrame(frame))
                {
                    frames.Add(frame);
                }
            }
            //# group frames by transmitting ECU
            //# frames_by_ECU[tx_id] = [Frame, Frame]
            var framesByECU = new Dictionary <int, List <IFrame> >();

            foreach (var frame in frames)
            {
                if (!framesByECU.ContainsKey(frame.TxId))
                {
                    framesByECU[frame.TxId] = new List <IFrame> {
                        frame
                    };
                }
                else
                {
                    framesByECU[frame.TxId].Add(frame);
                }
            }
            //# parse frames into whole messages
            var messages = new List <IMessage>();

            foreach (var ecu in framesByECU)
            {
                //# new message object with a copy of the raw data
                //# and frames addressed for this ecu
                var message = new Message(ecu.Value.ToArray());

                //# subclass function to assemble frames into Messages
                if (ParseMessage(message))
                {
                    //# mark with the appropriate ECU ID
                    message.Ecu = EcuMap.ContainsKey(ecu.Key) ? EcuMap[ecu.Key] : ECU.Unknown;
                    messages.Add(message);
                }
            }
            //# ----------- handle invalid lines (probably from the ELM) -----------

            foreach (var line in nonOBDLines)
            {
                //# give each line its own message object
                //# messages are ECU.UNKNOWN by default
                messages.Add(new Message(new Frame(line)));
            }

            return(messages.ToArray());
        }