Using minicom to enter modem AT commands. Connecting to Cisco from Linux We receive and send characters using the com port in the console

on two Linux hosts with a com port, let's see with the command

Add a user to the dialout group

user NameUser, from which we will

Usermod -g dialout NameUser

Let's check whether the user has been added to the group:

Id NameUser

We receive and send characters using the com port in the console

Let's open a terminal on the Linux host and, to wait for characters to be received on the com-port, type the command

Cat /dev/ttyS0

Let's send console symbols from another Linux host

Echo 1 > /dev/ttyS1

You should see in the console of the first host on com port ttyS0 the symbols that were sent from the second host via com port ttyS1

Checking whether the minicom package is installed

aptitude show minicom

If necessary we install

Sudo apt-get install minicom

Initial configuration of the minicom package

let's type (you need to configure as root, otherwise the configuration settings will not be saved)

Minicom -l -8 -c on -s

where are the keys:
l - ANSI Displays – Graphics
8 - Eight-bit input mode for Russian language
with on - Turn on color display
s - Launch the minicom configuration utility

Make the settings
Directories and files - Directory for receiving - Directory for sending
Serial port setup - Serial port (for example /dev/ttyS0) - Baud/parity/bits
Save the configuration - Save setting as dfl
Clicking Exit Minicom will take you back to the console

Launch minicom

with the parameters you just saved as default, type in the console:

Minicom -l -8 -c on

minicom Device /dev/ttyS is locked

After using minicom, an old lock-file remains, which prevents it from working normally
minicom -> Device /dev/ttyS0 is locked
Device /dev/ttyS0 is locked
To restore functionality, simply delete the lock file in the /var/tmp or /var/lock directory
The location of Lock files is specified
minicom -l -8 -c on -s -> Serial port setup -> B - Lock file location

Minicom

Introduction

Minicom is a text-based serial port communications program. It is used to talk to external RS-232 devices such as mobile phones, routers, and serial console ports.

Installation

Install the program with:

sudo apt-get install minicom

Alternatively, you can get Minicom via the Synaptic Package Manager.

Using the program

In order to find the name of your port(s) enter this command in terminal:

dmesg | grep tty

If it is a direct serial connection, the output will be something like this:

[ 22.587279] console enabled [ 24.186230] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 24.186860] 00:08: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 51.598012] audit( 1243322582.732:2): type=1503 operation="inode_permission" requested_mask="a::" denied_mask="a::" name="/dev/tty" pid=5705 profile="/usr/sbin/cupsd" namespace= "default"

For a USB-to-Serial adapter, one may see:

[ 0.000000] console enabled [ 5.065029] usb 4-3: pl2303 converter now attached to ttyUSB0

What we are interested in is the name of the serial port. In the first section above it is ttyS0, the other is ttyUSB0. which we will need in order to use Minicom. Next, enter in a terminal enter:

sudo minicom -s

One will next choose "Serial port setup". Then, adjust the Serial Device to the device one has, for example:

A - Serial Device: /dev/ttyS0

Next, one will want to consult the hardware vendor's manual for the Bits per second, data bits, Parity, stop bits, and Flow control. Once these have been adjusted, one may want to also go to the Modem and dialing menu and remove all information in setting options A through I. Once configured, one may "Save setup as dfl", which will save these as the default configurations for future connections (/etc/minicom/minirc.dfl Once saved, one may choose). Exit, and one is at the minicom prompt. Hit enter, and you may be asked for your username, indicating a successful connection.

To exit Minicom when in terminal mode press "Ctrl-A" to get a message bar at the bottom of the terminal window and then press "X".

Another useful Option is to log all information to a file which will be saved in your Home directory. Select "Filenames and paths" and press "F" (Logging options). By default this will be saved as "minicom.log", but change it to whatever you like with the "A" key. Press "Enter" to save the changes.

Run "minicom -s" and select the "Serial port setup" menu item.

The first item is "Serial Device" - this is the most important setting: your modem connects to a serial device. (Who wants to make minicom work with several serial devices at the same time?) Press return to confirm and esc to exit to the initial settings menu. Select "Exit to minicom" and type "atdt99999". Your modem will immediately begin dialing the number and you will hear a click when the modem goes off-hook. Of course, "99999" is a non-existent number.

2.2 Starting PPP manually

You may have tried to call your provider's phone number instead of "99999". Did you see random characters on the screen after registering (if not, type "ppp")? They indicate that "pppd" (or its equivalent) is running on the other end of the line. If this is the case, then on your part you can try to start the "pppd" daemon and subsequently evaluate the contents of the log files.

To run "pppd" inside minicom, you can define a new upload method "upload" (that is, from you) or override the "kermit programm" setting from the "Filename and paths" configuration menu:

A - Download directory: B - Upload directory: C - Script directory: D - Script program: /usr/bin/runscript E - Kermit program: /usr/sbin/pppd file /etc/ppp/mini_options
Now, if you've seen these random characters, the next time you call your ISP you can press Alt-K to launch "pppd".

The remainder of this mini-HOWTO is devoted to automating logging and running pppd.

2.3 Studying logs

While I'm not going to explain how PPP is configured, I will briefly describe how to read the logs. To extract significant information from the log "/var/log/debug" (or "/var/log/daemon.log") run the commands

tail -n 40 /var/log/debug |\ grep -E " pppd\[*\]:" |\ sed -e "s/^.*pppd\ rcvd
which indicate that we sent a request to set the maximum receive block size (mru) to 296. The other side rejected this setting ("configuration rejected"). In this case I only removed the "mru" option from the "/etc/ppp/options" file (see below).

2.4 Setting up phone numbers

If the above steps were successful, you may want to save phone number in the minicim database. Press Alt-D to bring up the call menu and use the cursor keys to select "Edit":

A - Name: Xeno B - Number: 022039697303 C - Dial string # : 1 D - Local echo: No E - Script: /etc/ppp/login.script F - Username: ppp-382 G - Password: top-secret H - Terminal Emulation: VT102 I - Backspace key sends: Delete J - Linewrap: Off K - Line Settings: Curr 8N1
This is an example entry for one of my providers. The script "/etc/ppp/login.script" is shown below. This script has two special variables: $(LOGIN) and $(PASS), which set the username (F) and password (G) values. This feature gives minicom some flexibility because you only need one script to automatically connect to multiple providers.

2.5 Registration scenario

"minicom" runs the login-script after it receives the "CONNECT" string. To be precise, "minicom" does not execute the script itself, but calls the "runscript" utility as a child process to do so.

Below is the example I use for my provider.

# v1.0, 08.20.96 Winfried Trêmper print "" print "Automatic login via /etc/ppp/login.script" ## uncomment if you need to push to ## get the prompt string #send "" expect ( "ogin:" "ogin>" "sername:" "sername>" "NO CARRIER" exit 1 ) send "$(LOGIN)" expect ( "assword:" " assword>" timeout 20 ) send "$(PASS)" expect ( "port" send "ppp" "Start your PPP now" ")!}" timeout 10 } print "" print "Сейчас переключаемся в ppp-режим..." print "" ! /usr/sbin/pppd file /etc/ppp/mini_options print "" print "команда killall -TERM pppd прекращает работу pppd" !}

To start "pppd" it uses the ability of "runscript" to call external programs. Copy your own options file for ppp to "/etc/ppp/options.ttyS1" (here you can replace "ttyS1" with the device your modem is connected to) and remove all lines from /etc/ppp/options that refer to your modem (like "connect", "crtscts" or "modem"). Paste the options that are specific to the ppp connection via minicom into "/etc/ppp/mini_options". One of these options would be

disconnect "chat "" "\d\d+++\d\dATH\r\c""
This option must be there because "pppd" reads data via standard input and cannot force the modem to hang up via "crtscts".

2.6 Automatic dialing at startup

To call a specific number when starting minicom, use the "-d" option. Also you can try

to transfer minicom to another console (see Consoles-Many mini-HOWTO).

2.7 Future extensions

Since "pppd" is a daemon, it is not intended for user interaction or monitoring. This is true. And after all this we use Unix...

The canonical solution is behind us. Any volunteers to hack minicom? The desired extensions are:

  • automatic creation of a registration script based on the sequence of actions performed by the user when establishing a connection manually
  • automatic evaluation of logs with adjustment of options
  • highlighting messages like those mentioned in paragraph 2.3.
Next

Using minicom to test a modem

The first step in using minicom is to create a global configuration file. To do this, you need to run minicom with the -s flag, logging in as the root user.

#minicom -s This command launches the minicom configuration environment (Fig. 18.8).


Rice. 18.8. Configuring minicom

Navigate through the menu using the up and down arrow keys, and select a menu item by pressing Enter.

Most important parameters are hidden behind the Serial Port Setup menu command in the Serial Port Setup dialog box (Figure 18.9).



Rice. 18.9. Serial Port Configuration

To change a value, press the key with the corresponding letter. First of all, you need to install the serial device by pressing the "A" (Serial Device) key and specifying the appropriate device file. If the modem is connected to the second serial port, you can specify /dev/ ttyS1 due to the use of minicom for outgoing connections.

Note

If the serial port is already connected to /dev/modem, as shown in Fig. 18.9, check its connections using the command ls -I /dev/modem. If the connection to a specific serial port is displayed, then no changes are needed.

It is also necessary to configure parameter E (Bps/Par/Bits - Speed/Parity/Stop Bits) in accordance with the requirements of the modem and the system to which you will connect (usually the Internet provider system). After pressing the "E" key, the communication parameters window will open (Fig. 18.10).

Rice. 18.10. Configuring Communication Settings

The current parameter values ​​are shown at the top of the window. To modify any of them, press the key with the corresponding letter.

For Speed, select a value equal to maximum speed modem when compressing data. Typically this value is four times its rated speed. For example, for a modem with a speed of 14.4 Kbps, you should set the value to 57,600 bps, for a 28.8 Kbps - 115,200 bps. A 56Kbps modem is set to 115200bps or 230400bps (if available).

As a rule, in modern systems the parity bit is not used, 8 data bits and one table bit are used (option Q). Find out the correct values ​​for the remaining parameters from the administrator of the system to which you will connect.

Return to the Serial Port Setup window by pressing Enter. Pressing Enter again returns you to the main menu.

This information should be enough to test the modem. Save the modified set of parameters as the default configuration by executing the Save Setup as Dfl menu command. After executing the Exit menu command, complete the configuration procedure and continue working in the minicom terminal emulator window (Fig. 18.11) with the set parameters.



Rice. 18.11. Main window of the minicom program

The "OK" message in the window indicates normal operation modem To verify this again, type AT and press Enter. The response should be "OK"

AT OK

The article discusses the simplest way connecting to a Cisco terminal from a Linux environment. Initially, you need to connect the console cable to the COM port of the machine with Linux OS installed and to the port console on Cisco. To connect to the Cisco console, you must install minicom package. Installation varies depending on the distribution. This example describes installation from Linux Debian.

aptitude install minicom

Minicom is in the repositories of most distributions, so installing it should not cause any difficulties.

Setting up minicom

For minicom to work correctly with Cisco, it is necessary to perform its initial setup.

  1. Go to the Serial port setup and change the value of Speed/Parity/Bits (Bps/Par/Bits) to 9600.
  2. We change the serial port (Serial Device) to the port to which the Cisco equipment is connected. In this example, this is /dev/ttyS0 - the address of the COM1 port.

As a result, you need to get the following settings:

A - Serial Device: /dev/ttyS0
B - Lockfile Location: /var/lock
C - Callin Program:
D - Callout Program:
E - Bps/Par/Bits: 9600 8N1
F - Hardware Flow Control: Yes
G - Software Flow Control: No

We save the changed configuration as the default settings in the minicom main menu (Save setup as dfl), or as a configuration with specific name(Save setup as..).