[Solved]Socat AT commands Quectel EC25

i have router zbt with OpenWrt 21.02 with 4g modem on it
Modem model :Quectel EC25

I need to get answer from modem into variable
so i write ash script:

#!/bin/ash
getinfo=$(echo -e ATI | socat - /dev/ttyUSB3)
echo " $getinfo "

And i cant get any information in terminal
But if i use

socat - /dev/ttyUSB3,crnl

and then put AT commands it is all good but no answer if it is in the script answer into $getinfo

root@OpenWrt:~# response=$( echo "ATI" | socat - OPEN:/dev/ttyUSB1,crnl,ignoreeof )
root@OpenWrt:~# echo "$response"
ATI
Manufacturer: huawei
Model: E3372
Revision: 21.200.07.00.00
IMEI: <censored>
+GCAP: +CGSM,+DS,+ES

OK
1 Like

well i did like you did but noothing

root@MakarSklad:~# echo "ATI" | socat - OPEN:/dev/ttyUSB3,crnl,ignoreeof
root@MakarSklad:~# response=$( echo "ATI" | socat - OPEN:/dev/ttyUSB1,crnl,ignoreeof )
^C
root@MakarSklad:~# ^C
root@MakarSklad:~# response=$( echo "ATI" | socat - OPEN:/dev/ttyUSB3,crnl,ignoreeof )
root@MakarSklad:~# echo "$response"

root@MakarSklad:~# response=$( echo "ATI" | socat - OPEN:/dev/ttyUSB1,crnl,ignoreeof )
^C
root@MakarSklad:~# ^C
root@MakarSklad:~# response=$( echo "ATI" | socat - OPEN:/dev/ttyUSB1^Crnl,ignoreeof )
root@MakarSklad:~# ^C
root@MakarSklad:~# echo "ATI" | socat - OPEN:/dev/ttyUSB3,crnl,ignoreeof
root@MakarSklad:~# echo "ATI" | socat - OPEN:/dev/ttyUSB0,crnl,ignoreeof
root@MakarSklad:~# echo "ATI" | socat - OPEN:/dev/ttyUSB1,crnl,ignoreeof
^C^C^C^Z^Z^X^Z^C^C^V^[[A^[[A^C^C^X^Z^Z^A^A^C^C^Croot@MakarSklad:~# ^C
root@MakarSklad:~# ^C
root@MakarSklad:~# echo "ATI" | socat - OPEN:/dev/ttyUSB2,crnl,ignoreeof
root@MakarSklad:~# echo "ATI" | socat - OPEN:/dev/ttyUSB3,crnl,ignoreeof
root@MakarSklad:~#

tried difrent USB no luck ..
i use modem-manager for connection

Perhaps ModemManager, merely by virtue of keeping the port open, eats the response? Try stopping it and rechecking.

Anyway I vaguely remember that, when debugging is enabled, you can issue arbitrary AT commands via mmcli. Cannot check as I am not at home right now.

1 Like

i tried to use mmcli but got this respose

root@MakarSklad:~# mmcli -m /sys/devices/platform/101c0000.ehci/usb1/1-1/1-1.3 --command=ATI
error: command failed: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Unauthorized: Cannot send AT command to modem: operation only allowed in debug mode'
root@MakarSklad:~#

root@MakarSklad:~# mmcli -m /sys/devices/platform/101c0000.ehci/usb1/1-1/1-1.3
  -----------------------------------
  General  |                    path: /org/freedesktop/ModemManager1/Modem/6
           |               device id: 4f4298xxxfa6dd49xxxxxe05be4c80xxxx4422f9
  -----------------------------------
  Hardware |            manufacturer: QUALCOMM INCORPORATED
           |                   model: QUECTEL Mobile Broadband Module
           |       firmware revision: EC25ECGAR06A07M1G
           |          carrier config: default
           |            h/w revision: 10000
           |               supported: gsm-umts, lte
           |                 current: gsm-umts, lte
           |            equipment id: 8xxxxxx49118670
  -----------------------------------
  System   |                  device: /sys/devices/platform/101c0000.ehci/usb1/1-1/1-1.3
           |                 drivers: option1, qmi_wwan
           |                  plugin: quectel
           |            primary port: cdc-wdm0
           |                   ports: cdc-wdm0 (qmi), ttyUSB0 (qcdm), ttyUSB1 (gps),
           |                          ttyUSB2 (at), ttyUSB3 (at), wwan0 (net)
  -----------------------------------
  Status   |                    lock: sim-pin2
           |          unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                   state: connected
           |             power state: on
           |             access tech: lte
           |          signal quality: 100% (cached)
  -----------------------------------
  Modes    |               supported: allowed: 2g; preferred: none
           |                          allowed: 3g; preferred: none
           |                          allowed: 4g; preferred: none
           |                          allowed: 2g, 3g; preferred: 3g
           |                          allowed: 2g, 3g; preferred: 2g
           |                          allowed: 2g, 4g; preferred: 4g
           |                          allowed: 2g, 4g; preferred: 2g
           |                          allowed: 3g, 4g; preferred: 4g
           |                          allowed: 3g, 4g; preferred: 3g
           |                          allowed: 2g, 3g, 4g; preferred: 4g
           |                          allowed: 2g, 3g, 4g; preferred: 3g
           |                          allowed: 2g, 3g, 4g; preferred: 2g
           |                 current: allowed: 4g; preferred: none
  -----------------------------------
  Bands    |               supported: egsm, dcs, utran-1, utran-8, eutran-1, eutran-3, eutran-7,
           |                          eutran-8, eutran-20, eutran-28
           |                 current: utran-1, utran-8, eutran-3
  -----------------------------------
  IP       |               supported: ipv4, ipv6, ipv4v6
  -----------------------------------
  3GPP     |                    imei: xxxxxxxxxxxxxxxx
           |           enabled locks: fixed-dialing
           |             operator id: xxxxx
           |           operator name: MegaFon
           |            registration: home
  -----------------------------------
  3GPP EPS |    ue mode of operation: csps-2
           |     initial bearer path: /org/freedesktop/ModemManager1/Bearer/16
           |      initial bearer apn: public.mc
           |  initial bearer ip type: ipv4
  -----------------------------------
  SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/5
  -----------------------------------
  Bearer   |                   paths: /org/freedesktop/ModemManager1/Bearer/17

It says AT command allowed only in debag mode , but woud the modem still working normally in debag mode ?
i need to get signal levels while modem is working

The signal levels can be obtained without running AT commands manually.

mmcli -m 0 --signal-get

Regarding the debug mode - it won't affect the connectivity. It's ModemManager who is in debug mode, not the modem itself. Just edit the script in /etc/init.d, and add the --debug option to the ModemManager command line there.

1 Like

Well i googled commands for mmcli but there wasnt all options apparently but i did find it in mmcli --help-all
Anyway thanks a lot ! :smiley:
But i also need to see which station i connected to , maybe there is an otion for it ?

Oh i find it!!! and it works ))

--location-get

Yes there is, exactly where you found it :slight_smile:

mmcli -m 0 --location-enable-3gpp
mmcli -m 0 --location-get

You will get the mobile country code and mobile network code, as well as the cell ID.

1 Like

Yeah all seems works ! Thanks a lot ! :slight_smile: :slight_smile:

:joy: and now i am looking for option to get which band the modem connected to

well no it wont give me band

root@MakarSklad:~# /root/getrsi.sh
  --------------------------
  3GPP |      operator code: 250
       |      operator name: 2
       | location area code: FFFE
       | tracking area code: 149A
       |            cell id: 07EFE102
  ----------------------
  Signal | refresh rate: 3 seconds
  ----------------------
  LTE    |         rssi: -42.00 dBm
         |         rsrq: -9.00 dB
         |         rsrp: -74.00 dBm
         |          s/n: 4.40 dB

no band :face_with_diagonal_mouth: :face_with_diagonal_mouth:
band or frequincy

It is not currently possible to get the current band via mmcli without resorting to manual AT commands. Please refer to this feature request: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/226

BTW, the manual page of mmcli recommends using the --output-keyvalue option in shell scripts if you need to get the information in machine-readable form.

1 Like

YEah option -K gives better answer for grepping paramets
also i have to use

mmcli -m /org/freedesktop/ModemManager1/Modem/6

not

mmcli -m 0 (doesnt work for me)

and everytime modem is rebooted the link changes like not it is /org/freedesktop/ModemManager1/Modem/7

so i did this and all fine

modemlink=$(mmcli -K -L | grep "modem-list.value" | awk '{print $3}')

location=$(mmcli -m $modemlink -K --location-get )
sleep 1
siglvls=$(mmcli -m $modemlink -K  --signal-get)

mmcli -m 6

is a shorthand for

mmcli -m /org/freedesktop/ModemManager1/Modem/6
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.