public static int Main(string[] args) { responsesPath = args.Length > 0 ? args [0] : responsesPath; defsPath = args.Length > 1 ? args [1] : defsPath; Console.WriteLine("ParsePID: Parse Subaru OBD-II mode 22 definitions and support responses."); Console.WriteLine("Usage:"); Console.WriteLine("ParsePID.exe <ResponseFile> <DefinitionsFile>"); Console.WriteLine("or: ParsePID.exe <ResponseFile>"); Console.WriteLine("or for using predefined file paths: ParsePID.exe\n"); if (!System.IO.File.Exists(defsPath)) { Console.Error.WriteLine("ERROR: Definitions file not found: \"{0}\"", defsPath); return(2); } if (!System.IO.File.Exists(responsesPath)) { Console.Error.WriteLine("ERROR: Response file not found: \"{0}\"", responsesPath); return(2); } Console.WriteLine("Parsing parameter definitions from file \"{0}\"", defsPath); using (var parser = new ParseDefCsv(defsPath, CsvSeparator)) { if (!parser.Parse(out parameters)) { return(1); } } Console.WriteLine("Parsed {0} parameters.", parameters.Count); Console.WriteLine(); Console.WriteLine("Parsing support responses from file \"{0}\"", responsesPath); using (var parser = new ParseSupportResponses(responsesPath)) { if (!parser.Parse(out supportResponses)) { return(1); } } foreach (var item in supportResponses) { Console.WriteLine(item); } Console.WriteLine("Parsed {0} support responses.", supportResponses.Count); // check PIDs, generate results foreach (var r in supportResponses) { if (IncludeSupportPIDs) { SearchAddParameter(r.PID); } ProcessParameterSupport(r); } // sort by PID and remove duplicates (SupportPIDs) var results = parametersSupported.OrderBy(p => p.PID).Distinct(new ParameterPIDComparer()).ToList(); // output results Console.WriteLine("\nResults:"); foreach (var p in results) { PrintParameter(p); } int countSupportedKnown = results.Count(p => p.IsDefined); int countSupportedUnknown = results.Count - countSupportedKnown; Console.WriteLine("Supported PIDs total: {0} | known: {1} | unknown: {2}", results.Count, countSupportedKnown, countSupportedUnknown); return(0); }
public static int Main(string[] args) { responsesPath = args.Length > 0 ? args [0] : responsesPath; defsPath = args.Length > 1 ? args [1] : defsPath; Console.WriteLine ("ParsePID: Parse Subaru OBD-II mode 22 definitions and support responses."); Console.WriteLine ("Usage:"); Console.WriteLine ("ParsePID.exe <ResponseFile> <DefinitionsFile>"); Console.WriteLine ("or: ParsePID.exe <ResponseFile>"); Console.WriteLine ("or for using predefined file paths: ParsePID.exe\n"); if (!System.IO.File.Exists (defsPath)) { Console.Error.WriteLine ("ERROR: Definitions file not found: \"{0}\"", defsPath); return 2; } if (!System.IO.File.Exists (responsesPath)) { Console.Error.WriteLine ("ERROR: Response file not found: \"{0}\"", responsesPath); return 2; } Console.WriteLine ("Parsing parameter definitions from file \"{0}\"", defsPath); using (var parser = new ParseDefCsv (defsPath, CsvSeparator)) { if (!parser.Parse (out parameters)) return 1; } Console.WriteLine ("Parsed {0} parameters.", parameters.Count); Console.WriteLine (); Console.WriteLine ("Parsing support responses from file \"{0}\"", responsesPath); using (var parser = new ParseSupportResponses (responsesPath)) { if (!parser.Parse (out supportResponses)) return 1; } foreach (var item in supportResponses) { Console.WriteLine (item); } Console.WriteLine ("Parsed {0} support responses.", supportResponses.Count); // check PIDs, generate results foreach (var r in supportResponses) { if (IncludeSupportPIDs) { SearchAddParameter (r.PID); } ProcessParameterSupport (r); } // sort by PID and remove duplicates (SupportPIDs) var results = parametersSupported.OrderBy (p => p.PID).Distinct (new ParameterPIDComparer ()).ToList (); // output results Console.WriteLine ("\nResults:"); foreach (var p in results) { PrintParameter (p); } int countSupportedKnown = results.Count (p => p.IsDefined); int countSupportedUnknown = results.Count - countSupportedKnown; Console.WriteLine ("Supported PIDs total: {0} | known: {1} | unknown: {2}", results.Count, countSupportedKnown, countSupportedUnknown); return 0; }