How to execute gsm0710muxd during boot time of android - android

I am using mux drivers for GSM modem with android 4.0.4 and I executes using command on console:
./gsm0710muxd -s /dev/ttyUSB0 -b 115200 -n 3
but I want to automate this, so I want to execute it during boot-up time so that my virtual ports may work with my gsm modem for calling functionalities but I am unable to automate this command, I have no idea how to do this because the command is complicated, I don't know how to use this as a whole to tell system serial port, baudrate, number of ports.

You can do this by giving this command in init.rc. Here is an example from init.rc. You can add this in the boot section of init.rc where other services are also initialized.
service gsmmuxd /system/bin/logwrapper /system/bin/gsm0710muxd –s /dev/<serial_port> –n3 -v7 –mbasic
class main
user radio
group radio cache inet misc
oneshot
Plus you will also need to change the device which is used in ril-daemon service. For instance, my RIL library is librapid-ril-core.so and I am using mux, the configuration would be the following:
service ril-daemon /system/bin/rild -l /system/lib/librapid-ril-core.so -- -a /dev/pts/0 -n /dev/pts/1
Here, if we were using USB, you would see /dev/ttyUSB0 and /dev/ttyUSB1 in your init.rc configurations.
I hope this helps. Please feel free to ask further questions.

Related

Use the "logcat -b radio" in unroot phone

I have tried to execute logcat -b radio programmatically, but failed. The command can be executed successfully from a PC terminal while the device is connected.
So I want to connect adbd service directly on the phone. Is there any method to connect adbd? Perhaps with a socket or usb driver? Who can give some advice on this?
The READ_LOGS permission control is changed since Android 4.1. Normal application cannot read the logs generated by other process (with different UID).
However, you can still get this permission manually by execute
"pm grant com.yourpackage.name android.permission.READ_LOGS"
on Adb shell. You might need to reboot your device after this.
Back to you question, you cannot connect to ADB daemon on your device with your application running on the same one. Another workaround for your application to read the logs is to write a daemon application to start and be daemonized on ADB shell, which will communicate with your application via IPC to get the log for you.

Build time configuration of Android TCP/IP MTU

I know that it is possible to read and set the MTU during runtime e.g. with:
adb shell ip -d -s l l dev rmnet0
adb shell ifconfig rmnet0 mtu <MTU>
This has the problem that the MTU set this way does not hold after restarting the phone.
So how to configure the default MTU for an interface when building your own build with Android Open Source Project sources?
There seems to be no mention about this anywhere and grepping code does not seem to help. Also the default Linux kernel configuration files where this is done do not seem to exist in Android.
There sure must be a way to do this, right?
Apparently PMTUD is a better solution to this (RFC 4821).
It can be enabled in AOSP builds in init.rc (e.g. system/core/rootdir/init.rc) by adding following lines at the end of section "on boot":
on boot
# Other configurations here...
# Set TCP MTU Probing to automatic:
write /proc/sys/net/ipv4/tcp_mtu_probing 1

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.

What is the ADB?

I keep reading tutorials where I'm supposed to enter something into the ADB command line and that it's in my Android sdk/platform-tools. So I find it, click on it, and a black screen comes up for about 2 seconds and while it's up, it scrolls through a bunch of text. So how am I supposed to use this "adb"?
It is called the Android Debug Bridge, and the Android Developers Site documentation does a better job of explaining it than I can:
http://developer.android.com/guide/developing/tools/adb.html
If you are looking for the adb command line, navigate to <sdk>/platform-tools/ and run
adb.exe shell
from the command line.
Pretty sure that is well documented since day 1 on the Android Debug Bridge
Android Debug Bridge (adb) is a versatile command line tool that lets
you communicate with an emulator instance or connected Android-powered
device. It is a client-server program that includes three components:
A client, which runs on your development machine. You can invoke a
client from a shell by issuing an adb command. Other Android tools
such as the ADT plugin and DDMS also create adb clients. A server,
which runs as a background process on your development machine. The
server manages communication between the client and the adb daemon
running on an emulator or device. A daemon, which runs as a background
process on each emulator or device instance.
So plain old English, ADB can be found on %ANDROID_HOME%/platform-toos/, and it's this magical command line that allows you to comunicate with your mobile device, either a physical or a Virtual device (AVD), so whenever you deploy you are passing the application through the device thanks to the ADB on a specific client port on your computer to the daemon port on the device.
Interesting things you can do with it?
Logcat: ./adb logcat allows you to see the log trace of each proces.
Install: ./adb install allows you to install apk to the device.
Killing:./adb kill-sever
Starting:./adb stat-server
Enter SQLite3: adb -s your_device shell
Use the monkey: adb shell monkey -v -p your.app.package 500 to
generate random events
And a lot more! Read the documentation it's beatiful and self-explanatory.

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