Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use adb command get the terminal output?

Tags:

android

adb

I want to get cpu usage of the phone and then draw on PC.

I want to do like this:

First, run a background process in the phone which caculate the CPU usage and show in terminal.

Second, use adb commnad to get the terminal output.

Finally, draw curve with data.

I'm confused wheather it will work normally without big latency. At first, I want to put the cpu usage into a file, and use command of 'adb pull' to pull the file, then read the file and draw. I thought this may cause big latency.

Does anyone could help me?

Thanks. James.

like image 980
james Avatar asked Aug 19 '12 08:08

james


People also ask

How do I run commands in ADB?

To run the command just type adb reboot-bootloader in the command line and to boot the device in recovery just type adb reboot recovery.


2 Answers

I'm not entirely sure if that is what you are trying to achieve but you can use:

  1. adb shell to access the shell prompt of the device and run commands from there. See: http://developer.android.com/tools/help/adb.html#shellcommands

  2. adb logcat to get the live log stream from the device. You can use filters etc to adjust the output to what you need. See: http://developer.android.com/tools/help/adb.html#logcat

like image 167
Paul Avatar answered Oct 28 '22 01:10

Paul


  1. Write an Android application write to a file, for sample: cpu_usage.txt

  2. Use LogCat to get output: adb shell cat /path_to_your_file/cpu_usage.txt

Parse the output from command line, then draw it on the graph. High latency? Nope.

Edit: Ok, if you get root permission, just execute the command as you wish, for example,

C:\>adb shell top -m -d 1 -n 1 > C:\top_result.txt

Check out the result at: C:\top_result.txt. Also, as I read your message, you say something like socket, if I were you, I would never use it, because it always causes high latency.

like image 21
Pete Houston Avatar answered Oct 28 '22 01:10

Pete Houston