diff --git a/OBD.NET/ODB.NET.ConsoleClient/Program.cs b/OBD.NET/ODB.NET.ConsoleClient/Program.cs index 172809d..f8f8e02 100644 --- a/OBD.NET/ODB.NET.ConsoleClient/Program.cs +++ b/OBD.NET/ODB.NET.ConsoleClient/Program.cs @@ -24,7 +24,7 @@ namespace ODB.NET.ConsoleClient Console.WriteLine("Parameter ComPort needed."); return; } - + var comPort = args[0]; using (SerialConnection connection = new SerialConnection(comPort)) @@ -50,7 +50,35 @@ namespace ODB.NET.ConsoleClient } Console.ReadLine(); } + + //Async example + MainAsync(comPort).Wait(); } + + /// + /// Async example using new RequestDataAsync + /// + /// The COM port. + /// + public static async Task MainAsync(string comPort) + { + using (SerialConnection connection = new SerialConnection(comPort)) + using (ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug))) + { + dev.Initialize(); + var data = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + data.Rpm); + data = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + data.Rpm); + var data2 = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + data2.Speed); + data = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + data.Rpm); + + } + } } + + }