Ubuntu using com-port minicom. Connecting to Cisco from Linux and FreeBSD We receive and send characters using the com port in the console

Minicom is a program for using the serial port in UNIX-like operating systems (analogous to Hyper Terminal in Windows).
IN in this example Let's look at how the minicom program works with the Huawei E171 modem in operating system Ubuntu.

First, let's insert the 3G modem into USB port computer and see if Ubuntu OS sees it by typing the command in the terminal:

We'll see everything USB devices, connected and recognized by the system.

Among them there should be a line similar to this:

Bus 002 Device 005: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem

Now you need to find the modem itself in the /dev/ directory by typing the command in the terminal:

Among the many devices appeared:

ttyUSB0
ttyUSB1
ttyUSB2

This is a 3G modem

If the minicom program is not installed on the system, then you need to install it by typing the command in the terminal:

sudo apt-get install minicom

To work with a specific port, you need to configure the configuration file by typing the command in the terminal:

The minicom configuration environment will start


Moving through the menu using the arrow keys (up or down), to the item “Setting up the serial port”, select this item by pressing Enter. The serial port setup menu appears.


In the "Serial port" item you need to install the device /dev/ttyUSB0; to do this, press the A (Latin) key and change the device file name. After editing, press Enter twice.
We don't change anything else in the settings. Use the arrow keys (up or down) to go to “Save settings as dfl” and press Enter. Next, exit the minicom configuration environment by pressing Esc or selecting the Exit menu item and get into the minicom program itself to enter AT commands.


The message "OK" in the window indicates normal operation of the modem. To verify this again, type AT and press Enter. The response should be "OK".
Now you can use AT commands to switch operating modes in Huawei and ZTE modems. These commands are given in the article AT commands for Huawei and ZTE modems.
To exit the minicom program you need to press Ctrl+A and then the Q key.

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.

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

Configuration of various switches, routers and other equipment is usually done through a serial COM port (RS232). First you need to find and connect the computer and the switch (via a COM port or USB adapter) with a suitable console cable. In this article we will look at how to configure it in Linux OS.

Setup via minicom

First of all, you need to find the settings for the console com port in the equipment documentation. To connect under Linux, you need to install the minicom program. Let's install from the package under Debian (ubuntu):

Aptitude install minicom

In order for minicom to see Cisco, it must be configured correctly, launch with the key:

Sudo minicom -s

Go to the Serial port setup and change the values ​​of Speed/Parity/Bits (Bps/Par/Bits) to 9600 8N1.

We change the serial port (Serial Device) to the port to which the equipment is connected and configure the Flow Control parameters. In this example, this is /dev/ttyS0 - the address of the COM1 port. When connected via a mini-usb connector, the port may be /dev/ttyACM0.

Help on commands can be obtained by pressing Ctrl+A then Z.

As a result we get standard settings for Cisco and HP procurve:

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 configuration as the default settings in the minicom main menu (Save setup as dfl), or as a configuration with specific name(Save setup as..).

To exit minicom, press Ctrl+A then Q.

Or with saved settings.

Minicom<имя_конфигурации>

And this is an example of settings for 3com(hp) 4210 and 4500 switches

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

The /dev/ttyUSB0 device is usually used when connecting via a usb->com adapter. The speed of 19200 is sometimes 115200 used on 3COM (now HP) switches, and they do not understand any other speed. So before connecting, you need to carefully read in the documentation what speeds and flow control you need to set. However, sometimes the connection parameters are written directly on the device next to the console port.

Settings via the cu utility

You can connect to the console with the command

Chown uucp /dev/ttyUSB0 cu -s 115200 -l /dev/ttyUSB0

If you do not set chown rights to the device file, you may receive the following message:

/dev/ttyUSB1: Device busy

The main advantage of the cu utility is that it works equally well under Linux and under freebsd, only the names of the devices differ.

On freebsd it will look like this:

Chown uucp /dev/сuaa0 cu -s 115200 -l /dev/сuaa0

The only thing you need to do is select the correct device file where the device is connected.

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.

The 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 the modem's maximum data compression speed. 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 message "OK" in the window indicates normal operation of the modem. To verify this again, type AT and press Enter. The response should be "OK"

AT OK

Computer