Gentoo Archives: gentoo-embedded

From: David Relson <relson@×××××××××××××.com>
To: gentoo-embedded@l.g.o
Subject: [gentoo-embedded] SOLUTION (partial) was: High Speed Serial Problem
Date: Sat, 20 Mar 2010 19:12:33
Message-Id: 20100320150237.2ee70a4e@osage.osagesoftware.com
In Reply to: RE: [gentoo-embedded] High Speed Serial Problem by "Relson
1 On Mon, 15 Mar 2010 13:47:14 -0400
2 Relson, David wrote:
3
4 > Hello Bob,
5 >
6 > VMIN and VTIME are the default values of 1 and 0, respectively. If I
7 > understand correctly, these settings will provide data as rapidly as
8 > possible.
9 >
10 > At present, I am using a 256 byte buffer for reading data. I've added
11 > some statistics gathering. Every 1000 reads, the program logs the
12 > total bytes read and the maximum read. The program was run for 30
13 > seconds to provide 6 statistics records
14 >
15 > With _no_ processing of data, 1000 reads got from 27,545 to 28,520
16 > chars. The max read was 128 chars. 3 of the 1000 read samples had
17 > max reads of 56 or 57 and 3 had max reads of 110, 126, and 128.
18 >
19 > With copying of data to a buffer (which involves several function
20 > calls, incrementing counters, etc), 1000 reads got from 27,187 to
21 > 28,241 chars and each of the 6 sample sets had a max read of 110 to
22 > 128 bytes.
23 >
24 > One would expect processing to increase the total bytes received, but
25 > this was not the case.
26 >
27 > The code _is_ handling the 3 char break sequence and the
28 > (undocumented) doubling (escaping) of 0xFF chars (to distinguish them
29 > from break sequences).
30 >
31 > Regards,
32 >
33 > David
34
35 The serial input problem has been solved! While talking with the
36 project manager, it occurred to me to check whether all byte codes,
37 i.e. 0x00 to 0xFF, were being received. I quickly found that 2 were
38 missing -- 0x11 and 0x13 -- which are the usual XON and XOFF
39 characters. Simply setting termios.c_iflag=PARMK (rather than or'ing
40 the flag) solved the lost character input problem.
41
42 Even with a dedicated thread, the program is still receiving multiple
43 characters per read. Calculating average and maximum byte counts for
44 each 10,000 reads, I've often seen maximums of 150 and have never seen
45 an average under 12. These numbers occur with VMIN=1 and VTIME=0.
46
47 Is there a setting so that the serial port driver will release
48 characters sooner (rather than later)?
49
50 My basic loop looks like:
51
52 while (1) {
53 char buffer[256];
54 select(...)
55 count = read(fd, buffer, sizeof(buffer))
56 ... save characters.
57 }
58
59 Regards,
60
61 David

Replies

Subject Author
Re: [gentoo-embedded] SOLUTION (partial) was: High Speed Serial Problem James Ausmus <james.ausmus@×××××.com>