private List <FuelSystemStatus> FuelSystemStatus(string[] data) { var binary = HexHelper.Sanitize(data); List <FuelSystemStatus> FuelSystemStatuses = new List <FuelSystemStatus>(); try { var fs = Convert.ToInt32(binary.Substring(0, 4), 2); FuelSystemStatuses.Add(new FuelSystemStatus(fs)); var fs2 = Convert.ToInt32(binary.Substring(4, 4), 2); FuelSystemStatuses.Add(new FuelSystemStatus(fs2)); } catch (Exception err) { } return(FuelSystemStatuses); }
private static Dictionary <ObdPid, bool> PidSupport(string[] data, ObdPid pid) { int offset; switch (pid) { case ObdPid.PidSupport_01_20: offset = 0; break; case ObdPid.PidSupport_21_40: offset = 32; break; case ObdPid.PidSupport_41_60: offset = 64; break; case ObdPid.PidSupport_61_80: offset = 96; break; case ObdPid.PidSupport_81_A0: offset = 128; break; default: offset = 0; break; } var binary = HexHelper.Sanitize(data); //dictionary of pids and car support for each one Dictionary <ObdPid, bool> pidSupport = new Dictionary <ObdPid, bool>(); for (int i = 0; i < binary.Length; i++) { pidSupport.Add((ObdPid)(i + 1) + offset, binary[i] == '1'); } return(pidSupport); }
private MonitorStatus MonitorStatus(string[] data) { var binary = HexHelper.Sanitize(data); //get # of DTC codes using bits A0 - A6 var dtcCount = Convert.ToInt32(binary.Substring(1, 6), 2); //convert all bits to boolean flags for polling on board tests bool[] tests = new bool[binary.Length]; for (int i = 0; i < binary.Length; i++) { tests[i] = binary[i] == '1'; } return(new MonitorStatus() { CheckEngineLightOn = tests[7], DTCCount = dtcCount, OnBoardTests = tests }); }