/// <summary> /// Read a dpid response from the PCM. /// </summary> public async Task <RawLogData> ReadLogData() { Message message; RawLogData result = null; for (int attempt = 1; attempt < 3; attempt++) { message = await this.ReceiveMessage(); if (message == null) { break; } this.logger.AddDebugMessage("ReadLogData: " + message.ToString()); if (message[3] != 0x6A) { continue; } if (this.protocol.TryParseRawLogData(message, out result)) { break; } } return(result); }
/// <summary> /// Invoke this repeatedly to get each row of data from the PCM. /// </summary> /// <returns></returns> public async Task <string[]> GetNextRow() { LogRowParser row = new LogRowParser(this.profile); #if FAST_LOGGING if (DateTime.Now.Subtract(lastRequestTime) > TimeSpan.FromSeconds(2)) { await this.vehicle.ForceSendToolPresentNotification(); } #endif #if !FAST_LOGGING if (!await this.vehicle.RequestDpids(this.dpids)) { return(null); } #endif while (!row.IsComplete) { RawLogData rawData = await this.vehicle.ReadLogData(); if (rawData == null) { return(null); } row.ParseData(rawData); } return(row.Evaluate()); }
/// <summary> /// Extracts the payload from a dpid message from the PCM. /// </summary> /// <param name="rawData"></param> public void ParseData(RawLogData rawData) { if (this.IsComplete) { throw new InvalidOperationException("This log row is already complete."); } this.responseData[rawData.Dpid] = rawData.Payload; this.dpidsReceived.Add(rawData.Dpid); }
/// <summary> /// Extract the raw data from a dpid response message. /// </summary> public bool TryParseRawLogData(Message message, out RawLogData rawLogData) { ResponseStatus unused; if (!TryVerifyInitialBytes(message.GetBytes(), new byte[] { 0x6C, DeviceId.Tool, DeviceId.Pcm, 0x6A }, out unused)) { rawLogData = null; return(false); } rawLogData = new RawLogData(message[4], message.GetBytes().Skip(5).Take(6).ToArray()); return(true); }
/// <summary> /// Invoke this repeatedly to get each row of data from the PCM. /// </summary> /// <returns></returns> public async Task <IEnumerable <string> > GetNextRow() { LogRowParser row = new LogRowParser(this.profileAndMath.Profile); #if FAST_LOGGING // if (DateTime.Now.Subtract(lastRequestTime) > TimeSpan.FromSeconds(2)) { await this.vehicle.ForceSendToolPresentNotification(); } #endif #if !FAST_LOGGING if (!await this.vehicle.RequestDpids(this.dpids)) { return(null); } #endif while (!row.IsComplete) { RawLogData rawData = await this.vehicle.ReadLogData(); if (rawData == null) { return(null); } row.ParseData(rawData); } DpidValues dpidValues = row.Evaluate(); IEnumerable <string> mathValues = this.profileAndMath.MathValueProcessor.GetMathValues(dpidValues); return(dpidValues .Select(x => x.Value.ValueAsString) .Concat(mathValues) .ToArray()); }