0 Replies - 1451 Views - Last Post: 14 February 2012 - 05:51 PM

#1 romanb67  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-February 12

Sending AT Commands from ADB shell - cannot capture output

Posted 14 February 2012 - 05:51 PM

Hi all,

I cannot get around one issue (actually two of them) so I cannot proceed with further tasks.

So basically I am in Android phone's adb shell, communicating with the GPRS modem by sending AT commands.
I am able to do it by redirecting at command to the device file representing the modem; and I can read back
the response using cat utility running on the background (started earlier). I implemented it in a a script
which can send a single AT command and read back the response, for example, here is the script to
send at+cops? to get network operator the mobile is camping on:
#SendATCommand script:
cat /dev/pts/7 &
echo -e at+cops?\\r > /dev/pts/7



The output looks as follows:

# ./sendATCommand 
./sendATCommand 
# 
+COPS: 0,0,"AT&T",6 
 
OK 
/dev/pts/7: invalid length 



Now here are two problems which I cannot resolve:

1. I still need to manually press ENTER button to get back adb shell prompt "#". Is there a way to return
to "#" prompt programmatically? Again, I am in adb shell.
2. The displayed response cannot be captured, neither in a variable, nor in file, such as:

#./sendATCommand > output.txt


Output.txt file will be empty. I tried various redirections, but still did not get it to work.

Can anyone please help me resolve those two problems (if ever possible)? Ultimately I want this little script to be
called from a "super" script (e.g. Perl or Powershell) running on PC to which my Android device is
connected, but there is no way to do it until those two problems resolved

Is This A Good Question/Topic? 0
  • +

Page 1 of 1