5

I need to send AT command to modem. I am using samsung galaxy S3 I9300 device, which is rooted.

The steps I did are:

abd shell
su
echo -e "AT\r"

But I am not sure how to read the response given by the above commands. I tried to redirect the command as follows: echo -e "AT\r" > /dev/smd0, but when I execute cat /dev/smd0 I do not see any response I just see "AT". Seems like the command I intended to be executed is interpreted just as string and I see that string instead of the result of that operation.

Please advice what am I doing wrong.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
mkd156
  • 435
  • 3
  • 5
  • 16
  • Try this... http://stackoverflow.com/questions/12855482/sending-at-commands-via-adb-android – Hiren Pandya Apr 10 '13 at 11:38
  • Possible duplicate of http://stackoverflow.com/questions/5811828/can-i-use-adb-shell-to-send-commands-to-my-application – Triode Apr 10 '13 at 11:39
  • @Rajesh.. I guess, OP is talking about the AT Commands for the Phone Modem... – Hiren Pandya Apr 10 '13 at 11:40
  • Or try this one... http://stackoverflow.com/questions/9286331/adb-shell-script-to-send-at-commands-to-a-modem-cannot-return-control-to-a-shell – Hiren Pandya Apr 10 '13 at 11:42
  • It is the proper output.. Try putting some other commands like `ATD123456789;\r` – Hiren Pandya Apr 10 '13 at 11:56
  • thanks for all the answer. However all the links you referred to I had already tried with no luck. I think my problem is that I am not identifying correct serial line to the modem and thus the AT commands I execute are not sent to the modem. But http://forum.xda-developers.com/showthread.php?t=1471241 link doesn't explain how did it choose /dev/ttyGS0. Here is the result of cat /proc/tty/drivers on my device: – mkd156 Apr 10 '13 at 12:21
  • cat /proc/tty/drivers /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 251 0-3 serial usbserial /dev/ttyUSB 188 0-253 serial s3c2410_serial /dev/ttySAC 204 64-67 serial – mkd156 Apr 10 '13 at 12:22
  • After a bit more research it turn out that I do not need to go so much low level and identify the serial line to the modem. Instead I can use rild-debug. LocalSocket socket = new LocalSocket(); LocalSocketAddress sockAddr = new LocalSocketAddress("rild-debug", LocalSocketAddress.Namespace.RESERVED); socket.connect(sockAddr); OutputStream os = socket.getOutputStream(); String s = "ATD+37491472524\r"; os.write(s.getBytes()); socket.getOutputStream().close(); – mkd156 Apr 11 '13 at 12:16
  • By this I was expecting to make a call to the specified number however I do not get any results. Nothing happens; neither errors nor results. Any idea? – mkd156 Apr 11 '13 at 12:18
  • its becuase you are not usin \n try echo -c "AT\r\n" > /dev/smd0 this should work – Balwinder SIngh Jan 13 '15 at 09:29

4 Answers4

1

I suggest that you try out my atinout program which should be exactly what you are asking for: a program to send AT commands from the command line and capture the output.

In your case the result should be like

$ abd shell
$ su
$ echo AT | atinout - /dev/smd0 -

OK
$

and to capture the output just put a file name instead of the last -.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
0

Did you tried that in adb shell

su

echo -e "AT\r" > /dev/smd0
AMAN SINGH
  • 3,491
  • 6
  • 28
  • 44
0

To do that interactively:

while read a;do echo -e "${a}\r" >>/dev/smd7 ; timeout 1s cat /dev/smd7;done
Zibri
  • 9,096
  • 3
  • 52
  • 44
0

Even better:

strace 2>/dev/null -e inject=ioctl:retval=0 microcom /dev/smd7

for an interactive session :D

Zibri
  • 9,096
  • 3
  • 52
  • 44