Purpose: This blog entry explains how you can determine whether your Serial Ports on your system works or not under Debian Linux.

Requirements:

  • Two computers running Debian Linux
  • At least one Serial Port on each of the computer
  • A Serial Cable that runs from one computer (Computer A) to another computer (Computer B) with proper gender at both ends.
  • Serial Port driver available in the Kernel. Almost all the kernels have it configured in them.
  • Software: minicom & setserial (if required)

Install the software by giving commands:
#apt-get update
#apt-get minicom setserial

Basics:

Before we begin, it is important to know that your Serial Ports (COM1 and COM2) are named as /dev/ttyS0 and /dev/ttyS1 respectively and so on.

BIOS configuration: It is important to first check your BIOS and see if Serial Ports are disabled or not. If they are disabled then please enable them and assign them proper IRQ before you proceed.

The BIOS default settings are as follow:

COM1 – 0x3F8 = IRQ4

COM2 – 0x2F8 = IRQ3

Almost all the BIOSes have the above setting. Therefore, there are very less chances that you will have to modify those in the BIOS.

Tell me how to test now?

Step 1: Connect both the serial port of computer A to serial port of computer B using the Serial Cable.


Step 2: Check if Linux detects your Serial Port or not

There are many ways to do that. One way you could do is to give the following command:
# dmesg | grep ttyS

You should see something like this:
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

The above output shows that your COM1 and COM2 ports are available and Linux recognizes them.

Another way to test is to give the following command:
# ls > /dev/ttyS0

If the command does not return any error message then your Serial Ports are recognized by your Linux system.

Errors?

In case, Linux does not detect your Serial Port, then try giving the following command:
setserial /dev/ttyS0 autoconfig auto_irq

Substitute ttyS0 with ttyS1 as required.

Step 3: Configure your Serial Ports

Launch the minicom program from your terminal and input the following settings after navigating through the minicom menu (Ctrl A -Z):
Select the device: ttyS0 or ttyS1 (Depending on whatever device name is being assigned to your serial port)
Buad Rate: 57600
Bits per second: 8
Parity: None
Stop Bits: 1
Hardware Flow Control: Yes
Software Flow Control: No

Here is an example of the settings:

serial_testing

Once you configure your Serial Port with above parameters, you are ready to start communicating between the two computers through Serial Connection.

Step 4: Start communicating

Before you can start communicating, you need to perform the Steps 2 and 3 on your other computer also. Once you do that you should be in a state where you have minicom window in front of you on both the computers.

Now start typing some characters from computer A (in your minicom window typing screen) and you should see those characters appearing auto-magically on your computer B. For example like this:

screenshot-1

Errors?

Note: In some case, you might get an error as follow as soon as you try to launch “minicom” program:
#minicom

minicom: WARNING: configuration file not found, using defaults
Device /dev/modem access failed: No such file or directory.

All this means is that you need to pass on the flag -s when you launch minicom like this:
#minicom -s
Once you do that you should be able to select your serial port device and other parameters.

That’s it! You have successfully detected and tested Serial Ports on Debian Linux.

If you are further interested in this topic, then I high recommend you to read the following articles:

  1. http://www.cpqlinux.com/serialconsole.html
  2. http://www.vanemery.com/Linux/Serial/serial-console.html

As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.

Learn how to redirect Linux console messages over Serial Ports on another machine.

Be Sociable, Share!