Code Monkey home page Code Monkey logo

simplecom's Introduction

SimpleCom CodeQL Unit test OpenSSF Scorecard

Console app for serial connection.

How to use

  1. Conenct serial adaptor to your PC
  2. Start SimpleCom.exe
  3. Setup serial console
    • If you start SimpleCom without any command line options, use dialog to configure
      • > SimpleCom.exe
    • You can configure serial port with command line, then dialog would not be shown
      • > SimpleCom.exe <options> COM[N]
      • COM[N] is mandatory to specify serial port
  4. Operate target device via the console
  5. Press F1 to leave its serial session and to finish SimpleCom

Command line options

Option Default Description
--show-dialog false Show setup dialog even if command line arguments are passed.
--wait-serial-device [seconds] 0 (disable) Wait specified seconds for serial devices are available.
--utf8 false Use UTF-8 code page on SimpleCom console.
--tty-resizer false Use TTY resizer. See README.md in TTY resizer.
--baud-rate [num] 115200 Baud rate
--byte-size [num] 8 Byte size
--parity [val] none Set one of following values as a parity:
  • none
  • odd
  • even
  • mark
  • space
--stop-bits [val] 1 Set one of following values as a stop bits:
  • 1
  • 1.5
  • 2
--flow-control [val] none Set one of following values as a flow control:
  • none
  • hardware
  • software
--auto-reconnect false Reconnect to peripheral automatically when serial session is disconnected.
--auto-reconnect-pause [num] 3 Pause time in seconds before reconnecting to peripheral.
--auto-reconnect-timeout [num] 120 Reconnect timeout
--log-file [logfile] <none> Log serial communication to file
--stdin-logging false Enable stdin logging

⚠️Possible to be logged each chars duplicately due to echo back from the console when this option is set, and also secrets (e.g. passphrase) typed into the console will be logged even if it is not shown on the console.
--help - Show help message

How to build

Use SimpleCom.sln on your Visual Studio.
I confirmed x64 build on VS 2019.

Distribution package

You can get distribution package when you do release build.

MSI installer installes SimpleCom.exe and README.md (and also custom action assembly). It will deploy JSON fragment for SimpleCom into %ProgramData% or %LocalAppData% (it depends on install user choice). So the use can use SimpleCom without any configuration (as following) on Windows Terminal.

How to use on Windows Terminal

You can use fragments.json to add SimpleCom to your Windows Terminal.
For example, run following commands to add SimpleCom for all users.

PS > mkdir "C:\ProgramData\Microsoft\Windows Terminal\Fragments\SimpleCom"
PS > cp C:\Path\To\fragment.json "C:\ProgramData\Microsoft\Windows Terminal\Fragments\SimpleCom"

Please see Applications installed from the web in Microsoft Docs.

Notes

  • SimpleCom sends / receives VT100 escape sequences. So the serial device to connect via SimpleCom needs to support VT100 or compatible shell.
  • F1 key is hooked by SimpleCom, so escase sequence of F1 (ESC O P) would not be propagated.
  • SimpleCom supports ANSI chars only, so it would not work if multibyte chars (e.g. CJK chars) are given.
  • Run resize provided by xterm if you want to align VT size of Linux box with your console window.

License

GNU General Public License v2.0

simplecom's People

Contributors

dependabot[bot] avatar ngbrown avatar oosl avatar yasuenag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simplecom's Issues

High CPU usage

I started using SimpleCom in order to connect to my serial devices, and I've gotta say that it's really cool to be able to use it inside Windows Terminal.
The only problem I found is that it's using a lot of my CPU and I've no idea if it's a widespread issue.

Slashes in connection setup show as yen sign (¥)

Screenshot - 2021-04-05_16-21-17

Once connected, the title of the console window shows the slashes:

Screenshot - 2021-04-05_16-23-04

I think the cause is the MS UI Gothic font is a Japanese only font, and not unicode. Setting the font to something like MS Shell Dlg might work better?

Or is yen sign separators normal for separating paths in Japan?

F1 doesn't close program

The instructions in the readme were "Press F1 to leave its serial session and to finish SimpleCom". When F1 is pressed, a dialog is displayed prompting to leave the serial session. If "Yes" is selected, the program does not close and F1 no longer does anything.

The com port is not fully closed because characters can still be received, they just don't seem to be able to be sent.

Set serial port timeout to avoid high CPU usage

@ngbrown has suggested me in #2 that we should call SetCommTimeouts() to avoid high CPU usage. I think we need to set 0 to ReadIntervalTimeout, but I cannot evaluate it because I cannot reproduce the problem (high CPU usage) on my environment (Windows 10 + USB serial converter + Raspberry Pi 4 (Raspberry Pi OS AAArch64)). So I need the help.

can‘t use the arrow key

First of all, thank you for your work so that I can connect to the serial port in the Windows terminal!
But when using the serial port, I often need to use the arrow keys in vim or use it to find the first few commands, I hope you can fix this problem to make it better. thanks again.

Lack of error handlings

As @ngbrown pointed in #2, I've elided some error handlings, but it should be handled.
We need to add it for the following at least:

Build error on VS2022

It was reported in #19

I try build by myself with vs 2022, but its failure, here is error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2039	'contains': is not a member of 'std::map<TString,TString,std::less<TString>,std::allocator<std::pair<const TString,TString>>>'	SimpleCom	~\SimpleCom\SimpleCom\SerialDeviceScanner.cpp	105	

Accept command line parameters

It would be good to accept some command line parameters and connect straight away. Accept COM port number and baud rate directly at command line, and don't display dialog when parameters are passed.

Since most COM ports are now provided by USB devices, it may also be good to accept the USB Device ID in place of the COM port number. Something in the format of FTDIBUS\VID_0403+PID_6001+AH063JZ9A\0000. Provide another command option that lists all the COM ports and their associated USB Device ID.

Can't use arrows after last Microsoft Terminal update

Hello,
I use SimpleCom from Microsoft Terminal, but after the last update it doesn't work properly, because the arrows don't work.
Strangely, if I launch it directly, the arrows work fine.
Is it just me or did this occur to someone else?

Expand buffer size for StdInRedirector and StdOutRedirector

Buffer size of StdInRedirector is 4, 1 is for StdOutRedirector. They are small because I assume SimpleCom is used for the console - it is enough to redirect typing by the hand. (I think the human cannot type so fast 😁)

However we might get the gain when the peripheral send many chars (e.g. log dumping) if we expand buffer size for StdOutRedirector. It is worth to work. OTOH we should consider it for StdInRedirector because we need to handle F1 key to terminate SimpleCom. We have to catch F1 (0x1b + 0x4f + 0x50), and also have to handle multibyte chars (e.g. Japanese Kanji). We might use ReadConsoleInput(), but I'm not sure.

Implement --help command as command-line option

First of all, thank you for this tool. I've been using it a lot since I have discovered it with my dev machines.

Occasionally I forget the command line arguments, that the tool accepts, and find myself typing in --help as argument, often used to get all supported arguments of a tool or program.

I think SimpleCom would benefit from the implementation of a --help argument, as one doesn't have to look it up on the web each time this way.

What do you think of this idea?
Thank you for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.