Date: Thu, 2 Mar 2000 15:47:12 -0800
   From: <[EMAIL PROTECTED]>

   I don't do any serial programming but it looks like there is a problem
   supporting mark parity and space parity.  James M. wants to use space
   parity.  Stty doesn't support it but the termios stucture in the
   serial driver might.  Such parity is specified by a c_cflag named
   CMSPAR in <asm/termbits.h>.  The equvalent is in <linux/serial-reg.h>
   as UART_LCR_SPAR 0x20.  This is called "sticky parity".  It looks like
   someone put a ? in the comment in the serial-reg.h file shown above and
   called it "stick" instead of "sticky".  If this "sticky" bit is set,
   then the parity bit is always odd (1) or even (0) depending on how the
   parity flag-bit has been set.

No, it's called "stick" parity, not "sticky".  Check the 8250 / 16550
UART documentation.

The reason why CMSPAR isn't in bits/termios.h is because it's not POSIX,
and so it was dropped during the glibc conversion by the glibc folks.  

Traditionally, the way Unix handled mark and space parity was to set or
clear the eighth bit, and simply used 8 bits no parity as far as termios
was concerned.  Actually, mark and space parity was very rare to begin
with, so it rarely came up.

The problem comes when you want to use 8 bits and also force mark or
space parity.  There is no way to do that under POSIX termios.  So, back
in 1977 I added CMSPAR for the one squeeky wheel that was complaining
that we didn't have the support.  Later, we converted to glibc, and the
glibc folks didn't add the bit.  It's indicative that no one has
complained that this feature was missing until now.

   It would seem that the high-level way to go would be to set the sticky
   parity bit in the termios structure, but will this do the job?  To
   change the termios structure one may use tcsetattr() and tcgetattr()
   as shown in Vern's HOWTO.  It seems that the flags normally used are
   in <bits/termios.h> and CMSPAR is missing from this.  <termios.h>
   #includes this but <asm/termios.h> #includes the one you want that
   contains the CMSPAR flags.  Will this flag work OK if one changes the
   #includes in their program to the </asm> directory?  Why isn't it in
   <bits/termios.h>?

So yes, if you set the CMSPAR bit in the termios, it will do the right
thing.  #including asm/termios.h is a bad idea, though.  In the new
header file religion, it's always a bad thing to include anything in the
asm/ directory.  You should complain to the glibc folks and ask them to
include CMSPAR in bits/termsio.h.

In the meantime, a program who needs this bit badly can simply manually
define CMSPAR, and they should be warned that this is a Linux specific
feature that won't work on any other OS.

                                                - Ted

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to