Talking to modem with AT commands on android - android

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.

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.

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.

Related

run CTS on specific device using its usb id

I'm working on script which suppose run CTS Tests on multiple devices.
unfortunately, while i check the serial number of my android devices I see that part of them contains identical serial number.
now, I read about an option to run adb devices -l to get usb entering of my devices, in order to I could run command on specific usb:
$ adb devices -l
List of devices attached
0123456789ABCDEF device usb:2-1.8
0123456789ABCDEF device usb:2-1.7
now, we can run this command on specific usb instead specific serial number as before:
$ adb -s usb:26200000 install xxx.apk
I want to do similar thing while I run CTS on specific android device:
$ ./cts-tradefed run cts -s usb:2-1.8 -p android.permission2
The problem is that it looks like the command not working. there isn't any response when I try this.
please, anybody can tell me if there is another way to run cts on specific device while there are two identical serial numbers?
There is another way of forcing adb to use a specific device besides -s parameter. You can assign your device id to the ANDROID_SERIAL environment variable. That works great for 3rd party scripts which do not support specifying the required id otherwise.
You can select between multiple devices you use the command list devices to get the serial of the devices:
l d
Example
cts-tf > l d
Serial State Allocation Product Variant Build Battery
10.1.1.113:5555 ONLINE Allocated product variant 2018.02.2 100
and then run cts with --serial parameter
run cts --serial <id>
where <id> is the first column in the result from l d command
Even if the parameter's name is serial in fact the value you give to it is the device id(as given by the command l d or list devices) and not the actual serial of the device.

VTS AT command only works once (sends dtmf tone only once) on sony ericson xperia Neo V

I have a rooted Xperia Neo V (running quite old Android - 2.3.4). Im trying to run AT commands on /dev/smd0. Most of the things work fine except I'm able to send DTMF tone only once, after that VTS command does not have any effect, even the simple AT command or other commands cease to work i.e. do not give any response after that unless I reboot the phone.
Sequence of events:
1. Test AT command is working:
echo -e "AT\r" > /dev/smd0;cat /dev/smd0
AT
OK
Make/receive a call either through UI or ATD/ATA.
Test AT Command is working:
echo -e "AT\r" > /dev/smd0;cat /dev/smd0
AT
OK
Send DTMF: (I can hear the tone on the other end)
echo -e "AT_VTS=3\r" > /dev/smd0;cat /dev/smd0
At this point all commands (AT+VTS=4, AT, ATI, etc etc) stop working till I reboot the phone. Im not able to hear any further DTMF tones with VTS command.
Observations:
1. I even tried doing a terminal Mitm using mulliner's code (http://mulliner.org/security/sms/feed/android_injector_v1.tgz) to understand how Android is sending DTMF tones correctly. However, the mitm does not work (no output in injector.log). Please note that it works when I send AT commands manually through the shell i.e. logs everything perfectly.
Even if /dev/smd0 is renamed, the ril/Android works fine. My assumption is that it is using some other Qualcomm dev file in case /dev/smd0 fails.
Info:
1. Phone: Sony Ericson Xperia Neo V
[ro.build.description]: [MT11i-user 2.3.4 4.0.2.A.0.62
2. dev file:
$ adb shell getprop | grep -i rild.libargs
[rild.libargs]: [-d /dev/smd0]
Baseband:
echo -e "ATI\r" > /dev/smd0;cat /dev/smd0
ATI
Manufacturer: QUALCOMM INCORPORATED
Model: 196
Revision: M7630A-ABBQMAZM-2.0.3028DT 1 [Sep 14 2011 11:00:00]
IMEI: XXXXXXXXXXXXXXXXXX
+GCAP: +CGSM,+FCLASS,+DS
Since your Sony Ericsson phone is based on Qualcomm's and not ST-Ericsson's platform I do not know any specific implementation details, but since I implemented the AT+VTS command for ST-Ericsson in 2008, I'll give it a shot.
First of, your command example is saying AT_VTS while the command is AT+VTS. I assume that is just a typo while writing this question?
Regarding deleting /dev/smd0 I think this is just rather that the RIL daemon is holding the file open, and thus deleting it in the file system has no effect on processes that have the file opened (until they close it) in the normal unix filesystem behaviour.
I do not know how opening + closing and reopening the device file repeatedly (which is done when running multiple command in sequence like that) will affect things on this phone, but in best case it does not matter and in worst case there might be some trouble related, so I suggest that you use my atinout for sending AT commands and receiving responses. With that you would instead of the echo + cat commands run
echo "AT" | atinout - /dev/smd0 -
echo "AT+VTS=3" | atinout - /dev/smd0 -
echo "ATI" | atinout - /dev/smd0 -
which will open the device once, write the command line once, and read the response(s) back before closing the device when exiting. And it is nicer to use since you do not have to mess with carriage return.
Running three commands like above will open and close the device three times. It would be very interesting to try to run all of them in one operation, e.g
echo "AT; +VTS=3; I" | atinout - /dev/smd0 -
and/or
cat > commands.txt <EOF
AT
AT+VTS=3
ATI
EOF
atinout commands.txt /dev/smd0 -
to see if any of those makes any difference. Will ATI print anything?
Unfortunately I have no experience in compiling atinout on android, so I have no help to offer there.

How to run AT commands in Android terminal as root user?

I have root my Android mobile (Spice MI 270). I want to run AT commands. But whenever I try to run any AT command form shell, it is giving messages as 'AT not found'. My whole purpose of routing is to give AT commands to modem.
How should I proceed?
Thanks.
You can use the program atinout which will allow you to easily send AT commands from the commands line. Example to hang up a call:
$ echo ATH | atinout - /dev/ttyACM0 -
ATH
OK
$
You need to find the name of the serial device for android (on desktop linux it is typically /dev/ttyACM0 but Android use something different as far as I remember).

Sending AT Commands Via ADB Android

I have a task at work to investigate if it is possible to send AT commands to an android device via ADB shell. So far,I have tried to echo out the AT commands but it passes them as normal strings.
Any help please anyone.
Please try this:
echo -e "AT+CFUN=?\r\n" > /dev/ttyUSB0
On your phone, the serial line must not necessarily be called ttyUSB0. If this is not working or not available, check out the other entries of the /dev/ directory.
So it could also be /dev/ttyGS0 or /dev/SMD0 (as found out by #Sani).
For further information, please check out this Guide
NOTE:
There might also be phones, that do not respond to AT commands on any of their serial (tty) devices.
I just tried my own procedure on a Samsung Galaxy S4 and did not have any success.
Echo them where? In Android you talk to the rild (Radio Interface Layer) daemon, which in turns talks to a proprietary library, which sends commands to the actual hardware. Check rild source code for details. You could probably write a command line program that talks to the rild and execute it via adb shell, if that fits your needs.
In order to find out which port to use :
You can check
# cat /proc/tty/drivers
Use logcat -b radio | grep dev to see wich tty the radio is using.
Yes you can run AT commands from adb shell too...
prerequsite :-
1. rooted android phone
2. you are aware of the port that RIL use for i/o operation.
3. to check which port is being used by RIl use `getprop rild.libargs`
To run AT command from ADB use:
echo -c "AT\r\n" > /dev/smd11
PS: smd11 is port used by RIL.This varies from device to device.
ALso to run AT commands from android application check this tutorial
http://tech-papers.org/executing-at-commands-android-application/
Kind of a combination of the above. We got it working with 2 terminals on a Pixel 4 XL.
On one we did:
cat /dev/smd7
in the other:
echo "AT\r" > /dev/smd7
The output shows up in the first terminal
Notes:
Have to be root!
None of the discovery mechanisms worked for us, so we blindly called into smdX until we got a response from "AT\r".
echo automatically adds a \n, so adding it is redundant.

How to control a serial device on Android?

I want to develop an application whitch control the serial device over usb, on Linux Android.
An Android OS is 3.1 that supports USB host.
Q1: Please let me know how to get which port the serial device is mounted .
I got likely USB device information when I got "Dump Device State" on Dalvik Debug Monitor.
And, I checked /dev/tty* on android device by using adb.
I don't know which one(/dev/tty??) the serial device is.
adb shell
$ ls /dev/tty*
/dev/tty
/dev/ttyFIQ0
/dev/ttyHS0
/dev/ttyHS2
/dev/ttyHS3
/dev/ttyHS4
/dev/ttyS0
/dev/ttyS1
/dev/ttyS2
/dev/ttyS3
Q2: Please let me know how to control the serial device on Android without root permission.
I have a application(exe) that can control the serial device on linux.
I tried to do on android , but I couldn't do for permission denied.
And, I tried redirect to the serial port(maybe)
$ ls > /dev/ttyS0
But I couldn't.
cannot create /dev/ttyS0: permission denied.
Please let me know anything how to control and access to the serial device.
There is a great review of this in the XDA forum thread:
How to talk to the Modem with AT commands.
That thread show you how to send AT commands (ATC) with a remote terminal (USB connected to you PC), but it has not yet solved the problem of how to use a local (phone) terminal to talk to the phone Modem.
BTW. You need a terminal application/program to do any talking to the modem (remember, its a 2-way communication). So that's why you need a rooted device, since the root kit usually come with Busybox (that includes a microcom terminal program). Otherwise you have to write your own program.
in next step, you can test tty* port by couple of command:
$ cat /dev/tty* /for receive the characters from tty
and
$ echo 'text string' > /dev/tty* /for send characters to tty
good luck!
Try on a rooted device?? In researching the same thing I've read that only a few 3.1 / 2.3.4 devices allow non-root access to the usb port.
This is what I get on my HTC Desire unrooted, 2.2:
$ ls /dev/tty*
ls /dev/tty*
/dev/tty
/dev/ttyHS0
/dev/ttyHSUSB0
/dev/ttyHSUSB1
/dev/ttyHSUSB2
/dev/ttyMSM0
My Asus Transformer, unrooted, 3.2:
$ ls /dev/tty*
ls /dev/tty*
/dev/tty
/dev/ttyHS1
/dev/ttyHS2
/dev/ttyS0
/dev/ttyS1
/dev/ttyS2
/dev/ttyS3
I get exactly the same list when docked with the Keyboard Dock installed (It as 2 x USB ports).
Hope it helps, please let me know I'd love to be able to do the same.

Categories

Resources