Beispiel #1
0
        public override string Communicate(ParameterIdentification pid, int timeout = 300)
        {
            // check if the header needs to be set
            if (pid.Header != currentJ1850Header &&
                !string.IsNullOrEmpty(pid.Header))
            {
                string response = SendCommand(Protocols.Elm327.SetFrameHeader(pid.Header));
                if (!response.Contains(Protocols.Elm327.Responses.OK))
                {
                    Diagnostics.DiagnosticLogger.Log("Could not set frame header for PID" + System.Environment.NewLine + pid.ToString());
                    return(null);
                }
            }
            else if (string.IsNullOrEmpty(pid.Header))
            {
                string response = SendCommand(Protocols.Elm327.SetFrameHeader(Protocols.J1850.Headers.Default));
                if (!response.Contains(Protocols.Elm327.Responses.OK))
                {
                    Diagnostics.DiagnosticLogger.Log("Could not set default frame header for PID" + System.Environment.NewLine + pid.ToString());
                    return(null);
                }
            }

            return(pid.SimulatedResponse(this.Protocol));
        }