/// <summary> /// Get supp /// </summary> /// <param name="what"></param> /// <returns></returns> private async Task registerSupportedPid(OdbPid what) { OdbResponse response = await this.socket.SendAndCheck(what); OdbData data = this.socket.ResolveData(response, what); if (data != null) { this.decodeSupportedPidsAndRegisterIt(what, data); } }
/// <summary> /// report response /// </summary> /// <param name="odbResponse"></param> public void ReportResponse(OdbResponse odbResponse) { if (!OdbClient.OBD_REPORTER_ENABLED) { return; } if (odbResponse.IsValid) { Debug.WriteLine(ResponsePrefix + odbResponse.Pid.Pid + " (" + odbResponse.Pid.Description + ") > " + odbResponse.Response); } else { Debug.WriteLine(ErrorPrefix + odbResponse.Pid.Pid + " (" + odbResponse.Pid.Description + ") > Invalid response from OBD device."); } }
/// <summary> /// Load supported PIds /// </summary> /// <returns></returns> private async Task LoadSupportedProtocols(OdbProtocol protocolType = OdbProtocol.Unknown, int protocolNumber = 0) { var selectedProtocol = -1; if (protocolType == OdbProtocol.Unknown) { OdbPid protocol = null; for (selectedProtocol = 0; selectedProtocol <= 9; selectedProtocol++) { protocol = OdbPids.GetPidForProtocolNumber(selectedProtocol); try { OdbResponse response = await this.socket.SendAndCheck(protocol); if (response.IsValid) { break; } } catch { reporter.ReportInfo("Protocol ATSP" + protocol.Description + " is not supported."); } } if (selectedProtocol == 10) { throw new OdbException(OdbError.CouldNotFindCompatibleProtocol); } this.socket.SelectedProtocol = protocol; } else if (protocolType == OdbProtocol.Specified && protocolNumber > 0 && protocolNumber < 10) { OdbPid protocol = OdbPids.GetPidForProtocolNumber(selectedProtocol); await this.socket.SendAndCheck(protocol); this.socket.SelectedProtocol = protocol; } else { throw new OdbException(OdbError.WrongProtocolNumber); } }