send-at-retry: add script
parent
fc2bcc29bc
commit
f6aee41fb1
|
@ -0,0 +1,7 @@
|
|||
Send AT commands multiple times until an expected string is in the reply.
|
||||
|
||||
This hack is a PoC for sending AT commands through the same pseudo TTY that
|
||||
mtkfusionrild is using.
|
||||
|
||||
Preparation:
|
||||
- Ubuntu touch with ssh enabled and writable rootfs
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh -ex
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Author: Oliver Smith
|
||||
# Copyright 2021 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
# Related: https://github.com/ubports/ubuntu-touch/issues/1836
|
||||
|
||||
LD_PRELOAD= LD_LIBRARY_PATH= lxc-attach -n android -e -- "$@"
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh -e
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Author: Oliver Smith
|
||||
# Copyright 2021 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
|
||||
DEV="/dev/radio/ptty2cmd2"
|
||||
RET="/data/local/tmp/ims_apn"
|
||||
|
||||
# $1: AT command to send
|
||||
# $2: retry until finding this string in reply
|
||||
send() {
|
||||
echo "---"
|
||||
echo "> $1"
|
||||
|
||||
rm -rf "$RET"
|
||||
cat "$DEV" > "$RET" &
|
||||
pid="$!"
|
||||
|
||||
for i in $(seq 1 5); do
|
||||
printf .
|
||||
echo "$1" > "$DEV"
|
||||
sleep 0.1
|
||||
|
||||
if grep -q "$2" "$RET"; then
|
||||
cat "$RET"
|
||||
kill "$pid"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
kill "$pid"
|
||||
echo
|
||||
echo "ERROR: could not find '$2' in response:"
|
||||
cat "$RET"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Query firmware information
|
||||
send 'AT+CGMI' '+CGMI:'
|
||||
send 'AT+CGMM' '+CGMM:'
|
||||
send 'AT+CGMR' '+CGMR:'
|
||||
|
||||
# Add your at commands below
|
||||
|
||||
echo
|
||||
echo "---"
|
||||
echo "done"
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh -ex
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Author: Oliver Smith
|
||||
# Copyright 2021 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
set -x
|
||||
dump_name="$1"
|
||||
|
||||
chmod +x /mnt/tmp/android_run.sh
|
||||
chmod +x /tmp/lxc_attach.sh
|
||||
|
||||
sudo /tmp/lxc_attach.sh /mnt/tmp/android_run.sh "$1" 2>&1 \
|
||||
| tee /tmp/"$dump_name"
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh -ex
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Author: Oliver Smith
|
||||
# Copyright 2021 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
dump_name="$(date "+%Y-%m-%d_%H%M%S")"
|
||||
|
||||
adb push data/send_at_retry_ut.sh /tmp/run.sh
|
||||
adb push data/lxc_attach.sh /tmp/lxc_attach.sh
|
||||
adb push data/send_at_retry_android.sh /mnt/tmp/android_run.sh
|
||||
|
||||
adb forward tcp:8023 tcp:22
|
||||
ssh -t -p 8023 phablet@localhost \
|
||||
sh -e /tmp/run.sh "$dump_name"
|
||||
|
||||
mkdir -p dump/"${dump_name}_at"
|
||||
adb pull /tmp/"$dump_name" "dump/${dump_name}_at/${dump_name}.txt"
|
||||
|
||||
ln -sf "$PWD/dump/${dump_name}_at/${dump_name}.txt" /tmp/latest.txt
|
Loading…
Reference in New Issue