public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Marek Smetana <mara.smetana@gmail.com>
To: cygwin-patches@cygwin.com
Subject: fhandler_serial.cc: MARK and SPACE parity for serial port
Date: Fri, 29 Jan 2021 23:06:30 +0100	[thread overview]
Message-ID: <4d88d636-8274-5dea-67f8-f224a63b49a9@gmail.com> (raw)
In-Reply-To: <20210128101429.GX4393@calimero.vinschen.de>

[-- Attachment #1: Type: text/plain, Size: 236 bytes --]

Hi,

I have modified the patch as recommended and am sending it as an attachment.

The CMSPAR value is the same as in "asm / termbits.h" on Linux.

Patches  sent by me are licensed under the 2-clause BSD license.

Best regards

Marek



[-- Attachment #2: serial_parity.patch --]
[-- Type: text/plain, Size: 1613 bytes --]

 winsup/cygwin/fhandler_serial.cc    | 11 ++++++++++-
 winsup/cygwin/include/sys/termios.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git c/winsup/cygwin/fhandler_serial.cc w/winsup/cygwin/fhandler_serial.cc
index fd5b45899..e0257302c 100644
--- c/winsup/cygwin/fhandler_serial.cc
+++ w/winsup/cygwin/fhandler_serial.cc
@@ -727,7 +727,12 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
   /* -------------- Set parity ------------------ */
 
   if (t->c_cflag & PARENB)
-    state.Parity = (t->c_cflag & PARODD) ? ODDPARITY : EVENPARITY;
+    {
+      if(t->c_cflag & CMSPAR)
+        state.Parity = (t->c_cflag & PARODD) ? MARKPARITY : SPACEPARITY;
+      else
+        state.Parity = (t->c_cflag & PARODD) ? ODDPARITY : EVENPARITY;
+    }
   else
     state.Parity = NOPARITY;
 
@@ -1068,6 +1073,10 @@ fhandler_serial::tcgetattr (struct termios *t)
     t->c_cflag |= (PARENB | PARODD);
   if (state.Parity == EVENPARITY)
     t->c_cflag |= PARENB;
+  if (state.Parity == MARKPARITY)
+    t->c_cflag |= (PARENB | PARODD | CMSPAR);
+  if (state.Parity == SPACEPARITY)
+    t->c_cflag |= (PARENB | CMSPAR);
 
   /* -------------- Parity errors ------------------ */
 
diff --git c/winsup/cygwin/include/sys/termios.h w/winsup/cygwin/include/sys/termios.h
index 17e8d83a3..e4465fca3 100644
--- c/winsup/cygwin/include/sys/termios.h
+++ w/winsup/cygwin/include/sys/termios.h
@@ -206,6 +206,7 @@ POSIX commands */
 
 #define CRTSXOFF 0x04000
 #define CRTSCTS	 0x08000
+#define CMSPAR	 0x40000000 /* Mark or space (stick) parity.  */
 
 /* lflag bits */
 #define ISIG	0x0001

  parent reply	other threads:[~2021-01-29 22:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 20:30 Marek Smetana
2021-01-28 10:08 ` Corinna Vinschen
2021-01-28 10:14   ` Corinna Vinschen
2021-01-28 17:17     ` Brian Inglis
2021-01-28 18:45       ` Brian Inglis
2021-01-29 22:06     ` Marek Smetana [this message]
2021-02-01  9:40       ` Corinna Vinschen
2021-02-01 21:26         ` Marek Smetana
2021-02-02  5:28           ` Brian Inglis
2021-02-02  9:44           ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d88d636-8274-5dea-67f8-f224a63b49a9@gmail.com \
    --to=mara.smetana@gmail.com \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).