1
0
mirror of https://github.com/DarthAffe/OBD.NET.git synced 2025-12-12 16:58:30 +00:00

Moved common parts into ODB.NET.Common

re-factored SerialConnection to ISerialConnection interface and removed stuff which is not compatible with NetStandard
This commit is contained in:
Roman Lumetsberger 2017-05-07 09:25:57 +02:00
parent 7e0e2447c7
commit 9dd42cba6f
144 changed files with 73 additions and 536 deletions

View File

@ -0,0 +1,40 @@
using System;
using System.Text;
using System.Threading;
namespace OBD.NET.Communication
{
/// <summary>
/// Serial connection interface
/// </summary>
/// <seealso cref="System.IDisposable" />
public interface ISerialConnection : IDisposable
{
/// <summary>
/// Gets a value indicating whether this instance is open.
/// </summary>
/// <value>
/// <c>true</c> if this instance is open; otherwise, <c>false</c>.
/// </value>
bool IsOpen { get; }
/// <summary>
/// Occurs when a full line was received
/// </summary>
event EventHandler<string> MessageReceived;
/// <summary>
/// Connects the serial port.
/// </summary>
void Connect();
/// <summary>
/// Writes the specified text to the serial connection
/// </summary>
/// <param name="text">The text.</param>
void Write(string text);
}
}

View File

@ -36,7 +36,7 @@ namespace OBD.NET.Devices
#region Constructors
public ELM327(SerialConnection connection, IOBDLogger logger = null)
public ELM327(ISerialConnection connection, IOBDLogger logger = null)
: base(connection, logger: logger)
{ }

View File

@ -9,7 +9,7 @@ namespace OBD.NET.Devices
#region Constructors
public STN1170(SerialConnection connection, IOBDLogger logger = null)
public STN1170(ISerialConnection connection, IOBDLogger logger = null)
: base(connection, logger)
{ }

View File

@ -11,14 +11,14 @@ namespace OBD.NET.Devices
protected IOBDLogger Logger { get; }
protected SerialConnection Connection { get; }
protected ISerialConnection Connection { get; }
protected char Terminator { get; set; }
#endregion
#region Constructors
protected SerialDevice(SerialConnection connection, char terminator = '\r', IOBDLogger logger = null)
protected SerialDevice(ISerialConnection connection, char terminator = '\r', IOBDLogger logger = null)
{
this.Connection = connection;
this.Terminator = terminator;

View File

@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
namespace OBD.NET.Exceptions
{
@ -17,10 +16,7 @@ namespace OBD.NET.Exceptions
public SerialException(string message, Exception innerException)
: base(message, innerException)
{ }
protected SerialException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endregion
}

View File

@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
namespace OBD.NET.Exceptions
{
@ -34,13 +33,7 @@ namespace OBD.NET.Exceptions
this.Result = result;
this.ExpectedResult = expectedResult;
}
protected UnexpectedResultException(SerializationInfo info, StreamingContext context, string result, string expectedResult)
: base(info, context)
{
this.Result = result;
this.ExpectedResult = expectedResult;
}
#endregion
}

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<Authors>Wyrez / Roman Lumetsberger</Authors>
<Company>-</Company>
<Product>OBD.NET</Product>
<Description>C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter</Description>
</PropertyGroup>
<ItemGroup>
<Folder Include="Communication\" />
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More