diff --git a/OBD.NET/ODB.NET.ConsoleClient/App.config b/OBD.NET/ODB.NET.ConsoleClient/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/OBD.NET/ODB.NET.ConsoleClient/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OBD.NET/ODB.NET.ConsoleClient/ODB.NET.ConsoleClient.csproj b/OBD.NET/ODB.NET.ConsoleClient/ODB.NET.ConsoleClient.csproj new file mode 100644 index 0000000..b86764b --- /dev/null +++ b/OBD.NET/ODB.NET.ConsoleClient/ODB.NET.ConsoleClient.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC} + Exe + ODB.NET.ConsoleClient + ODB.NET.ConsoleClient + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31} + OBD.NET.Common + + + {14CB98E1-95DE-4923-8896-FDF5171AA49E} + ODB.NET.Desktop + + + + \ No newline at end of file diff --git a/OBD.NET/ODB.NET.ConsoleClient/Program.cs b/OBD.NET/ODB.NET.ConsoleClient/Program.cs new file mode 100644 index 0000000..172809d --- /dev/null +++ b/OBD.NET/ODB.NET.ConsoleClient/Program.cs @@ -0,0 +1,56 @@ +using OBD.NET.Common.Logging; +using OBD.NET.Communication; +using OBD.NET.Devices; +using OBD.NET.Logging; +using OBD.NET.OBDData; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace ODB.NET.ConsoleClient +{ + /// + /// Console test client + /// + class Program + { + static void Main(string[] args) + { + if (args.Length < 1) + { + Console.WriteLine("Parameter ComPort needed."); + return; + } + + var comPort = args[0]; + + using (SerialConnection connection = new SerialConnection(comPort)) + using (ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug))) + { + dev.SubscribeDataReceived((sender, data) => + { + Console.WriteLine("EngineRPM: " + data.Data.Rpm); + }); + + dev.SubscribeDataReceived((sender, data) => + { + Console.WriteLine("VehicleSpeed: " + data.Data.Speed); + }); + + dev.Initialize(); + dev.RequestData(); + for (int i = 0; i < 5; i++) + { + dev.RequestData(); + dev.RequestData(); + Thread.Sleep(1000); + } + Console.ReadLine(); + } + + } + } +} diff --git a/OBD.NET/ODB.NET.ConsoleClient/Properties/AssemblyInfo.cs b/OBD.NET/ODB.NET.ConsoleClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..95594b5 --- /dev/null +++ b/OBD.NET/ODB.NET.ConsoleClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ODB.NET.ConsoleClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ODB.NET.ConsoleClient")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8f8ec5d5-94bd-47cf-9714-ca8c0198bddc")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OBD.NET/ODB.NET.Desktop/Logging/ODBConsoleLogger.cs b/OBD.NET/ODB.NET.Desktop/Logging/ODBConsoleLogger.cs new file mode 100644 index 0000000..0e69e0b --- /dev/null +++ b/OBD.NET/ODB.NET.Desktop/Logging/ODBConsoleLogger.cs @@ -0,0 +1,35 @@ +using OBD.NET.Logging; +using System; +using System.Diagnostics; + +namespace OBD.NET.Common.Logging +{ + /// + /// Simple console logger + /// + /// + public class OBDConsoleLogger : IOBDLogger + { + public OBDLogLevel LogLevel { get; set; } + + public OBDConsoleLogger() + { + LogLevel = OBDLogLevel.None; + } + + public OBDConsoleLogger(OBDLogLevel level) + { + LogLevel = level; + } + + public void WriteLine(string text, OBDLogLevel level) + { + if (LogLevel == OBDLogLevel.None) return; + + if((int)level >= (int)LogLevel) + { + Console.WriteLine($"{DateTime.Now.ToString()} - {level} - {text}"); + } + } + } +} diff --git a/OBD.NET/ODB.NET.Desktop/ODB.NET.Desktop.csproj b/OBD.NET/ODB.NET.Desktop/ODB.NET.Desktop.csproj index 083888b..47674c1 100644 --- a/OBD.NET/ODB.NET.Desktop/ODB.NET.Desktop.csproj +++ b/OBD.NET/ODB.NET.Desktop/ODB.NET.Desktop.csproj @@ -42,6 +42,7 @@ +