Added help message

This commit is contained in:
Edward Wright 2019-06-01 20:03:50 -04:00
parent 3517c61f09
commit ce943616d9
3 changed files with 93 additions and 10 deletions

View File

@ -25,12 +25,14 @@ namespace SimplySerial
ProcessArguments(args); ProcessArguments(args);
// set up the serial port // set up the serial port
serialPort = new SerialPort(port, baud, parity, dataBits, stopBits); 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! Handshake = Handshake.None, // we don't need to support any handshaking at this point
serialPort.WriteTimeout = 250; // small delay - if we go too small on this it causes System.IO semaphore timeout exceptions ReadTimeout = 1, // minimal timeout - we don't want to wait forever for data that may not be coming!
serialPort.DtrEnable = true; // without this we don't ever receive any data WriteTimeout = 250, // small delay - if we go too small on this it causes System.IO semaphore timeout exceptions
serialPort.RtsEnable = true; // without this we don't ever receive any data 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 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 // attempt to open the serial port, terminate on error
@ -132,7 +134,7 @@ namespace SimplySerial
// help // help
if (argument[0].StartsWith("h") || argument[0].StartsWith("?")) if (argument[0].StartsWith("h") || argument[0].StartsWith("?"))
{ {
Console.WriteLine("Sorry, you're on your own."); ShowHelp();
ExitProgram(silent: true); ExitProgram(silent: true);
} }
@ -253,6 +255,31 @@ namespace SimplySerial
} }
/// <summary>
/// Displays help information about this application and its command-line arguments
/// </summary>
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.");
}
/// <summary> /// <summary>
/// Writes the specified exit message to the console, then waits for user to press a key before halting program execution. /// Writes the specified exit message to the console, then waits for user to press a key before halting program execution.
/// </summary> /// </summary>

View File

@ -7,11 +7,26 @@
<ProjectGuid>{3C7DB929-519C-44A3-A68F-2646CC595CAE}</ProjectGuid> <ProjectGuid>{3C7DB929-519C-44A3-A68F-2646CC595CAE}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>SimplySerial</RootNamespace> <RootNamespace>SimplySerial</RootNamespace>
<AssemblyName>SimplySerial</AssemblyName> <AssemblyName>ss</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -22,6 +37,8 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -32,6 +49,27 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -49,5 +87,17 @@
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,20 +1,26 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.28307.645 VisualStudioVersion = 16.0.28922.388
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplySerial", "SimplySerial.csproj", "{3C7DB929-519C-44A3-A68F-2646CC595CAE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplySerial", "SimplySerial.csproj", "{3C7DB929-519C-44A3-A68F-2646CC595CAE}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C7DB929-519C-44A3-A68F-2646CC595CAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {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|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.ActiveCfg = Release|Any CPU
{3C7DB929-519C-44A3-A68F-2646CC595CAE}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE