mirror of
https://github.com/fasteddy516/SimplySerial.git
synced 2024-11-24 10:04:35 +00:00
Added option to specify bytes sequence as newline char
This commit is contained in:
parent
dfe8c45bba
commit
2b57b55013
@ -20,10 +20,10 @@
|
|||||||
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/salvathor79/SimplySerial"/>
|
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/salvathor79/SimplySerial"/>
|
||||||
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/salvathor79/SimplySerial/releases"/>
|
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/salvathor79/SimplySerial/releases"/>
|
||||||
<ROW Property="Manufacturer" Value="salvathor79"/>
|
<ROW Property="Manufacturer" Value="salvathor79"/>
|
||||||
<ROW Property="ProductCode" Value="1033:{40C3F1CB-45FD-45CF-A1D7-C3B6EBF3C5A2} " Type="16"/>
|
<ROW Property="ProductCode" Value="1033:{7CD09F76-E917-437B-904D-6C2BC73889F2} " Type="16"/>
|
||||||
<ROW Property="ProductLanguage" Value="1033"/>
|
<ROW Property="ProductLanguage" Value="1033"/>
|
||||||
<ROW Property="ProductName" Value="SimplySerial"/>
|
<ROW Property="ProductName" Value="SimplySerial"/>
|
||||||
<ROW Property="ProductVersion" Value="0.9.1" Options="32"/>
|
<ROW Property="ProductVersion" Value="0.9.2" Options="32"/>
|
||||||
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
|
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
|
||||||
<ROW Property="UpgradeCode" Value="{6A3965D3-95B6-4145-8B3C-6F55E2A16C31}"/>
|
<ROW Property="UpgradeCode" Value="{6A3965D3-95B6-4145-8B3C-6F55E2A16C31}"/>
|
||||||
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
|
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/salvathor79/SimplySerial"/>
|
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/salvathor79/SimplySerial"/>
|
||||||
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/salvathor79/SimplySerial/releases"/>
|
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/salvathor79/SimplySerial/releases"/>
|
||||||
<ROW Property="Manufacturer" Value="salvathor79"/>
|
<ROW Property="Manufacturer" Value="salvathor79"/>
|
||||||
<ROW Property="ProductCode" Value="1033:{16C3C6AD-9E62-4D87-92DB-7AEA301F2B34} " Type="16"/>
|
<ROW Property="ProductCode" Value="1033:{AE8D3CC3-37AB-4B07-9BCC-EC47C40BD39C} " Type="16"/>
|
||||||
<ROW Property="ProductLanguage" Value="1033"/>
|
<ROW Property="ProductLanguage" Value="1033"/>
|
||||||
<ROW Property="ProductName" Value="SimplySerial"/>
|
<ROW Property="ProductName" Value="SimplySerial"/>
|
||||||
<ROW Property="ProductVersion" Value="0.9.1" Options="32"/>
|
<ROW Property="ProductVersion" Value="0.9.2" Options="32"/>
|
||||||
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
|
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
|
||||||
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
|
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
|
||||||
<ROW Property="UpgradeCode" Value="{64061592-EDD5-474E-B846-4CA070788BBE}"/>
|
<ROW Property="UpgradeCode" Value="{64061592-EDD5-474E-B846-4CA070788BBE}"/>
|
||||||
|
12
README.md
12
README.md
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
###### A serial terminal that runs as a Windows console application.
|
###### 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
|
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
|
# 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.
|
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
|
# 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_.
|
`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
|
`-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.
|
`-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
|
# 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
|
# Acknowledgements
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -15,7 +16,7 @@ namespace SimplySerial
|
|||||||
{
|
{
|
||||||
class SimplySerial
|
class SimplySerial
|
||||||
{
|
{
|
||||||
const string version = "0.9.1";
|
const string version = "0.9.2";
|
||||||
|
|
||||||
private const int STD_OUTPUT_HANDLE = -11;
|
private const int STD_OUTPUT_HANDLE = -11;
|
||||||
private const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
|
private const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
|
||||||
@ -303,7 +304,19 @@ namespace SimplySerial
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CustomString = "";
|
CustomString = String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (NewlineTxMode == 5)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (NewlineTxDict.TryGetValue(NewlineTxMode, out string t))
|
||||||
|
{
|
||||||
|
CustomString = t;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CustomString = String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -741,8 +754,39 @@ namespace SimplySerial
|
|||||||
NewlineTxDict.Add(4, argument[1].Substring(argument[1].IndexOf("=") + 1));
|
NewlineTxDict.Add(4, argument[1].Substring(argument[1].IndexOf("=") + 1));
|
||||||
NewlineTxMode = 4;
|
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
|
else
|
||||||
ExitProgram(("Invalid newline mode specified (CR | LF | CRLF | CUSTOM=CustomString)\r\n.CustomString should be less than 255 chars.<" + argument[1] + ">"), exitCode: -1);
|
{
|
||||||
|
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 | 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
|
// an invalid/incomplete argument was passed
|
||||||
else
|
else
|
||||||
@ -874,7 +918,9 @@ namespace SimplySerial
|
|||||||
Console.WriteLine(" -noclear Don't clear the terminal screen on connection.");
|
Console.WriteLine(" -noclear Don't clear the terminal screen on connection.");
|
||||||
Console.WriteLine(" -nostatus Block status/title updates from virtual terminal sequences.");
|
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(" -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(" -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");
|
Console.WriteLine("\nPress CTRL-X to exit a running instance of SimplySerial.\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user