Skip to content

Instantly share code, notes, and snippets.

@shinglyu
Created May 15, 2015 03:06
Show Gist options
  • Save shinglyu/e44502cbb78e6e207445 to your computer and use it in GitHub Desktop.
Save shinglyu/e44502cbb78e6e207445 to your computer and use it in GitHub Desktop.
Shell script for parsing STK logs
# How to capture STK log:
# * Enable RIL log
# * adb logcat | grep typeOfCommand --line-buffered | tee /tmp/stk.log
if [ $# -lt 1 ]; then
echo "Usage: stk_summary.sh <log file>"
exit
fi
fname=$1
# Get unique set of commands issued
commands=$(grep -o -e "typeOfCommand\":[0-9]*" $fname | sort | uniq)
# Extract the code only
array=$(echo $commands | tr "typeOfCommand\":" "\n")
# Convert decimal code to hex
for cmd in $array; do
hex=$(echo "obase=16; $cmd" | bc)
echo "0x$hex"
done
@shinglyu
Copy link
Author

Example output:

% ./stk_summary.sh stk.log.chunghua 
0x10
0x13
0x21
0x23
0x24
0x25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment