Talking to modem with AT commands on android

牧云@^-^@ 提交于 2019-12-07 07:39:07

问题


I'm trying to talk to samsung galaxy s2 plus and huawei p1 xl (u9200) modem sending AT commands, but can't get any result. I'm sending commands using adb shell and view logs with logcat.

In samsung when i execute cat /proc/tty/drivers i get the following:

/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster

rfcomm               /dev/rfcomm   216 0-255 serial
g_serial             /dev/ttyGS    237 0-3 serial
serial               /dev/ttyS       4 64-67 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
unknown              /dev/tty        4 1-63 console

Looks like i should send commands to /dev/ttyGS0, but it doesn't reply. I've tried the following commands:

echo "AT\r" > /dev/ttyGS0
echo "ATD12345678900;\r" > /dev/ttyGS0

but nothing happens. Actually, i'm not sure that i have to send commands to this file, but others don't reply too. I've read article on XDA-developers, but it didn't help.

With Huawei i know which file i should use, but i can't make data call. I can make regular voice call, but i can't execute AT+CSNS=4. Just doesn't work. Also i have LG P765, which is based on a similar chipset and on LG i can make data call. Can anyone tell me what should i do?

All devices are rooted.


回答1:


I suggest that you try to send AT command using the atinout program, e.g. instead of redirecting output to the modem device run

echo "ATD12345678900;" | atinout - /dev/ttyGS0 -

I am guessing, but it could be that the echo command in the adb shell does not interpret \r as anything special (that would at least explain no response whatsoever). By using atinout you are guarantied that AT command lines are properly terminated with \r and capturing should be simpler and work much more reliably.




回答2:


please try different ports available to check the results.

in my android its working under /dev/pts/7 port number.

also use different terminal to read and write

Terminal 1 :

echo -e "AT\r" > /dev/pts/7

Terminal 2 :

cat /dev/pts/7

also try using executing as a root user.



来源:https://stackoverflow.com/questions/17718545/talking-to-modem-with-at-commands-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!