/// <summary> /// Request OBD from all known ports in parallel. /// </summary> private void RequestOBD() { // Dispose of (close) old connections. Parallel.ForEach(ports, (port) => { port.Dispose(); }); ports.Clear(); // Remove trash. // Grab new ports. ports = Sender.GetPorts(); Log(string.Format("Found {0} communication ports.", ports.Count)); // Get the command used to search for the OBD. if (cmdDeviceDescription == null) { cmdDeviceDescription = GetCommandOfType <IDeviceDescription>(assemblyCommands) as IDeviceDescription; } // Search for OBD. Parallel.ForEach(ports, (port) => { port.DataReceived += Receiver.OnDataReceived; try { port.Request(cmdDeviceDescription); } catch (Exception e) { Log(e.Message); } }); }
public static IDeviceDescription CreateDeviceDescription(EltraDevice device, DeviceDescriptionFile deviceDescriptionFile) { IDeviceDescription result = null; var content = deviceDescriptionFile?.Content; if (content != null && device != null) { switch (device.Family) { case "EPOS2": throw new NotImplementedException(); case "EPOS4": result = new XddDeviceDescription(device) { DataSource = content }; break; default: result = new XddDeviceDescription(device) { DataSource = content }; break; } } return(result); }