How do I establish AT command communication with EC25E directly with the device port?
We are trying to capture phonecall information directly from the modem (as well as incoming caller number).
So taken from modemmanager, details about the firmware and driver:
Driver says it exposes multiple device file handles, namely ttyUSB2 and ttyUSB3 both apparently being used for at commands.
When using modem manager directly to send a raw AT command, we get a reply.
Command: mmcli -m 0 --command=‘ATI’
Response:
response: ‘Quectel
EC25
Revision: EC25EFAR08A02M4G’
However when we use pyserial module, whatever we write into the port, we just read empty strings back.
Changing parameters as well as sleep timings does not play an effect, we always get empty response.
Example code below:
import serial
import time
port = "/dev/ttyUSB2"
baudrate = 115200
command = "ATI"
payload = bytes(command, 'utf-8')
ser = serial.Serial(port=port, baudrate=baudrate, bytesize=8, timeout=1)
ser.close()
ser.open()
ser.write(payload)
time.sleep(0.1)
read_val = ser.read(size=64)
print(read_val)
This is in addition to requiring the termination character \r:
ModemManager normally controls both AT ports available on the modem. If you want to use pyserial you can free one of the ports using a udev rule. It can work even if ModemManager uses it, but in my experience the communication is unstable.
You can check if the ports are in use by a program using fuser or lsof.
The idVendor and idProduct are for an EG25-G module in this case. Also there are 2 rules bc. we use information from different levels of the udev system.
It should also possible to rewrite the official udev rule instead of creating your own. For my system the file is at /lib/udev/rules.d/77-mm-quectel-port-types.rules.
Search for a line like the following and adjust it (guess ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="0" to disable):