LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-07-2004, 01:41 PM   #1
newbie42
LQ Newbie
 
Registered: Nov 2002
Distribution: Red Hat 8.0
Posts: 11

Rep: Reputation: 0
Collecting data through serial ports w/ RH 8.0


Hello,

I am debugging a C application that reads data from 4 serial ports simultaneously on a Linux box running Red Hat 8.0. The data comes from a device my employer is developing, and consists of "frames", each of which has a 16-bit tag-word, 6 16-bit data words, and a checksum word (this is all RS-232). The device can output either 100 of these "frames" per second or 450 per second.

My application reads one byte at a time from each serial port, using read().

At 100 frames per second, everything is fine and my application reads the data from 4 devices on 4 serial ports reliably. At 450 per second, the app can read from 2 ports simultaneously without problems, but reading 4 at a time I'm getting frequent "checksum error" messages from my app (3 or 4 such errors per port per second). It looks like the app is having trouble keeping up with the data streams and is dropping bits.

I am running the app as root and am invoking it with "nice -20 <appname>". I also make sure all other windows and applications are closed.

Questions:

Is there a commonly available version of Linux that has less system overhead than RH 8.0? Is Blue Cat or Lynx any better?

Is there a method for giving my application a higher priority when running?

Is there an easy way to "strip down" the RH Linux session so there are fewer processes running?

Does anyone have suggestions for improving the application itself? I'm not proud and freely admit it's probably not the most efficient program for collecting serial data.

Along the same lines, could someone point me to example source code for reading RS-232 data in an efficient manner?

Thanks for indulging my curiosity.

-newbie42
 
Old 04-07-2004, 04:54 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,750

Rep: Reputation: 271Reputation: 271Reputation: 271
You could use top to see how much cpu your application is using. If it is already using 100% then efforts to give it higher priority are futile. See:

man top

"My application reads one byte at a time from each serial port, using read()."

You could greatly reduce your cpu overhead if you could find a way to read more than one byte at a time. Could you read an entire frame in one read?

You could also greatly increase efficiency if you wrote a device driver for the device. You could set up the device driver to accept reads for a byte, a frame, or a record (if the concept of record has meaning for this device). Here is some information on Linux device drivers:

http://www.oreilly.com/catalog/linuxdrive2/

"Is there a commonly available version of Linux that has less system overhead than RH 8.0? Is Blue Cat or Lynx any better?"

You are dealing at the level of kernel efficiency. You might conceivably get better efficiency by compiling a different kernel configuration but changing distributions is probably irrelevent.

"Is there an easy way to "strip down" the RH Linux session so there are fewer processes running?"

If you do manage to do this then you will end up with an application that will work in your development environment but will fail in the real world. But anyway, the way to strip RH down is to remove the startup scripts that start processes that you deem superflous.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Last edited by jailbait; 04-07-2004 at 05:18 PM.
 
  


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
How to use serial ports in kernel? jamespayne Programming 24 06-24-2014 01:20 PM
Can only use one of my serial ports steaktc Linux - Hardware 1 11-23-2005 07:07 AM
Serial ports KenHorse Programming 2 12-27-2004 09:49 AM
collecting data from fork process frostmagic Programming 5 12-28-2003 02:55 PM
Serial Ports (tty´s) aqoliveira Linux - Hardware 4 06-21-2002 11:06 AM


All times are GMT -5. The time now is 10:55 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration