public List <Tuple <DiagnosticTroubleCode, string> > RequestAllDtcStatuses(OBD2.Cables.Cable cable) { List <Tuple <DiagnosticTroubleCode, string> > statuses = new List <Tuple <DiagnosticTroubleCode, string> >(); string response = cable.Communicate(this, 5000); string[] responses = ParameterIdentification.PrepareResponseString(response); if (responses != null) { foreach (string individualResponse in responses) { byte[] responseBytes = ParameterIdentification.ParseStringValues(individualResponse); if (responseBytes != null) { if (responseBytes.Length == 4) { if (responseBytes[0] - 0x40 == this.Mode) { string firstByte = responseBytes[1].ToString(Protocols.ToHexFormat); string secondByte = responseBytes[2].ToString(Protocols.ToHexFormat); // the code is still in elm327 encoded format, e.g. "4670" which would be DTC B0670 string elm327code = firstByte + secondByte; DiagnosticTroubleCode code = new DiagnosticTroubleCode(elm327code, DiagnosticTroubleCode.CodeType.StatusCheck); string codeStatusDescription = GetStatusDescription(responseBytes[3]); statuses.Add(new Tuple <DiagnosticTroubleCode, string>(code, codeStatusDescription)); } else { Diagnostics.DiagnosticLogger.Log("Invalid mode for mode 19 response line \"" + individualResponse + "\""); } } else { Diagnostics.DiagnosticLogger.Log("Received a mode 19 response line that did not have 4 bytes. Received \"" + individualResponse + "\""); } } else { Diagnostics.DiagnosticLogger.Log("ParseStringValues() returned null for response \"" + individualResponse ?? string.Empty + "\""); } } } else { Diagnostics.DiagnosticLogger.Log("PrepareResponseString() returned null for \"" + response ?? string.Empty + "\""); } return(statuses); }
public void UpdateTroubleCode(DiagnosticTroubleCode dtc) { troubleCodeReadings.Add(new Reading <DiagnosticTroubleCode>(dtc)); }