Works with test hardware

This commit is contained in:
Benjamin Höglinger-Stelzer 2022-10-03 17:25:19 +02:00
parent 8d0a29c0b7
commit 4f7a5b3f7b
7 changed files with 39 additions and 106 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ _ReSharper*/
/packages /packages
/.tmp /.tmp
*.DotSettings *.DotSettings
/misc

View File

@ -1,9 +1,9 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.29613.14 VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PInvokeSerialPort", "Nefarius.Peripherals.SerialPort\Nefarius.Peripherals.SerialPort.csproj", "{AEC711A5-AA9B-4127-A82C-C4D8FDA9741A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nefarius.Peripherals.SerialPort", "Nefarius.Peripherals.SerialPort\Nefarius.Peripherals.SerialPort.csproj", "{AEC711A5-AA9B-4127-A82C-C4D8FDA9741A}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99052083-B245-462F-8778-4C94662ABABE}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99052083-B245-462F-8778-4C94662ABABE}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
@ -49,12 +49,14 @@ Global
{928609B4-70AB-4D93-A43E-4BE75C279066}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {928609B4-70AB-4D93-A43E-4BE75C279066}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{928609B4-70AB-4D93-A43E-4BE75C279066}.Release|Mixed Platforms.Build.0 = Release|Any CPU {928609B4-70AB-4D93-A43E-4BE75C279066}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{928609B4-70AB-4D93-A43E-4BE75C279066}.Release|x86.ActiveCfg = Release|Any CPU {928609B4-70AB-4D93-A43E-4BE75C279066}.Release|x86.ActiveCfg = Release|Any CPU
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Any CPU.ActiveCfg = Debug|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Mixed Platforms.Build.0 = Debug|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|Mixed Platforms.Build.0 = Debug|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|x86.ActiveCfg = Debug|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|x86.ActiveCfg = Debug|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|x86.Build.0 = Debug|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Debug|x86.Build.0 = Debug|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Any CPU.ActiveCfg = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Any CPU.Build.0 = Release|Any CPU
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Mixed Platforms.ActiveCfg = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Mixed Platforms.ActiveCfg = Release|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Mixed Platforms.Build.0 = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Mixed Platforms.Build.0 = Release|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|x86.ActiveCfg = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|x86.ActiveCfg = Release|x86

View File

@ -17,9 +17,10 @@
<PackageIconUrl /> <PackageIconUrl />
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Properties\" /> <Compile Remove="Properties\**" />
<EmbeddedResource Remove="Properties\**" />
<None Remove="Properties\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,69 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{76FAB402-7515-4A9B-8605-4FEC0736C78A}</ProjectGuid> <ProjectGuid>{76FAB402-7515-4A9B-8605-4FEC0736C78A}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <TargetFramework>net6</TargetFramework>
<RootNamespace>PInvokeSerialPort.Sample</RootNamespace> <AssemblyTitle>PInvokeSerialPort.Sample</AssemblyTitle>
<AssemblyName>PInvokeSerialPort.Sample</AssemblyName> <Product>PInvokeSerialPort.Sample</Product>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <Copyright>Copyright © 2012</Copyright>
<TargetFrameworkProfile> <OutputPath>bin\$(Configuration)\</OutputPath>
</TargetFrameworkProfile> <LangVersion>latest</LangVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <ProjectReference Include="..\Nefarius.Peripherals.SerialPort\Nefarius.Peripherals.SerialPort.csproj" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nefarius.Peripherals.SerialPort\Nefarius.Peripherals.SerialPort.csproj">
<Project>{AEC711A5-AA9B-4127-A82C-C4D8FDA9741A}</Project>
<Name>PInvokeSerialPort</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.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> </Project>

View File

@ -1,19 +1,23 @@
using System; using System;
using PInvokeSerialPort; using Nefarius.Peripherals.SerialPort;
namespace PInvokeSerialPort.Sample namespace PInvokeSerialPort.Sample;
internal class Program
{ {
class Program private static void Main(string[] args)
{ {
static void Main(string[] args) var serialPort = new SerialPort("com7") { UseRts = HsOutput.Online };
serialPort.DataReceived += x =>
{ {
var serialPort = new SerialPort("com1", 14400); Console.Write($"{x:X2} ");
serialPort.DataReceived += x => Console.Write((char)x); };
serialPort.Open();
while (true) serialPort.Open();
{
serialPort.Write(Console.ReadKey().KeyChar); serialPort.Write("START\r\n");
}
} Console.ReadKey();
} }
} }

View File

@ -2,18 +2,6 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; 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("PInvokeSerialPort.Sample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PInvokeSerialPort.Sample")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // 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 // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
@ -21,16 +9,3 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9628528d-5e4d-4071-aad1-b1f85f3d45d5")] [assembly: Guid("9628528d-5e4d-4071-aad1-b1f85f3d45d5")]
// 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")]

View File

@ -2,6 +2,7 @@
using System.Text; using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading; using System.Threading;
using Nefarius.Peripherals.SerialPort;
namespace PInvokeSerialPort.Test namespace PInvokeSerialPort.Test
{ {