Mailing List Archive

SOLUTION (partial) was: High Speed Serial Problem
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
Re: SOLUTION (partial) was: High Speed Serial Problem [ In reply to ]
On Sat, Mar 20, 2010 at 12:02 PM, David Relson <relson@osagesoftware.com> wrote:
<snip>
> 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)?
<snip>

Wasn't involved in the other thread, so my apologies if this has
already been answered/stated, but are you using the realtime kernel
patches? If you run RT-Preempt, then you can set the priority of the
kernel thread that is handling the serial interrupt high than all the
other kernel threads, which should improve your latencies... See
https://rt.wiki.kernel.org/index.php/Main_Page for more info.

HTH-

James


> Regards,
>
> David
>
>