Linux modem at command

Как отправить AT-команды на модем в Linux?

В Linux (Ubuntu) я пытаюсь отправить AT-команды модему по адресу /dev/ttyACM0 . Я пытался сделать это так:

но при наборе чего-либо я просто получаю строку, повторяющую эту команду (я ожидаю OK ).

это похоже на работу. Я печатаю AT и получаю OK . Я набираю немного дерьма, я получаю ERROR .

Похоже, что modem1 для minicom как-то настроено использование модема на /dev/ttyACM0 .

Как я могу использовать socat для отправки AT-команд? Нужно ли что-то настраивать? Может быть, я могу использовать конфигурации для modem1 Minicom (я не знаю, как найти / увидеть эту конфигурацию)?

Дополнительная информация

Является ли данная socat команда правильной? Должен ли я играть с некоторыми вариантами? С -v опцией я вижу следующее:

Само устройство найдено со следующим выводом dmesg:

И tty настроен следующим образом:

Пытаться socat — /dev/ttyUSB2,crnl

Это говорит socat отправить возврат каретки, а также перевод строки.

Разъяснение — это восходит к темным дням электрических пишущих машинок, где вы должны сказать ему откатить каретку до позиции 0 на странице — эрго, возврат каретки — а также сказать ей переместить бумагу вверх на одну строку ,

Лучший способ отправить AT-команды модему в Linux — это использовать программу atinout, написанную с единственной целью отправки AT-команд модему из командной строки.

Вы можете использовать его для проверки работоспособности модема , сделав резервную копию телефонной книги:

или любые другие вещи, для которых вы используете команды AT.

Я наткнулся на этот пост проекта Chromium, который показывает, что вы хотите. Это называется: Отладка сотового модема .

выдержка из этой страницы

Связь напрямую с модемом с помощью набора AT-команд

Большинство модемов поддерживают AT-команды, которые управляют модемом и запрашивают информацию. На устройстве Chromium OS с включенным режимом разработчика вы можете использовать команду socat для связи с модемом. Вам необходимо устройство с ОС Chromium с установленным тестовым образом (или вы можете использовать gmerge socat, если вы знакомы с сервером dev). Например:

  • Введите CTRL + ALT + T, чтобы войти в оболочку.
  • Введите shell, чтобы войти в оболочку bash.
  • Определите, какое USB-устройство использовать с: ls / dev / ttyACM * / dev / ttyUSB *
  • Остановите менеджер модема, если он работает: sudo stop modemmanager
  • Введите sudo socat — / dev / ttyACM1, crnl или sudo socat — / dev / ttyUSB0 для связи с модемом.
  • Убедитесь, что модем включен с помощью команды: «AT + CFUN = 1»

В зависимости от модема вы можете попробовать разные AT-команды, например, «AT + CGMI», «AT + CGSN» и т. Д.

Источник

How to send AT commands to device

AT commands (“attention commands” formally, the Hayes command set), are used to communicate directly with a modem device and configure it.

From OpenWrt

To send AT commands directly from OpenWrt, you can simply use echo to send them to the right device. However, you will not get any errors, confirmation or any other answer from the modem.

Читайте также:  Как установить аудиоустройство windows 10

A better solution is to use socat , which can both send commands and print the modem’s answers.

socat

socat will open a prompt where you can enter AT commands (see examples in the section below).

For instance, to access a Quectel EP06 LTE modem, which creates 4 devices ( /dev/ttyUSB0 through to /dev/ttyUSB3 ):

(Here, socat sends a carriage return (cr) and a new line (nl) after each command, which seems to be needed for this modem.)

To find the device on which to run socat , try looking through dmesg . Something like the following may help:

Some modems also show up as a ttyACM device.

To quit socat , use ctrl+C .

Use echo -e so as to be able to escape characters such as “ .

From a computer

To send AT commands to a LTE modem, you need to first connect the device/modem to the computer, most likely using an adapter (built-in modem slots are very rare these days) and access it with a COM terminal.

If you are not familiar with using COM terminals, you might want to use a graphical tool like: CuteCom or minicom . Installation of these are beyond the scope of this page.

These settings should work fine:

Examples of AT commands

To test things are working, you can issue ATI which should return basic information such as brand, model and firmware revision.

AT+CSQ can be used to get signal strength. The values returned are the RSSI (received signal strength indication,higher is better) and BER (bit error rate, lower is better)

Here is example for the Huawei E392 LTE/3G dongle:

Modem configuration is split into 2 parts: before ; and after.

Once a modem is plugged-in, it should declare itself in first configuration (normally with at least: A1 — virtual CD drive with Drivers and application). If the drivers are installed, they will see the modem and issue a special command to switch to a “working” configuration — this is 2,7 interfaces in this example.

Warning: Never turn Off PC interface! (2:PCUI in this example) You will lose the ability to access modem with terminal and change the configuration.

You can add more interfaces to be active i.e. SD card:

If you get an ERROR, maybe the numerical mode is not sorted (16,2,7)→(2,7,16). If your device answers to set command with OK but AT^SETPORT? doesn’t show your desired settings, you can try using space in between numerical modes(2,7) and alphabetical modes(A2) like so:

Or with multiple modes:

How to force LTE connection

Format:

Parameters

Examples:

Set modem to LTE only:

Set it back to “auto”:

Further references

  • Last modified: 2021/03/28 08:24
  • by mwynn

Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.

Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International

Источник

Выполнение AT/USSD команд к /dev/ttyUSB* модему из консоли Linux

Утилиты и скрипты для коммуникации с /dev/ttyUSB* устройством из shell консоли (bash скриптов).

Теория

Отправить в /dev/ttyUSB* терминал AT команду не составляет проблем. Но результат вывода мы не увидим!

Мы можем читать поток stdout c /dev/ttyUSB2 (результат выполнения команд):

  1. Нужно получить только результат выполнения конкретной AT команды, а не весь поток вывода.
  2. Нужно использовать gsm7bit кодировку для кодирования параметров и получения ответа при выполнении USSD запросов:
  3. Ну и хочется простоты в работе)

Выполнение AT/USSD команд

Скрипт at.sh для отправки AT команды и получения ответа в переменную:

Читайте также:  Синхронизация каталогов windows server

Но вы получите ответ вида:

minicom

Можно отправить AT команду и перенаправить весь вывод в файл:

После этого нужно закрыть терминал и разобрать/декодировать весь вывод из файла output.txt. Не круто..

ussd.py

В сети нашел python скрипт для отправки USSD запросов (немного поправил):

Кодировка GSM 7bit в USSD запросах

Кодирование в gsm7bit

При отправке USSD запросов нужно кодировать USSD-код в кодировку GSM 7bit (как я понял из-за того, что модем не поддерживает текстовый режим).

Следующие запросы вернут ERROR:

Python функция gsm7bitencode для кодирования utf8 строки в gsm7bit:

Примечание

Смотрите онлайн-сервис для работы с кодировками: http://smstools3.kekekasvi.com/topic.php?id=288

Пример USSD команд в кодировке 7bit gsm проверки баланса:

Кодированные ответы (ответ всегда приходит на устройство /dev/ttyUSB2):

Декодирование из gsm7bit

Python функция gsm7bitdecode для декодирования gsm7bit в utf8:

Источник

How to send AT commands to a modem in Linux?

In Linux (Ubuntu) I am trying to send AT commands to a modem at /dev/ttyACM0 . I tried to do it as:

but when typing anything I just get a line repeating this command (I expect an OK ).

it seems to work. I type an AT and get an OK . I type some crap, I get an ERROR .

It seems that modem1 for minicom is somehow configured to use the modem at /dev/ttyACM0 .

How can I use socat to send AT commands? Do I need to configure something? Maybe I can use configurations for modem1 of minicom (I do not know how to find/see this configuration)?

Additional information

Is the given socat command correct? Should I play with some options? With the -v option I see the following:

The device itself is found with the following dmesg output:

And the tty is configured as follows:

5 Answers 5

Try socat — /dev/ttyUSB2,crnl

This tells socat to send a carriage return as well as a line feed.

Clarification — this goes back to the dark days of electric typewriters, where you would have to tell it to roll the carriage back to position 0 on the page — ergo, a carriage return — as well as telling it to move the paper up one line.

The best way to send AT commands to a modem in Linux is to use the program atinout which is written with the sole purpose of sending AT commands to a modem from the command line.

You can use it to test if a modem is up and running, make a backup of the phone book:

