public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; String value = ""; byte milLampBit = (byte)0x00; // Bit 7 of byte 1 = MIL Lamp Status milLampBit = (byte)(data[0] & 0x80); if (milLampBit > 0) { value = "ON"; } else { value = "OFF"; } arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; UInt16[] value = new UInt16[2]; if (data.Length == 4) { value[0] = (UInt16)((data[0] << 8) | data[1]); value[1] = (UInt16)((data[2] << 8) | data[3]); arg = new ELM327ListenerEventArgs(this, value); } else { arg = new ELM327ListenerEventArgs(this, null, true, "Only " + data.Length + " bytes of data were returned. Expected 4 bytes."); } if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; StringBuilder value = new StringBuilder(data.Length); /* * Convert the string of bytes into a string of characters * Skip the first byte. It directly precedes the first * actual VIN data in the FIRST FRAME. It indicates the * number of data items to expect (in this case 1 because * there is only 1 VIN number). */ for (int i = 1; i < data.Length; i++) { value.Append((char)data[i]); } arg = new ELM327ListenerEventArgs(this, value.ToString()); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
/// <summary> /// Registers a listener on the handler for one request only. After it has completed the request/response cycle, the listener is removed from the handler /// and the response is returned from this method. This method blocks the calling thread until it returns; therefore, this is a synchronous call. /// </summary> /// <param name="handlerName">The name of the Handler to use for the request/response cycle.</param> /// <returns>The processed results.</returns> public ELM327ListenerEventArgs SyncQuery(string handlerName) { // Variables HandlerWrapper handlerWrapper = null; ELM327ListenerEventArgs returnValue = null; Stopwatch stopWatch = new Stopwatch(); // Find a Handler with the provided name if (!(_loadedHandlers.TryGetValue(handlerName, out handlerWrapper))) { log.Error("An attempt was made to enqueue a handler for an AsyncQuery that could not be found using the provided name: " + handlerName); return(null); } // Add an anonymous listener that gets the value for us handlerWrapper.Handler.RegisterSingleListener( new Action <ELM327ListenerEventArgs>( (ELM327ListenerEventArgs args) => { returnValue = args; } ) ); // Wait no more than 100 milliseconds for a response stopWatch.Start(); while (stopWatch.ElapsedMilliseconds < 100 && returnValue == null) { ; } stopWatch.Stop(); return(returnValue); }
public void Update(ELM327ListenerEventArgs e) { foreach (DataItem d in _dataItems) { if (d.HandlerType.Equals(e.Handler.GetType())) { d.Value = e.ProcessedResponse.ToString(); } } }
/// <summary> /// This method cycles through the list of ECU Addresses (see <see cref="IProtocol.EcuAddresses"/>) and /// queries each one to see if it exists. A list of responsive ECUs is returned. /// </summary> /// <returns>List of ECUs that responded to queries.</returns> public override List <ECU> AutoDetectEcus() { // Variables List <ECU> returnValue = new List <ECU>(); ELM327ListenerEventArgs response = null; Stopwatch stopWatch = new Stopwatch(); // Find a Handler with the provided name DiagnosticSessionControlHandler interrogationHandler = new DiagnosticSessionControlHandler(); // Add an anonymous listener that gets the value for us interrogationHandler.RegisterSingleListener( new Action <ELM327ListenerEventArgs>( (ELM327ListenerEventArgs args) => { response = args; } ) ); // Wait no more than 100 milliseconds for a response foreach (ECU nextEcu in EcuAddresses) { // Set the ECU request address interrogationHandler.Header = nextEcu.RequestAddress.ToString("X6"); // Interrogate bool successfulExecution = Execute(interrogationHandler); // If a valid response was received, add the ECU if (successfulExecution && response != null && !response.IsBadResponse) { returnValue.Add(nextEcu); } response = null; } #if DEBUG // If we are debugging, add the Engine Control Module as a "responsive" ECU // because the emulator doesn't recognize UDS commands (see ISO15765-3). returnValue.Add(EcuAddresses[1]); #endif return(returnValue); }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; UInt32 value = (UInt32)(((uint)data[0] * 256 + (uint)data[1]) * 0.621371); arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; UInt32 value = ((uint)data[0] * 100) / 255; arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; Int32 value = (Int32)(((int)data[0] - 40) * 1.8 + 32.0); arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; Single value = (Single)(((data[0] - 128) * 100) / 128.0f); arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; Single value = (((float)data[0] * 256.0f) + (float)data[1]) / 4.0f; arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; UInt32 value = (uint)data[0]; value = (uint)Math.Round((float)value * 0.621371192f); arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; UInt32 value = (UInt32)0; // Bits 0-6 of byte 1 = # of DTCs stored in ECU value = (UInt32)(data[0] & 0xEF); arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }
public void Update(ELM327ListenerEventArgs e) { return; }
public void ProcessResponse(byte[] data) { ELM327ListenerEventArgs arg; String value = ""; switch (data[0]) { case 0x01: { value = "OBD II (California ARB)"; break; } case 0x02: { value = "OBD (Federal EPA)"; break; } case 0x03: { value = "OBD and OBD II"; break; } case 0x04: { value = "OBD I"; break; } case 0x05: { value = "Not OBD Compliant"; break; } case 0x06: { value = "EOBD"; break; } case 0x07: { value = "EOBD and OBD II"; break; } case 0x08: { value = "EOBD and OBD"; break; } case 0x09: { value = "EOBD, OBD, and OBDII"; break; } case 0x0A: { value = "JOBD"; break; } case 0x0B: { value = "JOBD and OBDII"; break; } case 0x0C: { value = "JOBD and EOBD"; break; } case 0x0D: { value = "JOBD, EOBD, and OBD II"; break; } case 0x0E: { value = "Heavy Duty Vehicles (EURO IV) B1"; break; } case 0x0F: { value = "Heavy Duty Vehicles (EURO V) B2"; break; } case 0x10: { value = "Heavy Duty Vehicles (EURO EEC) C (gas engines)"; break; } case 0x11: { value = "Engine Manufacturer Diagnostics (EMD)"; break; } default: { if (data[0] > 0x11 && data[0] < 0xFB) { value = "ISO/SAE reserved"; } else if (data[0] > 0xFA) { value = "ISO/SAE Not available for assignment"; } break; } } arg = new ELM327ListenerEventArgs(this, value); if (RegisteredListeners != null) { RegisteredListeners(arg); } if (RegisteredSingleListeners != null) { RegisteredSingleListeners(arg); RegisteredSingleListeners = null; } }