diff --git a/Installer-System/Installer-System.aip b/Installer-System/Installer-System.aip index faff957..ce5e982 100644 --- a/Installer-System/Installer-System.aip +++ b/Installer-System/Installer-System.aip @@ -20,10 +20,10 @@ - + - + diff --git a/Installer/Installer.aip b/Installer/Installer.aip index 652bd78..39dbc5d 100644 --- a/Installer/Installer.aip +++ b/Installer/Installer.aip @@ -20,10 +20,10 @@ - + - + diff --git a/README.md b/README.md index 679f0fa..71eaf9f 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,14 @@ ###### A serial terminal that runs as a Windows console application. -Written by [Edward Wright](mailto:fasteddy@thewrightspace.net) (fasteddy516). +Original Written by [Edward Wright](mailto:fasteddy@thewrightspace.net) (fasteddy516). Available at https://github.com/fasteddy516/SimplySerial +I forked it, merged some pull-requests and added some options + +Available at https://github.com/salvathor79/SimplySerial (salvathor79) + # Description SimplySerial is a basic serial terminal that runs as a Windows console application. It provides a quick way to connect to - and communicate with - serial devices through Command Prompt or PowerShell. SimplySerial can be used directly from Command Prompt/PowerShell and should work with most devices that appear in Device Manager as "COMx". It was, however, written specifically for use within a "terminal" window in [Visual Studio Code](https://code.visualstudio.com/) to provide serial communications with devices running [CircuitPython](https://circuitpython.org/). Most of the testing and development of this application was done with this use case in mind. @@ -23,7 +27,7 @@ _The required version of .NET framework is already included in supported Windows # Installation -Download the [latest release](https://github.com/fasteddy516/SimplySerial/releases/latest) of this application in one of three formats: +Download the [latest release](https://github.com/salvathor79/SimplySerial/releases/latest) of this application in one of three formats: `SimplySerial_x.x.x_user_setup.msi` is a windows installer package that puts everything where it needs to go and adds the location of the SimplySerial executable to your `PATH` environment variable, which makes it easily accessible from Command Prompt, PowerShell and Visual Studio Code. Installation is per-user, and does not require Administrative rights to install. **This is the preferred installation method,** _and works well with the "user setup" version of VSCode_. @@ -88,7 +92,7 @@ If you have multiple COM ports, multiple CircuitPython devices connected, or nee `-ec --echo` enable or disable printing typed characters - `-tx --tx_newline` newline chars sent on carriage return (ex. `-tx:CRLF`, `-tx:custom=CustomString`, `--tx_newline:LF`) + `-tx --tx_newline` newline chars sent on carriage return. A sequence of bytes can be used with bytes keyword (ex. `-tx:CRLF`, `-tx:custom="CustomString"`, `--tx_newline:LF`, `--tx:bytes="0xFF0xFF"`, `--tx:bytes="0xFF 0xFF"`, `--tx:bytes="FF FF"`, `--tx:bytes="FFFF"`) `-i, --input` ut configuration file, with newline separated configuration options. eg: `c:COM1`. Note that the prefix `-` and `--` shall be omitted. @@ -125,7 +129,7 @@ If you're directly editing the settings.json, the profile section will look like # Contributing - If you have questions, problems, feature requests, etc. please post them to the [Issues section on GitHub](https://github.com/fasteddy516/SimplySerial/issues). If you would like to contribute, please let me know. I have already put some "enhancement requests" in the GitHub Issues section with some ideas for improvements, most of which were either beyond my limited C#/Windows programming knowledge, or required more time than I had available! + If you have questions, problems, feature requests, etc. please post them to the [Issues section on GitHub](https://github.com/salvathor79/SimplySerial/issues). If you would like to contribute, please let me know. I have already put some "enhancement requests" in the GitHub Issues section with some ideas for improvements, most of which were either beyond my limited C#/Windows programming knowledge, or required more time than I had available! # Acknowledgements diff --git a/SimplySerial/SimplySerial.cs b/SimplySerial/SimplySerial.cs index d8e4d72..7acdac9 100644 --- a/SimplySerial/SimplySerial.cs +++ b/SimplySerial/SimplySerial.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.IO; @@ -15,7 +16,7 @@ namespace SimplySerial { class SimplySerial { - const string version = "0.9.1"; + const string version = "0.9.2"; private const int STD_OUTPUT_HANDLE = -11; private const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004; @@ -303,7 +304,19 @@ namespace SimplySerial } else { - CustomString = ""; + CustomString = String.Empty; + } + } + else if (NewlineTxMode == 5) + { + + if (NewlineTxDict.TryGetValue(NewlineTxMode, out string t)) + { + CustomString = t; + } + else + { + CustomString = String.Empty; } } else @@ -741,8 +754,39 @@ namespace SimplySerial NewlineTxDict.Add(4, argument[1].Substring(argument[1].IndexOf("=") + 1)); NewlineTxMode = 4; } + else if ((argument[1].StartsWith("bytes="))) + { + string temp = argument[1].Substring(argument[1].IndexOf("=") + 1); + + temp = temp.Replace(" ", "").Replace("\"","").Replace("0x", ""); + + if ((temp.Length % 2 != 0) && (temp.Length <= (255 * 2))) + { + ExitProgram(("Invalid format of bytes sequence specified, each byte must be 2 characters long and the maximum number of bytes should be less than 255.\r\nUse bytes with leading or trailing '0'. i.e.: 0D or A0<" + argument[1] + ">"), exitCode: -1); + } + else + { + string plaintext = string.Empty; +; + for (int read_index = 0; read_index <= (temp.Length - 2); read_index += 2) + { + try + { + plaintext += Convert.ToChar(Convert.ToByte(temp.Substring(read_index, 2), 16)); + } + catch + { + ExitProgram(("<"+ temp.Substring(read_index, 2) + "> " + "is an invalid byte value. Use only hexadecimal value with or without leading 0x"), exitCode: -1); + } + + } + + NewlineTxDict.Add(5, plaintext); + NewlineTxMode = 5; + } + } else - ExitProgram(("Invalid newline mode specified (CR | LF | CRLF | CUSTOM=CustomString)\r\n.CustomString should be less than 255 chars.<" + argument[1] + ">"), exitCode: -1); + ExitProgram(("Invalid newline mode specified (CR | LF | CRLF | CUSTOM=CustomString | BYTES=\"Custom sequence of bytes\")\r\n.CustomString should be less than 255 chars or bytes should be less than 255.<" + argument[1] + ">"), exitCode: -1); } // an invalid/incomplete argument was passed else @@ -874,7 +918,9 @@ namespace SimplySerial Console.WriteLine(" -noclear Don't clear the terminal screen on connection."); Console.WriteLine(" -nostatus Block status/title updates from virtual terminal sequences."); Console.WriteLine(" -echo:VAL ON | OFF enable or disable printing typed characters"); - Console.WriteLine(" -tx_newline:VAL CR | LF | CRLF | CUSTOM=CustomString newline chars sent on carriage return."); + Console.WriteLine(" -tx_newline:VAL CR | LF | CRLF | CUSTOM=\"CustomString\" | BYTES=\"custom sequence of bytes\", each byte must be expressed by 2 chars"); + Console.WriteLine(" bytes sequence must be an exadecimal value with or without leading 0x and separated or not by spaces."); + Console.WriteLine(" newline chars sent on carriage return."); Console.WriteLine(" -input Input file whose each line contain an option without '-' infront. eg: com:COM1"); Console.WriteLine("\nPress CTRL-X to exit a running instance of SimplySerial.\n"); }