LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 06-21-2006, 04:13 AM   #1
damiendusha
LQ Newbie
 
Registered: Jun 2006
Location: Brisbane, Australia
Distribution: Ubuntu 8.04
Posts: 21

Rep: Reputation: 15
Serial Port Buffer Overrun


Hello all,

Long after most people has thought serial ports are dead, I have a problem.

I am running Fedora Core 4, on a Toshiba PM-2.0GHz Laptop.

My application is collecting video data (via coriander on Firewire) and GPS + inertial data on a serial port, via a custom application.

Each program on their own works well.

However, when we start streaming images, we are losing data on the serial port. Interestingly, we are NOT getting the same problem on the USB port.

This is what I have gathered so far:
- From /proc/tty/driver/serial, there are quite a few overrun errors, and data is being lost. Port is set to the usual /dev/ttyS0 parameters automatically, including IRQ.

Given that the USB-serial convert works in the same instance, it is almost certian that the 16-byte FIFO on the 16550A uart is being overrun, since it is not getting serviced fast enough.

From a couple of days of googling, it looks like a receive interrupt is generated after 14 bytes, meaning at the decent data rates (well, relative to serial ) we are using, the 2 bytes could be easily overrun. It's like this to minimise the number of rx interrupts the CUP has to service.

The problem is, neither setserial, stty, ioctrl or termios allow the receive interrupt trigger to be easly changed. Ironically, you can acutally change this quite easily in windows...

I have also investigated changing the IRQ priority, which seemed to have some success for PPP irqtune utility.

Unfortunantly, it refuses to install under FC4. See linuxforums.org/forum/peripherals-hardware/31952-i-thought-ext-usr-modem-would-work-umm-no.html[/url] to see what the problem there is (and yes, I tried all what was said there, and more).

Hence, I'd love if somone has information on the following
- Setting the Recieve interrupt trigger level on the 16550A UART
- Changing the priorities of IRQs under a 2.6 kernel.

Thanks,
Damien Dusha.
 
Old 06-22-2006, 02:56 AM   #2
ZX_SA
LQ Newbie
 
Registered: May 2004
Location: Stellenbosch, South Africa
Distribution: Kubuntu breezy, MDK10.2
Posts: 26

Rep: Reputation: 15
This might not really be the best suggestion, but if you can't find anything else to help, you may as well try.

Don't use interrupts. Write a program that uses a thread to poll the receiver. Set this thread to be time critical. In the thread's main loop it will sleep for maybe the duration of two-four bytes being sent (ie with 9600 BAUD 8bits 1stopbit 1startbit, receiving 2 bytes will take approx 2 milliseconds). Then check if any bytes are available, read them and place them in some buffer which will be much larger than the 16byte buffer, and restart the the loop.

Since the operation this thread will need to do is not very complex, it will finish a run very quickly. And if you are using a rather low BAUD rate (below 115200 BAUD), it wouldn't need to run too often. Thus polling shouldn't have too dramatic an effect on overall system performance.

But still, I myself would only use polling as a last resort.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
flush the serial buffer fizgig10 Linux - General 1 09-21-2009 03:29 AM
Buffer serial input -- create new device? prell Programming 4 04-30-2005 03:52 PM
how to increase serial receive email buffer size? HZC Programming 0 02-14-2005 10:32 PM
No of bytes in the serial drivers transmit buffer igjesdal Programming 0 10-13-2004 10:58 AM
Buffer Overrun? gnashley Slackware 0 07-28-2004 04:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 12:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration