[ECOS] Serial buffer overrun

Jonathan Larmour jifl@eCosCentric.com
Thu Jan 16 17:56:00 GMT 2003

Grant Edwards wrote:
> On Wed, Jan 15, 2003 at 08:23:49PM -0800, Shannon Holland wrote:
>>I also notice that the low level ISR immediately schedules a DSR - how 
>>long is the delay from the exit from the ISR until the DSR routine is 
> That depends on what other DSRs are running or how long an
> application or driver has DSRs locked out.

Indeed. Having to do a timeslice could be all it takes.

>>I also noticed that in the DSR it pulls in a single byte and then calls 
>>out to the channel callback, then gets the next byte, etc. Just for 
>>grins I modified this code to pull in a number of bytes at a time before 
>>calling the channel callback. I'm not sure this will buy me anything 
>>(doesn't change behavior) - I need to read up on the uart docs!
> I gave up on the single-character callback scheme years ago and
> made my DSR cognisant of the cbuf structure so that data bytes
> are transferred directly to/from the circular buffers.  I found
> that using the single-character callbacks I had no chance
> whatsoever to keep up with multiple serial ports at high baud
> rates.

It's true that the driver design could be improved in that respect. It's 
all possible...

>>I also have another question as to how the debugger printf's interact 
>>with program flow: I notice I drop a whole ton of bytes if I call printf 
>>(anywhere from 20-60 bytes!). Are interrupts disabled when using the 
>>monitor printf?
> Don't know.  The diag_printf with which I'm familiar busy-waits
> on the UART to which it's writing.  If you call it with
> interrupts disabled, then interrupts stay disabled the whole
> time.  If not, they stay enabled the whole time.

The default diag_printf will disable interrupts while it is outputting. 
Since you may well be using a serial line for output at the same speed, 
that means ints will be off for the same number of chars as you're writing.

It would be better to use normal printf and change the driver underneath 
libc stdio from /dev/ttydiag to /dev/ttyS0 or whatever it is; that way you 
get interrupt driven output so they can interleave.

eCosCentric       http://www.eCosCentric.com/       <info@eCosCentric.com>
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine

Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

More information about the Ecos-discuss mailing list