add skip option

This commit is contained in:
Brian Peek 2022-12-21 20:42:05 -07:00
parent 8ff6f6264f
commit 843a85d577
2 changed files with 9 additions and 7 deletions

View File

@ -13,6 +13,7 @@ namespace SendEPROM
var portOption = new Option<string>(new string[] {"--port", "-p" }, description: "COM port on which to send the file", getDefaultValue: () => "COM3");
var baudOption = new Option<int> (new string[] {"--baud", "-b" }, description: "Baud rate at which to send", getDefaultValue: () => 115200);
var modeOption = new Option<byte> (new string[] {"--mode", "-m" }, description: "EPROM mode (1 = 27C256, 2 = 27C020)", getDefaultValue: () => 2);
var skipOption = new Option<int> (new string[] {"--skip", "-s" }, description: "Skip N bytes at start of file", getDefaultValue: () => 0);
var fileArgument = new Argument<FileInfo>("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!");
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>disable</Nullable>
</PropertyGroup>