Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions HIDInterface.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.30501.0
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "USBInterface", "USBInterface\USBInterface.csproj", "{30432D4A-0128-48E7-ADCD-249D70323611}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "USBInterface", "USBInterface\USBInterface.csproj", "{30432D4A-0128-48E7-ADCD-249D70323611}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "USBInterfaceTest", "TestUSBInterface\USBInterfaceTest.csproj", "{E69C9EE3-BCA8-4E5D-8EFA-7EBD75B1087A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUSBInterface", "TestUSBInterface\TestUSBInterface.csproj", "{E69C9EE3-BCA8-4E5D-8EFA-7EBD75B1087A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -25,4 +25,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FBCD496A-267D-40A5-8C67-F452E0F47DBD}
EndGlobalSection
EndGlobal
52 changes: 9 additions & 43 deletions TestUSBInterface/Program.cs
Original file line number Diff line number Diff line change
@@ -1,65 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using USBInterface;

namespace TestUSBInterface
{
class Program
{

public static void handle(object s, USBInterface.ReportEventArgs a)
public static void Handle(object s, ReportEventArgs a)
{
Console.WriteLine(string.Join(", ", a.Data));
}

public static void enter(object s, EventArgs a)
public static void Enter(object s, DeviceScanner.DeviceArrivedArgs deviceArrivedArgs)
{
Console.WriteLine("device arrived");
Console.WriteLine($"Device arrived - {deviceArrivedArgs.Path}");
}
public static void exit(object s, EventArgs a)
public static void Exit(object s, DeviceScanner.DeviceRemovedArgs deviceRemovedArgs)
{
Console.WriteLine("device removed");
Console.WriteLine($"Device removed - {deviceRemovedArgs.Path}");
}

static void Main(string[] args)
{
// setup a scanner before hand
DeviceScanner scanner = new DeviceScanner(0x4d8, 0x3f);
scanner.DeviceArrived += enter;
scanner.DeviceRemoved += exit;
var scanner = new DeviceScanner(0x20A0, 0x4241);
scanner.DeviceArrived += Enter;
scanner.DeviceRemoved += Exit;
scanner.StartAsyncScan();
Console.WriteLine("asd");

// this should probably happen in enter() function
try
{
// this can all happen inside a using(...) statement
USBDevice dev = new USBDevice(0x4d8, 0x3f, null, false, 31);

Console.WriteLine(dev.Description());

// add handle for data read
dev.InputReportArrivedEvent += handle;
// after adding the handle start reading
dev.StartAsyncRead();
// can add more handles at any time
dev.InputReportArrivedEvent += handle;

// write some data
byte[] data = new byte[32];
data[0] = 0x00;
data[1] = 0x23;
dev.Write(data);

dev.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Scanning");
Console.ReadKey();
}
}
Expand Down
36 changes: 0 additions & 36 deletions TestUSBInterface/Properties/AssemblyInfo.cs

This file was deleted.

11 changes: 11 additions & 0 deletions TestUSBInterface/TestUSBInterface.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType>
<PlatformTarget>x86</PlatformTarget>
<RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\USBInterface\USBInterface.csproj" />
</ItemGroup>
</Project>
64 changes: 0 additions & 64 deletions TestUSBInterface/USBInterfaceTest.csproj

This file was deleted.

7 changes: 1 addition & 6 deletions USBInterface/ArrayHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace USBInterface
namespace USBInterface
{
public class ArrayHelpers
{
Expand Down
Loading