public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* fhandler_serial.cc: MARK and SPACE parity for serial port
@ 2021-01-27 20:30 Marek Smetana
  2021-01-28 10:08 ` Corinna Vinschen
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Smetana @ 2021-01-27 20:30 UTC (permalink / raw)
  To: cygwin-patches

Hi,

This patch add MARK and SPACE parity support to serial port

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

diff --git a/winsup/cygwin/fhandler_serial.cc
b/winsup/cygwin/fhandler_serial.cc
index fd5b45899..23d69eca5 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/winsup/cygwin/fhandler_serial.cc
@@ -727,7 +727,10 @@ 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 +1071,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..933851c21 100644
--- a/winsup/cygwin/include/sys/termios.h
+++ b/winsup/cygwin/include/sys/termios.h
@@ -185,6 +185,7 @@ POSIX commands */
 #define PARODD 0x00200
 #define HUPCL 0x00400
 #define CLOCAL 0x00800
+#define CMSPAR  0x40000000 /* Mark or space (stick) parity.  */

 /* Extended baud rates above 37K. */
 #define CBAUDEX 0x0100f

---

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-02-02  9:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27 20:30 fhandler_serial.cc: MARK and SPACE parity for serial port 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
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

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