Next Previous Contents

8. Speed (Flow Rate)

By "speed" we really mean the "data flow rate" but almost everybody incorrectly calls it speed. The speed is measured in bits/sec (or baud). Speed is set using the "stty" command or by a program which uses the serial port.

8.1 Can't Set a High Enough Speed

You need to find out the highest speed supported by your hardware. As of late 1998 most hardware only supported speeds up to 115.2K bps. If you have a application program that doesn't show high enough speeds in its menu, then there are some options you can give to the setserial command so that a low speed command from the communication program will actually result in a higher speed. With these options, when you set the speed for 38400 the actual speed will be higher. See the man page for "setserial" and search for speed_hi, spd_cust, baud_base, and divisor. Note that you must set baud_base to the actual maximum speed of the hardware. This speed is usually lower than the frequency of the crystal oscillator in the hardware since the crystal frequency is often divided by 16 in the hardware to give the maximum clock speed for bit pulses. The reason the crystal frequency needs to be higher is so that its full clock signal can be used to take several samples of a bit pulse at the highest speed. If your software doesn't permit typing in a speed of 230400 to an application program but your physical serial port supports 230400 then you could try the following:

setserial /dev/ttyS2 spd_cust baud_base 230400 divisor 1
Then to get a speed of 230400 you must claim to the application program that the speed is 38400. See the man page for setserial for more info about this.

If you use setserial test it on the command line first, and then when you have it working, put it into /etc/rc.d/rc.serial or /etc/rc.boot/0setserial so that they are run at startup. Make sure that you are using a valid path for setserial, and a valid device name. You can check the settings of a serial port by running:

setserial -a /dev/ttyS3

8.2 Higher Serial Throughput

If you are seeing slow throughput and serial port overruns on a system with (E)IDE disk drives, you can get hdparm. This is a utility that can modify (E)IDE parameters, including unmasking other IRQs during a disk IRQ. This will improve responsiveness and will help eliminate overruns. Be sure to read the man page very carefully, since some drive/controller combinations don't like this and may corrupt the filesystem.

Also have a look at a utility called irqtune that will change the IRQ priority of a device, for example the serial port that your modem is on. This may improve the serial throughput on your system. The irqtune FAQ is at http://www.best.com/~cae/irqtune.


Next Previous Contents