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

Readded UWP bluetooth implementation

This commit is contained in:
Julian Windows 2022-03-30 08:59:54 -07:00
parent 24b18a6708
commit 086a670855
9 changed files with 486 additions and 6 deletions

View File

@ -0,0 +1,170 @@
using System;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Threading.Tasks;
using OBD.NET.Communication.EventArgs;
using Windows.Devices.Bluetooth.Rfcomm;
using Windows.Networking.Sockets;
using Windows.Storage.Streams;
using System.Linq;
namespace OBD.NET.Communication
{
/// <summary>
/// Bluetooth OBD serial implementation
/// </summary>
/// <seealso cref="OBD.NET.Communication.ISerialConnection" />
public class BluetoothSerialConnection : ISerialConnection
{
private StreamSocket _socket;
private DataWriter _writer;
private readonly byte[] _readBuffer = new byte[1024];
private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private Task _readerTask;
private string device;
/// <summary>
/// Initializes a new instance of the <see cref="BluetoothSerialConnection"/> class.
/// </summary>
public BluetoothSerialConnection()
{
device = null;
}
/// <summary>
/// Initializes a new instance of the <see cref="BluetoothSerialConnection"/> class.
/// </summary>
/// <param name="deviceName">Name of the device.</param>
/// <param name="logger">The logger.</param>
public BluetoothSerialConnection(string deviceName)
{
device = deviceName;
}
/// <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>
public bool IsOpen { get; private set; }
/// <summary>
/// Gets a value indicating whether this instance uses asynchronous IO
/// </summary>
/// <remarks>
/// Has to be set to true if asynchronous IO is supported.
/// If true async methods have to be implemented
/// </remarks>
public bool IsAsync => true;
/// <summary>
/// Occurs when a full line was received
/// </summary>
public event EventHandler<DataReceivedEventArgs> DataReceived;
/// <summary>
/// Connects the serial port.
/// </summary>
/// <exception cref="System.NotSupportedException">Synchronous operations not supported</exception>
public void Connect()
{
throw new NotSupportedException("Synchronous operations not supported on UWP platform");
}
/// <summary>
/// Connects the serial port asynchronously
/// </summary>
/// <returns></returns>
public async Task ConnectAsync()
{
var services = await Windows.Devices.Enumeration.DeviceInformation
.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
//use first serial service
if (services.Count > 0)
{
var id = services[0].Id;
//use predefined device from constructor
if (!string.IsNullOrWhiteSpace(device))
{
id = services.Where(x => x.Name.Equals(device, StringComparison.OrdinalIgnoreCase))
.Select(x => x.Id).FirstOrDefault();
if (id == null)
{
throw new InvalidOperationException($"Device {device} not found");
}
}
// Initialize the target Bluetooth device
var service = await RfcommDeviceService.FromIdAsync(id);
// Check that the service meets this App's minimum requirement
_socket = new StreamSocket();
await _socket.ConnectAsync(service.ConnectionHostName,
service.ConnectionServiceName);
_writer = new DataWriter(_socket.OutputStream);
_readerTask = StartReader();
IsOpen = true;
}
}
/// <summary>
/// Writes the specified text to the serial connection
/// </summary>
/// <param name="text">The text.</param>
/// <exception cref="System.NotImplementedException">Synchronous operations not supported</exception>
public void Write(byte[] data)
{
throw new NotImplementedException("Synchronous operations not supported on UWP platform");
}
/// <summary>
/// Writes the specified text to the serial connection asynchronously
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
public async Task WriteAsync(byte[] data)
{
_writer.WriteBytes(data);
await _writer.StoreAsync();
await _writer.FlushAsync();
}
private Task StartReader()
{
return Task.Factory.StartNew(async () =>
{
var buffer = _readBuffer.AsBuffer();
while (!_cancellationTokenSource.IsCancellationRequested)
{
var readData = await _socket.InputStream.ReadAsync(buffer, buffer.Capacity, InputStreamOptions.Partial);
SerialPortOnDataReceived(readData);
}
}, _cancellationTokenSource.Token);
}
private void SerialPortOnDataReceived(IBuffer buffer)
{
DataReceived?.Invoke(this, new DataReceivedEventArgs((int)buffer.Length, _readBuffer));
}
public void Dispose()
{
_cancellationTokenSource?.Cancel();
_readerTask?.Wait();
_socket?.Dispose();
}
}
}

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E0EAFF82-C514-4827-8F49-F1928EBA8E73}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OBD.NET.Universal</RootNamespace>
<AssemblyName>OBD.NET.Universal</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="Communication\BluetoothSerialConnection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\OBD.NET.Universal.rd.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.13</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OBD.NET\OBD.NET.csproj">
<Project>{d985b70e-cdf3-4cf1-ab5d-8d19c7fe7b31}</Project>
<Name>OBD.NET</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="OBD.NET.Universal.nuspec" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<projectUrl>https://github.com/romanlum/OBD.NET</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright 2017</copyright>
</metadata>
</package>

View File

@ -0,0 +1,29 @@
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("OBD.NET.Universal")]
[assembly: AssemblyDescription("C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter on UWP")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Roman Lumetsberger")]
[assembly: AssemblyProduct("OBD.NET")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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")]
[assembly: ComVisible(false)]

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains Runtime Directives, specifications about types your application accesses
through reflection and other dynamic code patterns. Runtime Directives are used to control the
.NET Native optimizer and ensure that it does not remove code accessed by your library. If your
library does not do any reflection, then you generally do not need to edit this file. However,
if your library reflects over types, especially types passed to it or derived from its types,
then you should write Runtime Directives.
The most common use of reflection in libraries is to discover information about types passed
to the library. Runtime Directives have three ways to express requirements on types passed to
your library.
1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter
Use these directives to reflect over types passed as a parameter.
2. SubTypes
Use a SubTypes directive to reflect over types derived from another type.
3. AttributeImplies
Use an AttributeImplies directive to indicate that your library needs to reflect over
types or methods decorated with an attribute.
For more information on writing Runtime Directives for libraries, please visit
https://go.microsoft.com/fwlink/?LinkID=391919
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Library Name="OBD.NET.Universal">
<!-- add directives for your library here -->
</Library>
</Directives>

View File

@ -1,22 +1,93 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OBD.NET", "OBD.NET\OBD.NET.csproj", "{F60052E8-1201-4A5A-ADD7-6367C5424F74}"
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OBD.NET", "OBD.NET\OBD.NET.csproj", "{F60052E8-1201-4A5A-ADD7-6367C5424F74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleClient", "ConsoleClient\ConsoleClient.csproj", "{8AC58110-3925-481F-9D85-4B809D7D18B9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleClient", "ConsoleClient\ConsoleClient.csproj", "{8AC58110-3925-481F-9D85-4B809D7D18B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OBD.NET.Universal", "OBD.NET.Universal\OBD.NET.Universal.csproj", "{E0EAFF82-C514-4827-8F49-F1928EBA8E73}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|ARM.ActiveCfg = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|ARM.Build.0 = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|ARM64.Build.0 = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|x64.ActiveCfg = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|x64.Build.0 = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|x86.ActiveCfg = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|x86.Build.0 = Debug|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|Any CPU.Build.0 = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|ARM.ActiveCfg = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|ARM.Build.0 = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|ARM64.ActiveCfg = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|ARM64.Build.0 = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|x64.ActiveCfg = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|x64.Build.0 = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|x86.ActiveCfg = Release|Any CPU
{F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|x86.Build.0 = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|ARM.Build.0 = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|ARM64.Build.0 = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|x64.ActiveCfg = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|x64.Build.0 = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|x86.ActiveCfg = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|x86.Build.0 = Debug|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|Any CPU.Build.0 = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|ARM.ActiveCfg = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|ARM.Build.0 = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|ARM64.ActiveCfg = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|ARM64.Build.0 = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|x64.ActiveCfg = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|x64.Build.0 = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|x86.ActiveCfg = Release|Any CPU
{8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|x86.Build.0 = Release|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|ARM.ActiveCfg = Debug|ARM
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|ARM.Build.0 = Debug|ARM
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|ARM64.Build.0 = Debug|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x64.ActiveCfg = Debug|x64
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x64.Build.0 = Debug|x64
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x86.ActiveCfg = Debug|x86
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x86.Build.0 = Debug|x86
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|Any CPU.Build.0 = Release|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|ARM.ActiveCfg = Release|ARM
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|ARM.Build.0 = Release|ARM
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|ARM64.ActiveCfg = Release|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|ARM64.Build.0 = Release|Any CPU
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x64.ActiveCfg = Release|x64
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x64.Build.0 = Release|x64
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x86.ActiveCfg = Release|x86
{E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {949E7C1D-8E95-46CF-B659-C6A15678A0D5}
EndGlobalSection
EndGlobal

View File

@ -1,3 +1,5 @@
#if NET5_0_OR_GREATER
using System.IO.Ports;
using System.Text;
using OBD.NET.Communication.EventArgs;
@ -68,4 +70,6 @@ public class SerialConnection : ISerialConnection
public void Write(byte[] data) => _serialPort.Write(data, 0, data.Length);
#endregion
}
}
#endif

View File

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;netstandard1.4</TargetFrameworks>
<LangVersion>10</LangVersion>
<Authors>Darth Affe / Roman Lumetsberger</Authors>
@ -27,7 +27,20 @@
<RootNamespace>OBD.NET</RootNamespace>
<PackageId>OBD.NET</PackageId>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
<DefineConstants>NET5_0;NETFULL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<DefineConstants>NET6_0;NETFULL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD1_4</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols>
@ -42,7 +55,7 @@
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="System.IO.Ports" Version="5.0.1" />
</ItemGroup>

View File

@ -0,0 +1,7 @@
{
"profiles": {
"OBD.NET": {
"commandName": "Project"
}
}
}