Linux Inside Next Previous Contents

12. Troubleshooting

See Modem-HOWTO for troubleshooting related to modems or getty for modems.

12.1 Serial Electrical Test Equipment

Breakout Gadgets, etc.

While a multimeter (used as a voltmeter) may be all that you need for just a few terminals, simple special test equipment has been made for testing serial port lines. Some are called "breakout ... " where breakout means to break out conductors from a cable. These gadgets have a couple of connectors on them and insert into the serial cable. Some have test points for connecting a voltmeter. Others have LED lamps which light when certain modem control lines are asserted (turned on). Still others have jumpers so that you can connect any wire to any wire. Some have switches.

Radio Shack sells (in 1998) a "RS-232 Troubleshooter" or "RS-232 Line Tester" which checks TD, RD, CD, RTS, CTS, DTR, and DSR. A green light means on (+12 v) while red means off (-12 v). They also sell a "RS-232 Serial Jumper Box" which permits connecting the pins anyway you choose.

Measuring Voltages

Any voltmeter or multimeter, even the cheapest that sells for about $10, should work fine. Trying to use other methods for checking voltage is tricky. Don't use a LED unless it has a series resistor to reduce the voltage across the LED. A 470 ohm resistor is used for a 20 ma LED (but not all LED's are 20 ma). The LED will only light for a certain polarity so you may test for + or - voltages. Does anyone make such a gadget for automotive circuit testing?? Logic probes may be damaged if you try to use them since the TTL voltages for which they are designed are only 5 volts. Trying to use a 12 V incandescent light bulb is not a good idea. It won't show polarity and due to limited output current of the UART it probably will not even light up.

To measure voltage on a female connector you may plug in a bent paper clip into the desired opening. The paper clip's diameter should be no larger than the pins so that it doesn't damage the contact. Clip an alligator clip (or the like) to the paper clip to connect up.

Taste Voltage

As a last resort, if you have no test equipment and are willing to risk getting shocked (or even electrocuted) you can always taste the voltage. Before touching one of the test leads with your tongue, test them to make sure that there is no high voltage on them. Touch both leads (at the same time) to one hand to see if they shock you. Then if no shock, wet the skin contact points by licking and repeat. If this test gives you a shock, you certainly don't want to use your tongue.

For the test for 12 V, Lick a finger and hold one test lead in it. Put the other test lead on your tongue. If the lead on your tongue is positive, there will be a noticeable taste. You might try this with flashlight batteries first so you will know what taste to expect.

12.2 Serial Monitoring/Diagnostics

A few Linux programs will monitor the modem control lines and indicate if they are positive (1) or negative (0). See section Serial Monitoring/Diagnostics

12.3 The following subsections are in both the Serial and Modem HOWTOs:

12.4 My Serial Port is Physically There but Can't be Found

Check the BIOS menus and BIOS messages. If it's an ISA bus PnP serial port, try "pnpdump --dumpregs" and/or see Plug-and-Play-HOWTO. For the PCI bus look at /proc/pci. You may try probing with setserial. See Probing If nothing seems to get thru the port it may be there but have a bad interrupt. See Extremely Slow: Text appears on the screen slowly after long delays

12.5 Extremely Slow: Text appears on the screen slowly after long delays

It's likely mis-set/conflicting interrupts. Here are some of the symptoms which will happen the first time you try to use a modem, terminal, or printer. In some cases you type something but nothing appears on the screen until many seconds later. Only the last character typed may show up. It may be just an invisible <return> character so all you notice is that the cursor jumps down one line. In other cases where a lot of data should appear on the screen, only a batch of about 16 characters appear. Then there is a long wait of many seconds for the next batch of characters. You might also get "input overrun" error messages (or find them in logs).

For more details on the symptoms and why this happens see

Interrupt Problem Details and/or Interrupt Conflicts and/or Mis-set Interrupts. If it involves Plug-and-Play devices, see also Plug-and-Play-HOWTO.

As a quick check to see if it really is an interrupt problem, set the IRQ to zero with "setserial". This will tell the driver to use polling instead of interrupts. If this seems to fix the "slow" problem then you had an interrupt problem but should still try to fix it since polling uses excessive computer resources.

Checking to find the interrupt conflict may not be easy since Linux supposedly doesn't permit any interrupt conflicts and will send you a /dev/ttySN: Device or resource busy error message if you attempt to create a conflict. But Linux can be tricked. For example if IRQ 5 is set in the hardware (by a jumper or Plug-and-Play) and "setserial" has told the driver it's IRQ 3, then the driver will not know that IRQ 5 is taken and will let some other device also use IRQ 5 with disastrous results. Thus when you get this error it means that Linux is wrong about how the IRQs are really set in the hardware. Checking for conflicts by looking at the settings using "setserial" or looking at /proc/interrupts will only tell you what Linux thinks and will not show any conflicts at all. Yet a conflict exists.

What you need to do is to check how the hardware is set by checking jumpers or using PnP software to check how the hardware is actually set. For PnP run either "pnpdump --dumpregs" or run "lspci". Compare this to how Linux thinks the hardware is set.

12.6 Somewhat Slow: I expected it to be 2-4 times faster

One reason may be that whatever is on the serial port (such as a modem, terminal, printer) doesn't work as fast as you thought it did.

Another possible reason is that the serial driver thinks you have an obsolete serial port (UART 8250,16450 or early 16550). See What Are UARTs?. Use "setserial -g /dev/ttyS*". If it shows anything less than a 16550A, this is likely your problem. Then if "setserial" has it wrong, change it. See What is Setserial for more info. Of course if you really do have an obsolete serial port, lying about it to setserial will only make things worse.

12.7 The Startup Screen Show Wrong IRQs for the Serial Ports.

Linux does not do any IRQ detection on startup. When the serial module loads it only does serial device detection. Thus, disregard what it says about the IRQ, because it's just assuming the standard IRQs. This is done, because IRQ detection is unreliable, and can be fooled. But if and when setserial runs from a start-up script, it changes the IRQ's and displays the new (and hopefully correct) state on on the startup screen. If the wrong IRQ is not corrected by a later display on the screen, then you've got a problem.

So, even though I have my ttyS2 set at IRQ 5, I still see

ttyS02 at 0x03e8 (irq = 4) is a 16550A
at first when Linux boots. (Older kernels may show "ttyS02" as "tty02") You have to use setserial to tell Linux the IRQ you are using.

12.8 "Cannot open /dev/ttyS?: Permission denied"

Check the file permissions on this port with "ls -l /dev/ttyS?"_ If you own the ttyS? then you need read and write permissions: crw with the c (Character device) in col. 1. It you don't own it then it should show rw- in cols. 8 & 9 which means that everyone has read and write permission on it. Use "chmod" to change permissions. There are more complicated ways to get access like belonging to a "group" that has group permission.

12.9 "Operation not supported by device" (error message) for ttySx

This means that an operation requested by setserial, stty, etc. couldn't be done because the kernel doesn't support doing it. Formerly this was often due to the "serial" module not being loaded. But with the advent of PnP, it may likely mean that there is no modem (or other serial device) at the address where the driver (and setserial) thinks it is. If there is no modem there, commands (for operations) sent to that address obviously don't get done. See What is set in my serial port hardware?

If the "serial" module wasn't loaded but "lsmod" shows you it's now loaded it might be the case that it's loaded now but wasn't loaded when you got the error message. In many cases the module will automatically loaded when needed (if it can be found). To force loading of the "serial" module it may be listed in the file: /etc/modules.conf or /etc/modules. The actual module should reside in: /lib/modules/.../misc/serial.o.

12.10 "Cannot create lockfile. Sorry" (error message)

When a port is "opened" by a program a lockfile is created in /var/lock/. Wrong permissions for the lock directory will not allow a lockfile to be created there. Use "ls -ld /var/lock" to see if the permissions are OK: usually rwx for everyone (repeated 3 times). If it's wrong, use "chmod" to fix it. Of course, if there is no "lock" directory no lockfile can be created there. For more info on lockfiles see What Are Lock Files

12.11 "Device /dev/ttyS? is locked."

This means that someone else (or some other process) is supposedly using the serial port. There are various ways to try to find out what process is "using" it. One way is to look at the contents of the lockfile (/var/lock/LCK...). It should be the process id. If the process id is say 261 type "ps 261" to find out what it is. Then if the process is no longer needed, it may be gracefully killed by "kill 261". If it refuses to be killed use "kill -9 261" to force it to be killed, but then the lockfile will not be removed and you'll need to delete it manually. Of course if there is no such process as 161 then you may just remove the lockfile but in most cases the lockfile should have been automatically removed if it contained a stale process id (such as 261).

12.12 "/dev/ttySN: Device or resource busy"

A common cause of ``device busy'' errors, is that you set up your serial port with an interrupt already taken by something else. The serial driver knows what interrupts have been assigned by setserial (or the like) and assumes they have been set this way in the hardware. If they are not set this way in the hardware, the driver will not know about possible conflicts and ``device busy'' errors may never be seen. Instead, performance may be Extremely Slow with no error messages.

Linux doesn't complain when you assign two devices the same IRQ provided that neither device is in use. As each device starts up (initializes), it asks Linux for permission to use its hardware interrupt. Linux keeps track of which interrupt is assigned to whom, and if your interrupt is already in use, you'll see this "... busy" error message. Thus if two devices use the same IRQ and you start up only one of the devices, everything is OK. But when you next try to start the second device (without quitting the first device) you get "... busy". Of course if the driver doesn't know about the conflict because it has incorrect info about the acutal IRQ set in the hardware, then you will not see the "... busy" message. Both interrupts will be used simultaneously with extremely slow performance.

Now there's a problem when you try to use "setserial" and get this "... busy" message. Worst of all, "setserial" will neither tell you what IRQ the port is trying to use nor change it. This happens because using "setserial" to deal with a device is something like trying to start up that device. You can't use "setserial" on the device because its IRQ (what the driver thinks is the IRQ) is in use by another device. It shouldn't be this way but it is.

If this happens, how do you determine what the conflict is? You could try to figure out what the IRQ is by finding where setserial last set it (look at boot-time messages). Another way to deal with this is to look at /proc/interrupts and try to guess what the conflict is. Then exit or kill gracefully all possible conflicting processes and then try "setserial" again. Instead of this, you may just want to reboot, making sure that the file the runs "setserial" at boot-time doesn't create the same conflict again.

12.13 Software which may help


Next Previous Contents