From ce943616d98ed33c30e2984d66ae34a19d89ca6d Mon Sep 17 00:00:00 2001 From: Edward Wright Date: Sat, 1 Jun 2019 20:03:50 -0400 Subject: [PATCH] Added help message --- SimplySerial/SimplySerial.cs | 41 ++++++++++++++++++++----- SimplySerial/SimplySerial.csproj | 52 +++++++++++++++++++++++++++++++- SimplySerial/SimplySerial.sln | 10 ++++-- 3 files changed, 93 insertions(+), 10 deletions(-) diff --git a/SimplySerial/SimplySerial.cs b/SimplySerial/SimplySerial.cs index 6da22d3..a60f94e 100644 --- a/SimplySerial/SimplySerial.cs +++ b/SimplySerial/SimplySerial.cs @@ -25,12 +25,14 @@ namespace SimplySerial ProcessArguments(args); // set up the serial port - serialPort = new SerialPort(port, baud, parity, dataBits, stopBits); - serialPort.Handshake = Handshake.None; // we don't need to support any handshaking at this point - serialPort.ReadTimeout = 1; // minimal timeout - we don't want to wait forever for data that may not be coming! - serialPort.WriteTimeout = 250; // small delay - if we go too small on this it causes System.IO semaphore timeout exceptions - serialPort.DtrEnable = true; // without this we don't ever receive any data - serialPort.RtsEnable = true; // without this we don't ever receive any data + serialPort = new SerialPort(port, baud, parity, dataBits, stopBits) + { + Handshake = Handshake.None, // we don't need to support any handshaking at this point + ReadTimeout = 1, // minimal timeout - we don't want to wait forever for data that may not be coming! + WriteTimeout = 250, // small delay - if we go too small on this it causes System.IO semaphore timeout exceptions + DtrEnable = true, // without this we don't ever receive any data + RtsEnable = true // without this we don't ever receive any data + }; string received = string.Empty; // this is where data read from the serial port will be temporarily stored // attempt to open the serial port, terminate on error @@ -132,7 +134,7 @@ namespace SimplySerial // help if (argument[0].StartsWith("h") || argument[0].StartsWith("?")) { - Console.WriteLine("Sorry, you're on your own."); + ShowHelp(); ExitProgram(silent: true); } @@ -253,6 +255,31 @@ namespace SimplySerial } + /// + /// Displays help information about this application and its command-line arguments + /// + static void ShowHelp() + { + Console.WriteLine("\nUsage: ss.exe [-help] [-com:PORT] [-baud:RATE] [-parity:PARITY] [-databits:VALUE]"); + Console.WriteLine(" [-stopbits:VALUE][-quiet][-nowait]\n"); + Console.WriteLine("Barebones serial terminal for IoT device programming in general, and working with"); + Console.WriteLine("CircuitPython devices specifically! With no command-line arguments specified,"); + Console.WriteLine("SimplySerial will attempt to connect to the first available serial (COM) port at"); + Console.WriteLine("9600 baud, no parity, 8 data bits and 1 stop bit.\n"); + Console.WriteLine("Optional arguments:"); + Console.WriteLine(" -help Display this help message"); + Console.WriteLine(" -com:PORT COM port number (i.e. 1 for COM1, 22 for COM22, etc.)"); + Console.WriteLine(" -baud:RATE 1200 | 2400 | 4800 | 7200 | 9600 | 14400 | 19200 | 38400 |"); + Console.WriteLine(" 57600 | 115200"); + Console.WriteLine(" -parity:PARITY NONE | EVEN | ODD | MARK | SPACE"); + Console.WriteLine(" -databits:VALUE 4 | 5 | | 7 | 8"); + Console.WriteLine(" -stopbits:VALUE 0 | 1 | 1.5 | 2"); + Console.WriteLine(" -quiet don't print any application messages/errors to console"); + Console.WriteLine(" -nowait don't wait for user input (i.e. 'press any key to exit')\n"); + Console.WriteLine(" Press CTRL-X to exit a running instance of SimplySerial."); + } + + /// /// Writes the specified exit message to the console, then waits for user to press a key before halting program execution. /// diff --git a/SimplySerial/SimplySerial.csproj b/SimplySerial/SimplySerial.csproj index d41e963..dce864c 100644 --- a/SimplySerial/SimplySerial.csproj +++ b/SimplySerial/SimplySerial.csproj @@ -7,11 +7,26 @@ {3C7DB929-519C-44A3-A68F-2646CC595CAE} Exe SimplySerial - SimplySerial + ss v4.6.1 512 true true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -22,6 +37,8 @@ DEBUG;TRACE prompt 4 + false + false AnyCPU @@ -32,6 +49,27 @@ prompt 4 + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + false + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + @@ -49,5 +87,17 @@ + + + False + Microsoft .NET Framework 4.6.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/SimplySerial/SimplySerial.sln b/SimplySerial/SimplySerial.sln index 90c954b..86f521b 100644 --- a/SimplySerial/SimplySerial.sln +++ b/SimplySerial/SimplySerial.sln @@ -1,20 +1,26 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.645 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28922.388 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplySerial", "SimplySerial.csproj", "{3C7DB929-519C-44A3-A68F-2646CC595CAE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Debug|x86.ActiveCfg = Debug|x86 + {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Debug|x86.Build.0 = Debug|x86 {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Release|Any CPU.ActiveCfg = Release|Any CPU {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Release|Any CPU.Build.0 = Release|Any CPU + {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Release|x86.ActiveCfg = Release|x86 + {3C7DB929-519C-44A3-A68F-2646CC595CAE}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE