From 7e9a8b821653dc31d911025620b2793f78bf6066 Mon Sep 17 00:00:00 2001 From: Brian Peek <2321675+BrianPeek@users.noreply.github.com> Date: Tue, 27 Sep 2022 23:06:59 -0700 Subject: [PATCH] oops --- src/SendEPROM | 1 - src/SendEPROM/App.config | 7 ++++ src/SendEPROM/Program.cs | 61 ++++++++++++++++++++++++++++++++++ src/SendEPROM/SendEPROM.csproj | 15 +++++++++ src/SendEPROM/SendEPROM.sln | 25 ++++++++++++++ 5 files changed, 108 insertions(+), 1 deletion(-) delete mode 160000 src/SendEPROM create mode 100644 src/SendEPROM/App.config create mode 100644 src/SendEPROM/Program.cs create mode 100644 src/SendEPROM/SendEPROM.csproj create mode 100644 src/SendEPROM/SendEPROM.sln diff --git a/src/SendEPROM b/src/SendEPROM deleted file mode 160000 index 852bcbb..0000000 --- a/src/SendEPROM +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 852bcbb35134d515fa85c28a36daf8a93beeb717 diff --git a/src/SendEPROM/App.config b/src/SendEPROM/App.config new file mode 100644 index 0000000..b8db93d --- /dev/null +++ b/src/SendEPROM/App.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/SendEPROM/Program.cs b/src/SendEPROM/Program.cs new file mode 100644 index 0000000..1c3880a --- /dev/null +++ b/src/SendEPROM/Program.cs @@ -0,0 +1,61 @@ +using System.IO.Ports; +using System.Configuration; + +namespace SendEPROM +{ + public class Program + { + public static int Main(string[] args) + { + if(args.Length != 3 && args.Length != 2) + return Usage(); + + string port = ConfigurationManager.AppSettings["port"]; + int baud = int.Parse(ConfigurationManager.AppSettings["baud"]); + string file = string.Empty; + byte mode = 0; + + if(args.Length == 2) + { + mode = byte.Parse(args[0]); + file = args[1]; + } + else if(args.Length == 3) + { + port = args[0]; + baud = int.Parse(args[1]); + file = args[2]; + } + + Console.WriteLine($"Reading {file}"); + byte[] buff = File.ReadAllBytes(file); + + Console.WriteLine($"Opening {port} at {baud}"); + var sp = new SerialPort(port) + { + BaudRate = baud + }; + sp.Open(); + + if(mode != 0) + { + Console.WriteLine($"Sending mode {mode}"); + byte[] modeBuff = { mode }; + sp.Write(modeBuff, 0, 1); + } + + Console.WriteLine($"Sending {buff.Length} bytes"); + sp.Write(buff, 0, buff.Length); + sp.Close(); + Console.WriteLine("Done!"); + + return 0; + } + + private static int Usage() + { + Console.WriteLine("Usage: SendEPROM [COMX] [baud] [EPROM mode] filename"); + return -1; + } + } +} \ No newline at end of file diff --git a/src/SendEPROM/SendEPROM.csproj b/src/SendEPROM/SendEPROM.csproj new file mode 100644 index 0000000..942af57 --- /dev/null +++ b/src/SendEPROM/SendEPROM.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + disable + + + + + + + + diff --git a/src/SendEPROM/SendEPROM.sln b/src/SendEPROM/SendEPROM.sln new file mode 100644 index 0000000..1513a9e --- /dev/null +++ b/src/SendEPROM/SendEPROM.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32014.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendEPROM", "SendEPROM.csproj", "{1B795DA1-604C-44C9-8306-BE3E84743BA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C5F74E1C-5293-43CD-9F71-72BC2BEB69B5} + EndGlobalSection +EndGlobal