mirror of
https://github.com/DarthAffe/OBD.NET.git
synced 2025-12-13 01:08:30 +00:00
Updated console client for RequestDataAsync
This commit is contained in:
parent
fa3fb7b756
commit
5e10352306
@ -24,7 +24,7 @@ namespace ODB.NET.ConsoleClient
|
|||||||
Console.WriteLine("Parameter ComPort needed.");
|
Console.WriteLine("Parameter ComPort needed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var comPort = args[0];
|
var comPort = args[0];
|
||||||
|
|
||||||
using (SerialConnection connection = new SerialConnection(comPort))
|
using (SerialConnection connection = new SerialConnection(comPort))
|
||||||
@ -50,7 +50,35 @@ namespace ODB.NET.ConsoleClient
|
|||||||
}
|
}
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Async example
|
||||||
|
MainAsync(comPort).Wait();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Async example using new RequestDataAsync
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="comPort">The COM port.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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<EngineRPM>();
|
||||||
|
Console.WriteLine("Data: " + data.Rpm);
|
||||||
|
data = await dev.RequestDataAsync<EngineRPM>();
|
||||||
|
Console.WriteLine("Data: " + data.Rpm);
|
||||||
|
var data2 = await dev.RequestDataAsync<VehicleSpeed>();
|
||||||
|
Console.WriteLine("Data: " + data2.Speed);
|
||||||
|
data = await dev.RequestDataAsync<EngineRPM>();
|
||||||
|
Console.WriteLine("Data: " + data.Rpm);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user