add skip option
This commit is contained in:
parent
8ff6f6264f
commit
843a85d577
|
@ -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 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 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 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");
|
var fileArgument = new Argument<FileInfo>("file", description: "File to send");
|
||||||
|
|
||||||
|
@ -21,20 +22,21 @@ namespace SendEPROM
|
||||||
portOption,
|
portOption,
|
||||||
baudOption,
|
baudOption,
|
||||||
modeOption,
|
modeOption,
|
||||||
|
skipOption,
|
||||||
fileArgument
|
fileArgument
|
||||||
};
|
};
|
||||||
|
|
||||||
rootCmd.SetHandler(
|
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);
|
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}");
|
Console.WriteLine($"Reading {file.FullName}");
|
||||||
|
@ -54,8 +56,8 @@ namespace SendEPROM
|
||||||
sp.Write(modeBuff, 0, 1);
|
sp.Write(modeBuff, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Sending {buff.Length} bytes");
|
Console.WriteLine($"Sending {buff.Length} bytes, skipping {skip} bytes");
|
||||||
sp.Write(buff, 0, buff.Length);
|
sp.Write(buff, skip, buff.Length - skip);
|
||||||
sp.Close();
|
sp.Close();
|
||||||
Console.WriteLine("Done!");
|
Console.WriteLine("Done!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue