且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 root 的 android 上执行 at 命令并得到结果

更新时间:2023-08-18 10:59:40

首先,我认为您只是将 AT 命令发送到 shell 中的 stdout,除了给您回读的回声之外,它不会做任何事情.要使这种方法起作用,您必须将 echo 命令重定向到串行端口设备文件.Android 手机为此使用各种设备,/dev/ttyGS0/dev/smd0 似乎是通用名称.

First I think you are just sending the AT command to stdout in the shell which will not do anything other than giving you an echo which you read back. For this approach to work you have to redirect the echo command to the serial port device file. Android phones use various devices for this, /dev/ttyGS0 and /dev/smd0 seems to be common names.

不过,我建议使用 atinput 程序来发送 AT 命令并捕获调制解调器响应.它是专门编写的,可以像这样从命令行使用.这将使您免于直接与调制解调器通信,剩下的唯一事情就是处理读取响应的管道.

However I would suggest using the program atinput to send AT commands and capture modem responses. It is specifically written to be used from the command line like that. That will relieve you from communicating directly with the modem and the only thing left is the pipe handling reading the response.