public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: David Lawyer <dave@lafn.org>
To: linux-serial@vger.kernel.org
Subject: Re: problems with serial driver
Date: Tue, 3 Sep 2002 12:17:35 -0700	[thread overview]
Message-ID: <20020903121734.B337@lafn.org> (raw)
In-Reply-To: <017b01c2535e$c3befc60$294b82ce@connecttech.com>

On Tue, Sep 03, 2002 at 11:29:59AM -0400, Stuart MacDonald wrote:
> From: <slack@slackware.ru>
> > It is clear. Not so clear, why it produces garbage when read from port, as
> > if it cannot sync with line.
> 
> It can't sync with the line. Serial transmission doesn't include a
> specific syncing marker.
> 
> Yes, I know about the start bit. However, when a uart starts looking
> at a line that already has data on it, how does it know which one is
> the start bit? It takes the first thing that looks like a start bit,
> which could be a bit in the middle of a character, and thus get
> mis-synced. This is the way serial transmission works.
> 
> If you try replugging the cable while the sender and receiver are
> running, you will notice that occasionally you'll get lucky and get a
> correct sync, but often you'll get a mis-sync and receive garbage.
> 
> > for()
> > usleep();
> > read();
> > }
> > read OK.
> >
> > for() {
> > // usleep()
> > read();
> > }
> > Garbage.
> 
> This shouldn't make a difference, but I suspect that the usleep() is
> luckily making the timing work out so that you get a correct sync
> instead of a mis-sync.

Could it be that usleep() somehow triggers a flow control stop?  Then
when transmission resumes, it will start on a byte boundary and all will
be in sync.  One way for flow control to happen is for the serial buffer
in main memory to fill since it's not being read.  But then there would
still be a lot of garbage bytes stored in the buffer, followed by valid
bytes when the flow resumes.  So could these garbage bytes be flushed or
could usleep() somehow immediately cause a flow control stop without the
buffer filling?

I notice that the man page says usleep() is obsolete.

			David Lawyer

> 
> However, if you've started the sender first, in the time it takes you
> to start the receiver, the uart is dropping data. Even when you don't
> get garbage you should notice that you're missing the first few bytes.

      parent reply	other threads:[~2002-09-03 19:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-02  9:55 problems with serial driver slack
2002-09-03 14:56 ` Stuart MacDonald
2002-09-03 14:30   ` slack
2002-09-03 15:29     ` Stuart MacDonald
2002-09-03 15:34       ` slack
2002-09-03 18:21         ` Stuart MacDonald
2002-09-04  5:39           ` slack
2002-09-04 12:57             ` Stuart MacDonald
2002-09-04 14:21               ` slack
2002-09-04 16:22                 ` Stuart MacDonald
2002-09-03 19:17       ` David Lawyer [this message]

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=20020903121734.B337@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