Oops, needs FullName, not Name

This commit is contained in:
Brian Peek 2022-10-01 16:15:10 -07:00
parent 25c90418b7
commit 8e6956034f
3 changed files with 33 additions and 19 deletions

12
.vscode/tasks.json vendored
View File

@ -1,4 +1,14 @@
{ {
"version": "2.0.0", "version": "2.0.0",
"tasks": [] "tasks": [
{
"type": "PlatformIO",
"task": "Build",
"problemMatcher": [
"$platformio"
],
"group": "build",
"label": "PlatformIO: Build"
}
]
} }

View File

@ -1,5 +1,8 @@
using System.IO.Ports; using System;
using System.IO;
using System.IO.Ports;
using System.CommandLine; using System.CommandLine;
using System.Threading.Tasks;
namespace SendEPROM namespace SendEPROM
{ {
@ -7,24 +10,26 @@ namespace SendEPROM
{ {
public static async Task<int> Main(string[] args) public static async Task<int> Main(string[] args)
{ {
var rootCmd = new RootCommand("Send a binary image to the EPROM emulator"); 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 portOption = new Option<string> (new string[] {"--port", "-p" }, description: "COM port on which to send the file", getDefaultValue: () => "COM3"); var modeOption = new Option<byte> (new string[] {"--mode", "-m" }, description: "EPROM mode (1 = 27C256, 2 = 27C020)", getDefaultValue: () => 2);
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 fileArgument = new Argument<FileInfo>("file", description: "File to send"); var fileArgument = new Argument<FileInfo>("file", description: "File to send");
rootCmd.AddOption(portOption); var rootCmd = new RootCommand("Send a binary image to the EPROM emulator")
rootCmd.AddOption(baudOption);
rootCmd.AddOption(modeOption);
rootCmd.AddArgument(fileArgument);
rootCmd.SetHandler((port, baud, mode, file) =>
{ {
SendData(port, baud, mode, file); portOption,
}, baudOption,
portOption, baudOption, modeOption, fileArgument); modeOption,
fileArgument
};
rootCmd.SetHandler(
(port, baud, mode, file) =>
{
SendData(port, baud, mode, file);
},
portOption, baudOption, modeOption, fileArgument);
return await rootCmd.InvokeAsync(args); return await rootCmd.InvokeAsync(args);
} }
@ -32,8 +37,8 @@ namespace SendEPROM
static void SendData(string port, int baud, byte mode, FileInfo file) static void SendData(string port, int baud, byte mode, FileInfo file)
{ {
Console.WriteLine($"Reading {file.Name}"); Console.WriteLine($"Reading {file.FullName}");
byte[] buff = File.ReadAllBytes(file.Name); byte[] buff = File.ReadAllBytes(file.FullName);
Console.WriteLine($"Opening {port} at {baud}"); Console.WriteLine($"Opening {port} at {baud}");
var sp = new SerialPort(port) var sp = new SerialPort(port)

View File

@ -3,7 +3,6 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
</PropertyGroup> </PropertyGroup>