public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] fhandler_serial.cc: MARK and SPACE parity for serial port
@ 2021-02-02  9:43 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2021-02-02  9:43 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d4a756f13a3440576c866d0a0cfc3a001f86ad59

commit d4a756f13a3440576c866d0a0cfc3a001f86ad59
Author: Marek Smetana <mara.smetana@gmail.com>
Date:   Mon Feb 1 22:02:14 2021 +0100

    fhandler_serial.cc: MARK and SPACE parity for serial port

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

diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc
index fd5b45899..e0257302c 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/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 a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h
index 17e8d83a3..e4465fca3 100644
--- a/winsup/cygwin/include/sys/termios.h
+++ b/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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-02  9:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02  9:43 [newlib-cygwin] fhandler_serial.cc: MARK and SPACE parity for serial port Corinna Vinschen

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).