or any other things you make use of AT commands for.

I came across this Chromium project post that shows what you want. It’s titled: Debugging a cellular modem.

excerpt from that page

Communicating directly with a modem with the AT command set

Most modems support AT commands which control the modem and query for information. On a Chromium OS device with the developer mode enabled, you can use the socat command to communicate with the modem. You need a Chromium OS device with a test image installed (or you can use gmerge socat if you are familiar with the dev server) . For example:

  • Type CTRL+ALT+T to enter the crosh shell.
  • Type shell to enter the bash shell.
  • Figure you which USB device to use with: ls /dev/ttyACM* /dev/ttyUSB*
  • Stop modem manager if it is running: sudo stop modemmanager
  • Type sudo socat — /dev/ttyACM1,crnl or sudo socat — /dev/ttyUSB0 to communicate with the modem.
  • Ensure that the modem is enabled with the command: «AT+CFUN=1»

Источник

5 Modem At Command Examples in Linux (How to Configure Minicom)

AT commands are instructions that are used to control modems.

AT stands for ATTENTION.

These commands come from Hayes at commands that were used by the Hayes smart modems in 1980’s. Many modems today including dial-up, wireless, GSM/GPRS modems use these AT command set for communication.

Читайте также:  Back to bed windows

There are 2 types of modem AT commands.

  • Basic commands
  • Extended commands

Basic commands are AT commands that do not start with “+”. Extended commands are AT commands that start with a “+”. All GSM/GPRS uses the extended commands for SMS/DATA services.

Task which can be done by using AT commands

Here are few list of tasks which can be done by using the AT commands.

  • Get basic information about the subscriber
  • Get the information about signal strength and battery strength
  • Establish a data/voice connection
  • Send and receive fax
  • Send and receive SMS
  • Read/Search phonebook entries

Note that not all modems will support all the AT commands.

In this tutorial, I’m going to show examples using my “Nokia 2700” mobile phone which has a inbuilt GSM/GPRS modem.

Installing minicom

In-order to send AT commands to modems, we need an interface. Minicom is a tool which provides an interface for communicating with devices that are connected to serial ports. Minicom is a linux equivalent to the HyperTerminal utility in Microsoft Operating Systems.

Using minicom we can send AT commands to the modem to get information about its features.

Configuring minicom to interface with the modem

Before configuring minicom, we need to connect the modem to the linux system. In my case, I’ve connected my “Nokia 2700” via data cable to my linux PC. Once the device is connected, you will see output similar to the following using dmesg. In my case the modem got detected as /dev/ttyACM0.

To configure minicom to access modem, do the following:

Choose the “Serial port setup” and press “Enter”. It will display a screen similar to the following.

Press ‘A’ to change the serial device from /dev/tty0 to /dev/ttyACM0.

Press ‘E’ to change the Baud rate at which the modem communicates. In my case, it is “460800”. You can also used wvdialconf to identify the baud rate supported by your modem.

Once you change these settings, press “Enter”.

Choose “Save setup as dfl” and choose “Exit”.

Now we have configured the minicom successfully and you will see a screen like the following.

To test whether we have configured minicom successfully to communicate with modem, type “AT” in the minicom. You should get a “OK” response as follows.

1. Answer an Incoming call – ATA

To answer an Incoming call via modem, issue the “ATA” command in the minicom.

When there is an incoming call, you can see a ‘RING’ message in the minicom. You can press “ATA” to answer the incoming call.

2. Dialing out and hanging up a voice call – ATD – ATH

You can also dial out a voice call from the modem using ATD command.

Now the phone will dial out to the number 99769XXXXX.

To hangup the call, use ATH command.

3. Getting the Manufacture/IMEI/IMSI information

Extended AT commands are used to provide information about the manufacturer, International Mobile Equipment Identity, International Mobile Subscriber Identity etc…

4. Getting Signal quality and battery charge status

You can also get the signal quality and the battery charge status using AT extended commands.

The output format +CSQ: 29,99 represents ,

The output format +CBC: 1,96 represents ,

5. Sending SMS using AT commands

You can also send SMS via AT commands.

The command AT+CMGF=1 sets the “Message format” to “text mode”. The command AT+CMGS, send the SMS to the specified number. is used to terminate the message input.

Источник

Оцените статью