public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: David Lawyer <dave@lafn.org>
To: 'linux-serial' <linux-serial@vger.kernel.org>
Subject: Re: Interpretation of termios flags on a serial driver
Date: Thu, 27 Mar 2003 11:06:52 -0800	[thread overview]
Message-ID: <20030327190652.GA1233@lafn.org> (raw)
In-Reply-To: <11E89240C407D311958800A0C9ACF7D1A33E05@EXCHANGE>

On Wed, Mar 26, 2003 at 04:59:11PM -0800, Ed Vance wrote:
> On Wed, Mar 26, 2003 at 4:17 PM, Henrique Gobbi wrote:
> > 
> > Hello Ed !
> > Thanks for the feedback. 
> > 
> > Please read my comments (doubts actually) below:
> > 
> > > > 4 - INPCK flag: What's the purpose of this flag. What's the 
> > > > difference in relation to IGNPAR;
[snip]
> > 

>From the code snippet, it seems that INPCK only determines how to "mark"
a parity error (when PARENB is set and IGNPAR is unset) and can be
overridden by PARMRK (prefixes the bad char. with \377\0).  INPCK has
no effect unless IGNPAR and PARMRK are both unset.  If they are both
unset then: INPCK set results in the bad character being replaced by \0,
while if INPCK is unset, then the bad character (less the parity bit) is
passed thru.  I've use "mark" in a broad sense, since in one case it's
not marked at all and in the other case it's marked by deleting it and
substituting a \0.

The man page for termios needs revision to make this clear.  One can't
just say that INPCK "enables parity checking"; it's a lot more involved.

> 
>    IGNPAR    INPCK         ACTION:
>      0         0           Deliver all data to the user-level, as is.
>      0         1           Deliver nulls in place of erroneous bytes
>      1         0           Discard erroneous bytes, deliver the rest
>      1         1           Discard erroneous bytes, deliver the rest 
> 
> IGNPAR gets processed before INPCK: 
> (from drivers/char/n_tty.c:488)
> 
> static inline void n_tty_receive_parity_error(struct tty_struct *tty,
>                                               unsigned char c)
> {
>         if (I_IGNPAR(tty)) {
>                 return;          /* discard data */
>         }
>         if (I_PARMRK(tty)) {
>                 put_tty_queue('\377', tty);
>                 put_tty_queue('\0', tty);
>                 put_tty_queue(c, tty);
>         } else  if (I_INPCK(tty))
>                 put_tty_queue('\0', tty);     /* deliver null */
>         else
>                 put_tty_queue(c, tty);        /* deliver data */
>         wake_up_interruptible(&tty->read_wait);
> }
> 
> > 
> > > > 5 - If the TTY knows the data status (PARITY, FRAMING, 
> > > > OVERRUN, NORMAL), 
> > > > why the driver has to deal with the flag IGNPAR. Shouldn't 
> > > > the TTY being 
> > > > doing it ?
> > > 
> > > Not sure I understand the question. Received data does not carry any
> > > information about errors with it after it leaves the driver, unless 
> > > PARMRK is set. 
> > 
> > When the driver copy the data from the controller to the flip buffer it
> > copies the data to the buffer tty->flip.char_buf_ptr and it set a flag
> > (TTY_NORMAL, TTY_PARITY, TTY_FRAME, etc) on the buffer
> > tty->flip.flag_buf_ptr telling the TTY how this byte was received. So
> > the TTY knows if certain byte was problematic or not. Did you 
> > understand my doubt know ?
> 
> Yes. I call that part a "line discipline". n_tty is the TTY line 
> discipline that implements termio(s) and some legacy functionality.
> 
> And yes, for received data with parity errors, the line discipline 
> handles IGNPAR, as well INPCK and PARMRK. See snippet of n_tty.c above. 
> 
> > 
> > Thanks for your patience
> > Henrique
> > 
> 
> Cheers,
> Ed
> 
> ---------------------------------------------------------------- 
> Ed Vance              edv (at) macrolink (dot) com
> Macrolink, Inc.       1500 N. Kellogg Dr  Anaheim, CA  92807
> ----------------------------------------------------------------
> -
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
			David Lawyer

  reply	other threads:[~2003-03-27 19:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-27  0:59 Interpretation of termios flags on a serial driver Ed Vance
2003-03-27 19:06 ` David Lawyer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-03-26 23:33 Ed Vance
2003-03-27  0:17 ` Henrique Gobbi

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=20030327190652.GA1233@lafn.org \
    --to=dave@lafn.org \
    --cc=linux-serial@vger.kernel.org \
    /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