From 5c4c4c2cd2c7fb60f0820d1fc0cd5a66a802d380 Mon Sep 17 00:00:00 2001 From: Roar Fredriksen Date: Thu, 14 Sep 2017 18:02:48 +0200 Subject: [PATCH] Added HanDebugger --- Code/HanDebugger/.gitignore | 253 ++++++++++++++++++ Code/HanDebugger/HanDebugger.sln | 22 ++ Code/HanDebugger/HanDebugger/App.config | 6 + .../HanDebugger/HanDebugger.csproj | 60 +++++ Code/HanDebugger/HanDebugger/Program.cs | 63 +++++ .../HanDebugger/Properties/AssemblyInfo.cs | 36 +++ 6 files changed, 440 insertions(+) create mode 100644 Code/HanDebugger/.gitignore create mode 100644 Code/HanDebugger/HanDebugger.sln create mode 100644 Code/HanDebugger/HanDebugger/App.config create mode 100644 Code/HanDebugger/HanDebugger/HanDebugger.csproj create mode 100644 Code/HanDebugger/HanDebugger/Program.cs create mode 100644 Code/HanDebugger/HanDebugger/Properties/AssemblyInfo.cs diff --git a/Code/HanDebugger/.gitignore b/Code/HanDebugger/.gitignore new file mode 100644 index 00000000..673e20aa --- /dev/null +++ b/Code/HanDebugger/.gitignore @@ -0,0 +1,253 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml +appsettings.secrets.json diff --git a/Code/HanDebugger/HanDebugger.sln b/Code/HanDebugger/HanDebugger.sln new file mode 100644 index 00000000..6d00017e --- /dev/null +++ b/Code/HanDebugger/HanDebugger.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HanDebugger", "HanDebugger\HanDebugger.csproj", "{EB8BDAFE-8991-4E9E-9E7E-F9BE61EBC122}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EB8BDAFE-8991-4E9E-9E7E-F9BE61EBC122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB8BDAFE-8991-4E9E-9E7E-F9BE61EBC122}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB8BDAFE-8991-4E9E-9E7E-F9BE61EBC122}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB8BDAFE-8991-4E9E-9E7E-F9BE61EBC122}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Code/HanDebugger/HanDebugger/App.config b/Code/HanDebugger/HanDebugger/App.config new file mode 100644 index 00000000..88fa4027 --- /dev/null +++ b/Code/HanDebugger/HanDebugger/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Code/HanDebugger/HanDebugger/HanDebugger.csproj b/Code/HanDebugger/HanDebugger/HanDebugger.csproj new file mode 100644 index 00000000..c95b83f6 --- /dev/null +++ b/Code/HanDebugger/HanDebugger/HanDebugger.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {EB8BDAFE-8991-4E9E-9E7E-F9BE61EBC122} + Exe + Properties + HanDebugger + HanDebugger + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/HanDebugger/HanDebugger/Program.cs b/Code/HanDebugger/HanDebugger/Program.cs new file mode 100644 index 00000000..5b938494 --- /dev/null +++ b/Code/HanDebugger/HanDebugger/Program.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.IO.Ports; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace HanDebugger +{ + class Program + { + static List gBuffer = new List(); + + static void Main(string[] args) + { + SerialPort vPort = new SerialPort("COM3", 2400, Parity.Even, 8, StopBits.One); + vPort.DataReceived += VPort_DataReceived; + vPort.Open(); + + while (true) + Thread.Sleep(100); + } + + private static void VPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + var vPort = sender as SerialPort; + byte[] vBuffer = new byte[1000]; + int vBytesRead = vPort.Read(vBuffer, 0, vBuffer.Length); + for (int i = 0; i < vBytesRead; i++) + { + gBuffer.Add(vBuffer[i]); + + // If we're catching a '7E' and it's not the beginning, it must be the end + if (gBuffer.Count > 1 && vBuffer[i] == 0x7e) + WriteAndEmptyBuffer(); + } + } + + private static void WriteAndEmptyBuffer() + { + Console.WriteLine(); + Console.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} - Received {gBuffer.Count} (0x{gBuffer.Count:X2}) bytes]"); + + int j = 0; + foreach (var vByte in gBuffer) + { + Console.Write(string.Format("{0:X2} ", (int)vByte)); + + if (++j % 8 == 0) + Console.Write(" "); + + if (j % 24 == 0) + Console.WriteLine(); + } + + Console.WriteLine(); + Console.WriteLine(); + + gBuffer.Clear(); + } + } +} diff --git a/Code/HanDebugger/HanDebugger/Properties/AssemblyInfo.cs b/Code/HanDebugger/HanDebugger/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a77b488c --- /dev/null +++ b/Code/HanDebugger/HanDebugger/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("HanDebugger")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HanDebugger")] +[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("eb8bdafe-8991-4e9e-9e7e-f9be61ebc122")] + +// 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")]