Friday, November 20, 2009

How do I configure minicom to communicate with a modem or serial device?

How do I configure minicom to communicate with a modem or serial device?



Release Found: Red Hat Enterprise Linux

Symptom:
Minicom is not able to communicate with a serial port device, such as a modem.

Solution:

The minicom program is a terminal emulation program included with Red Hat Enterprise Linux. It is a tool accessed from the command line. Minicom provides a terminal emulation interface for a serial device or a modem. It also has a text-based menu to access various features.

You will need to have the minicom package installed to use it. If regular users need to have access to minicom, then you will need to grant permission on the relevant device files. We have related articles to help.

In addition you will also need to know the capabilities of the device you are connecting to. For a modem it is usually safe to use a speed of 57,600 baud (number of 8-bit characters per second). Other serial devices may communicate at a different rates. Please note, that this rate is the speed between your computer and the device. In the case of the modem to modem signaling rate this speed may be different depending on the device.

Most present day serial devices support 8 data bits, No parity, and 1 stop bit. If the these settings are different for your device then make a note of it.

You will get the fastest and most reliable connection with a device that supports Hardware (i.e. CTS/RTS) flow control. This option is often used with modems and generally is well supported. Other serial devices may or may not specify flow control capabilities. If the flow control setting is not specified in the specifications for the device, you are usually safe using no flow control.

To set the system-wide parameters in minicom you will need to execute minicom as root with the -s (setup) option. For example:

 
# minicom -s
 
            ┌─────[configuration]──────┐
            │ Filenames and paths      │
            │ File transfer protocols  │
            │ Serial port setup        │
            │ Modem and dialing        │
            │ Screen and keyboard      │
            │ Save setup as dfl        │
            │ Save setup as..          │
            │ Exit                     │
            │ Exit from Minicom        │
            └──────────────────────────┘ 
    



Generally, in Red Hat Linux, the serial devices are typically represented as follows:

/dev/ttyS0 -> First serial port (i.e. COM 1)
/dev/ttyS1 -> Second serial port (i.e. COM 2)
/dev/ttyS2 -> Third serial port (i.e. COM 3)
/dev/ttyS3 -> Fourth serial port (i.e. COM 4) (Note: that the device name uses a capatal "S" before the number) --or-- /dev/cua0 -> First serial port (i.e. COM 1)
/dev/cua1 -> Second serial port (i.e. COM 2)
/dev/cua2 -> Third serial port (i.e. COM 3)
/dev/cua3 -> Fourth serial port (i.e. COM 4) General Explination:The difference between the ttyS and cua devices is technical. Generally speaking if one doesn't work try the other. If both don't work then you have some other problem. Technical Explination: When connecting to the ttyS devices, they will "block" until the carrier detect line (DCD) goes high. The cua devices are "non-blocking" and will accept the connection even if there is no DCD signal.

Use the arrow keys to navigate the menu selecting the option "Serial port setup" first. Press [Enter] to select this option and another window will open (see below). The letters on the left side of the window are used to select which setting to modify. Most likely you will want to modify "A - Serial Device" to use one of the device files listed above. Press [Enter] once you are done typing the device name.

Next, choose option "E - Bps/Par/Bits". Another window will open displaying the possible communication parameters. Choose the baud rate (speed) on the left by pressing the corresponding letter (A - J). The 8N1 at the top of the window refers to the options 8 data bits, No parity, and 1 stop bit. If you need to change these settings, then press the corresponding letter for the new setting. When you are done, press [Enter] to exit the menu.

                                                            
    ┌───────────────────────────────────────────────────────────────────────┐
    │ A -    Serial Device      : /dev/cua0                                 │
    │ B - Lockfile Location     : /var/lock                                 │
    │ C -   Callin Program      :                                           │
    │ D -  Callout Program      :                                           │
    │ E -    Bps/Par/Bits       : 57600 8N1                                 │
    │ F - Hardware Flow Control : Yes                                       │
    │ G - Software Flow Control : No                                        │
    │                                                                       │
    │    Change which setting?                                              │
    └───────────────────────────────────────────────────────────────────────┘
            │ Screen and keyboard      │
            │ Save setup as dfl        │
            │ Save setup as..          │
            │ Exit                     │
            │ Exit from Minicom        │
            └──────────────────────────┘             
    



If required, you can change the flow control setting with option F and G. I would not recommend turning on both hardware and software at the same time. Software flow control is rarely used, Hardware is more common as is no flow control. Again, pressing [Enter] will exit this menu and take you back to the main configuration menu.

Next, arrow down to "Modem and dialing" and press [Enter]. You will get a screen full of options resembling the following:

 
 ┌────────────────────[Modem and dialing parameter setup]─────────────────────┐
 │                                                                            │
 │ A - Init string ......... ~~AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0               │
 │ B - Reset string ........ ~ATZ~                                            │
 │ C - Dialing prefix #1.... ATDT                                             │
 │ D - Dialing suffix #1....                                                  │
 │ E - Dialing prefix #2.... ATDP                                             │
 │ F - Dialing suffix #2....                                                  │
 │ G - Dialing prefix #3.... ATX1DT                                           │
 │ H - Dialing suffix #3.... ;X4D                                             │
 │ I - Connect string ...... CONNECT                                          │
 │ J - No connect strings .. NO CARRIER            BUSY                       │
 │                           NO DIALTONE           VOICE                      │
 │ K - Hang-up string ...... ~~+++~~ATH                                       │
 │ L - Dial cancel string ..                                                  │
 │                                                                            │
 │ M - Dial time ........... 45      Q - Auto bps detect ..... No             │
 │ N - Delay before redial . 2       R - Modem has DCD line .. Yes            │
 │ O - Number of tries ..... 10      S - Status line shows ... DTE speed      │
 │ P - DTR drop time (0=no). 1       T - Multi-line untag .... No             │
 │                                                                            │
 │ Change which setting?       (Return or Esc to exit)                        │
 └────────────────────────────────────────────────────────────────────────────┘



If you are using a modem, you may need to modify option A. See your hardware documentation for details. Generally the other default options are suitable for most modems.

If you are not configuring for a modem, I would recommend blanking out the strings for options A, B, and K.

The other options at the bottom can be set if required but the defaults are usually okay. Press [enter] to exit this screen.

You may find, while connected to your device that the [Backspace] key does not behave properly. If so, you will want to return to this menu and change the setting under Screen and keyboard

Lastly, choose "Save setup as defl" to save your default configuration. The "Configuration Saved" message should close on it's own in a few seconds. Choose Exit and your ready to test your setup.

If you ever need to return to this configuration menu from the terminal screen, press Ctrl+A, release, then press the letters "z" then "o".

For additional features and information on minicom you will find documentation for located under /usr/share/doc/minicom-/doc/


No comments:

Post a Comment