From 843a85d5777e7ca23f2444ebad4a8aca235c2179 Mon Sep 17 00:00:00 2001 From: Brian Peek <2321675+BrianPeek@users.noreply.github.com> Date: Wed, 21 Dec 2022 20:42:05 -0700 Subject: [PATCH] add skip option --- src/SendEPROM/Program.cs | 14 ++++++++------ src/SendEPROM/SendEPROM.csproj | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SendEPROM/Program.cs b/src/SendEPROM/Program.cs index a805233..7ffea4c 100644 --- a/src/SendEPROM/Program.cs +++ b/src/SendEPROM/Program.cs @@ -13,6 +13,7 @@ namespace SendEPROM var portOption = new Option(new string[] {"--port", "-p" }, description: "COM port on which to send the file", getDefaultValue: () => "COM3"); var baudOption = new Option (new string[] {"--baud", "-b" }, description: "Baud rate at which to send", getDefaultValue: () => 115200); var modeOption = new Option (new string[] {"--mode", "-m" }, description: "EPROM mode (1 = 27C256, 2 = 27C020)", getDefaultValue: () => 2); + var skipOption = new Option (new string[] {"--skip", "-s" }, description: "Skip N bytes at start of file", getDefaultValue: () => 0); var fileArgument = new Argument("file", description: "File to send"); @@ -21,20 +22,21 @@ namespace SendEPROM portOption, baudOption, modeOption, + skipOption, fileArgument }; rootCmd.SetHandler( - (port, baud, mode, file) => + (port, baud, mode, skip, file) => { - SendData(port, baud, mode, file); + SendData(port, baud, mode, skip, file); }, - portOption, baudOption, modeOption, fileArgument); + portOption, baudOption, modeOption, skipOption, fileArgument); return await rootCmd.InvokeAsync(args); } - static void SendData(string port, int baud, byte mode, FileInfo file) + static void SendData(string port, int baud, byte mode, int skip, FileInfo file) { Console.WriteLine($"Reading {file.FullName}"); @@ -54,8 +56,8 @@ namespace SendEPROM sp.Write(modeBuff, 0, 1); } - Console.WriteLine($"Sending {buff.Length} bytes"); - sp.Write(buff, 0, buff.Length); + Console.WriteLine($"Sending {buff.Length} bytes, skipping {skip} bytes"); + sp.Write(buff, skip, buff.Length - skip); sp.Close(); Console.WriteLine("Done!"); } diff --git a/src/SendEPROM/SendEPROM.csproj b/src/SendEPROM/SendEPROM.csproj index 08ef6d4..63c3675 100644 --- a/src/SendEPROM/SendEPROM.csproj +++ b/src/SendEPROM/SendEPROM.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 disable