Skip to content

Commit

Permalink
Clear console before establish serial connection
Browse files Browse the repository at this point in the history
  • Loading branch information
YaSuenag committed Oct 1, 2024
1 parent bbbb09d commit 342b19e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion SimpleCom/SimpleCom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "WinAPIException.h"
#include "debug.h"

static LPCTSTR CLEAR_CONSOLE_COMMAND = _T("\x1b[2J");
static DWORD CLEAR_CONSOLE_COMMAND_LEN = static_cast<DWORD>(_tcslen(CLEAR_CONSOLE_COMMAND));


static HWND GetParentWindow() {
HWND current = GetConsoleWindow();
Expand Down Expand Up @@ -134,7 +137,13 @@ int _tmain(int argc, LPCTSTR argv[])

try {
while (true) {
SimpleCom::SerialConnection conn(device, &dcb, parent_hwnd, std::get<0>(std_handles), std::get<1>(std_handles), setup.GetUseTTYResizer(), setup.GetLogFile(), setup.IsEnableStdinLogging());
HANDLE hStdIn = std::get<0>(std_handles);
HANDLE hStdOut = std::get<1>(std_handles);

// Clear console
WriteConsole(hStdOut, CLEAR_CONSOLE_COMMAND, CLEAR_CONSOLE_COMMAND_LEN, nullptr, nullptr);

SimpleCom::SerialConnection conn(device, &dcb, parent_hwnd, hStdIn, hStdOut, setup.GetUseTTYResizer(), setup.GetLogFile(), setup.IsEnableStdinLogging());
bool exited = conn.DoSession();

if (setup.GetAutoReconnect() && !exited) {
Expand Down

0 comments on commit 342b19e

Please sign in to comment.