LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Collecting data through serial ports w/ RH 8.0 (https://www.linuxquestions.org/questions/linux-software-2/collecting-data-through-serial-ports-w-rh-8-0-a-167359/)

newbie42 04-07-2004 12:41 PM

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

jailbait 04-07-2004 03:54 PM

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


All times are GMT -5. The time now is 01:13 AM.