Using AT commands with an Android phone

a 夏天 提交于 2019-12-11 06:39:22

问题


I'm writing a program that is able to send and receive data from the GSM modem in my Android phone with AT commands.

I execute the following shell script:

su
echo -e "AT+CSQ?\r" > /dev/smd0
cat /dev/smd0 > /dev/asd.txt

The asd.txt file is created, however there is nothing in it (it should write out the signal strength). It looks like it hangs at the cat command, I think because it doesn't get any output. I've tried some other commands, but I had no luck so far. Can you recommend anything?


回答1:


You can try to use the atinout program, it should behave like the following:

$ echo AT+CSQ | atinout - /dev/smd0 -
AT+CSQ
+CSQ: <rssi>,<ber>

OK
$

Run as ... - /dev/smd0 /dev/asd.txt if you want to capture the results like in your code. Notice that you should run AT+CSQ, not AT+CSQ?.

(the Makefile in atinout-0.9.tar.gz needs a small change to compile, the git source is fine).



来源:https://stackoverflow.com/questions/16404344/using-at-commands-with-an-android-phone

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