From b8260ae628da934c414a8377a34b430601c85302 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Fri, 8 Nov 2024 20:27:36 -0800
Subject: [PATCH] Don't reset the port baud rate to 0 in comOpen()

As noticed while trouble-shooting issue #813, calling comOpen() would
(on Linux, at least) set the port baud rate to 0 bps (B0) which in
most or all Linux serial drivers triggers special logic to deassert DTR and
RTS signals (to the modem, to attempt to "hangup" any connection).

If the app (e.g. sexpots) did not explictily set the port baud rate after
calling comOpen(), the port would be unusable. This is not how comOpen() works
on Windows.

So rather than just overwrite all the bits in termios.c_cflag, we clear the
fields we know we want to, set the bits we want, and leave the rest (which
usually includes the current baud rate, if CBAUD is defined) as-is.
---
 src/comio/comio_nix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/comio/comio_nix.c b/src/comio/comio_nix.c
index 0fd01f5818..918492732d 100644
--- a/src/comio/comio_nix.c
+++ b/src/comio/comio_nix.c
@@ -221,7 +221,8 @@ COM_HANDLE comOpen(const char* device)
                 | IGNPAR   /* ignore (discard) parity errors */
                 );
     t.c_oflag = 0;  /* No output processing */
-    t.c_cflag = (
+	t.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD);
+    t.c_cflag |= (
                   CS8         /* 8 bits */
                 | CREAD       /* enable receiver */
 /*
-- 
GitLab