From 8e6956034f77ea126f7e5b6955df1065a0cd8b70 Mon Sep 17 00:00:00 2001 From: Brian Peek <2321675+BrianPeek@users.noreply.github.com> Date: Sat, 1 Oct 2022 16:15:10 -0700 Subject: [PATCH] Oops, needs FullName, not Name --- .vscode/tasks.json | 12 ++++++++++- src/SendEPROM/Program.cs | 39 +++++++++++++++++++--------------- src/SendEPROM/SendEPROM.csproj | 1 - 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index eb7fd53..54db57a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,4 +1,14 @@ { "version": "2.0.0", - "tasks": [] + "tasks": [ + { + "type": "PlatformIO", + "task": "Build", + "problemMatcher": [ + "$platformio" + ], + "group": "build", + "label": "PlatformIO: Build" + } + ] } \ No newline at end of file diff --git a/src/SendEPROM/Program.cs b/src/SendEPROM/Program.cs index 23f5fa7..a805233 100644 --- a/src/SendEPROM/Program.cs +++ b/src/SendEPROM/Program.cs @@ -1,5 +1,8 @@ -using System.IO.Ports; +using System; +using System.IO; +using System.IO.Ports; using System.CommandLine; +using System.Threading.Tasks; namespace SendEPROM { @@ -7,24 +10,26 @@ namespace SendEPROM { public static async Task Main(string[] args) { - var rootCmd = new RootCommand("Send a binary image to the EPROM emulator"); - - 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 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 fileArgument = new Argument("file", description: "File to send"); - rootCmd.AddOption(portOption); - rootCmd.AddOption(baudOption); - rootCmd.AddOption(modeOption); - rootCmd.AddArgument(fileArgument); - - rootCmd.SetHandler((port, baud, mode, file) => + var rootCmd = new RootCommand("Send a binary image to the EPROM emulator") { - SendData(port, baud, mode, file); - }, - portOption, baudOption, modeOption, fileArgument); + portOption, + baudOption, + modeOption, + fileArgument + }; + + rootCmd.SetHandler( + (port, baud, mode, file) => + { + SendData(port, baud, mode, file); + }, + portOption, baudOption, modeOption, fileArgument); return await rootCmd.InvokeAsync(args); } @@ -32,8 +37,8 @@ namespace SendEPROM static void SendData(string port, int baud, byte mode, FileInfo file) { - Console.WriteLine($"Reading {file.Name}"); - byte[] buff = File.ReadAllBytes(file.Name); + Console.WriteLine($"Reading {file.FullName}"); + byte[] buff = File.ReadAllBytes(file.FullName); Console.WriteLine($"Opening {port} at {baud}"); var sp = new SerialPort(port) diff --git a/src/SendEPROM/SendEPROM.csproj b/src/SendEPROM/SendEPROM.csproj index a933b14..08ef6d4 100644 --- a/src/SendEPROM/SendEPROM.csproj +++ b/src/SendEPROM/SendEPROM.csproj @@ -3,7 +3,6 @@ Exe net6.0 - enable disable