public inbox for gentoo-embedded@lists.gentoo.org
 help / color / mirror / Atom feed
From: David Relson <relson@osagesoftware.com>
To: gentoo-embedded@lists.gentoo.org
Subject: [gentoo-embedded] SOLUTION (partial)  was: High Speed Serial Problem
Date: Sat, 20 Mar 2010 15:02:37 -0400	[thread overview]
Message-ID: <20100320150237.2ee70a4e@osage.osagesoftware.com> (raw)
In-Reply-To: <91FA647A1A781F41BBB0359765C90C15F713C8@mailsvr.orion-sys.com>

On Mon, 15 Mar 2010 13:47:14 -0400
Relson, David wrote:

> Hello Bob,
> 
> VMIN and VTIME are the default values of 1 and 0, respectively.  If I
> understand correctly, these settings will provide data as rapidly as
> possible.
> 
> At present, I am using a 256 byte buffer for reading data.  I've added
> some statistics gathering.  Every 1000 reads, the program logs the
> total bytes read and the maximum read.  The program was run for 30
> seconds to provide 6 statistics records
> 
> With _no_ processing of data, 1000 reads got from 27,545 to 28,520
> chars.  The max read was 128 chars.  3 of the 1000 read samples had
> max reads of 56 or 57 and 3 had max reads of 110, 126, and 128.
> 
> With copying of data to a buffer (which involves several function
> calls, incrementing counters, etc), 1000 reads got from 27,187 to
> 28,241 chars and each of the 6 sample sets had a max read of 110 to
> 128 bytes.
> 
> One would expect processing to increase the total bytes received, but
> this was not the case.
> 
> The code _is_ handling the 3 char break sequence and the
> (undocumented) doubling (escaping) of 0xFF chars (to distinguish them
> from break sequences).
> 
> Regards,
>  
> David

The serial input problem has been solved!  While talking with the
project manager, it occurred to me to check whether all byte codes,
i.e. 0x00 to 0xFF, were being received.  I quickly found that 2 were
missing -- 0x11 and 0x13 -- which are the usual XON and XOFF
characters.  Simply setting termios.c_iflag=PARMK (rather than or'ing
the flag) solved the lost character input problem.

Even with a dedicated thread, the program is still receiving multiple
characters per read.  Calculating average and maximum byte counts for
each 10,000 reads, I've often seen maximums of 150 and have never seen
an average under 12.  These numbers occur with VMIN=1 and VTIME=0.  

Is there a setting so that the serial port driver will release
characters sooner (rather than later)?

My basic loop looks like:

   while (1) {
     char buffer[256];
     select(...)
     count = read(fd, buffer, sizeof(buffer))
     ... save characters.
   }

Regards,

David



  reply	other threads:[~2010-03-20 19:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-14 14:24 [gentoo-embedded] High Speed Serial Problem David Relson
2010-03-14 16:34 ` Manuel Lauss
2010-03-14 17:14   ` David Relson
2010-03-14 17:51 ` Peter Stuge
2010-03-15  1:47 ` Peter Bell
2010-03-15 13:34 ` Bob Dunlop
2010-03-15 17:47   ` Relson, David
2010-03-20 19:02     ` David Relson [this message]
2010-03-23  5:19       ` [gentoo-embedded] SOLUTION (partial) was: " James Ausmus
2010-03-15 14:07 ` [gentoo-embedded] " wireless

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=20100320150237.2ee70a4e@osage.osagesoftware.com \
    --to=relson@osagesoftware.com \
    --cc=gentoo-embedded@lists.gentoo.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