liufumingren 3701da40df chore(scripts): 新增现场取证与电源压测脚本
现场"扫描枪收不到按键"需要区分"按键没到内核"与"到了内核但上层丢了",
以及区分"供电不足/外设取电"与"枪线材问题",补三个可直接复用的工具:

- scripts/scan-forensics.ps1:故障当场一键取证(设备/root/uptime、/proc/bus/input/devices、
  dmesg usb/hid、App 侧 logcat(WMSScan/WMSPage/UniConsole)、dumpsys input、内核 getevent 抓窗),
  并自动输出判据:内核有按键而 App keys=0 -> 上层(Android 分发/WebView);内核无按键 -> 枪/线/供电。
- scripts/power-probe.sh:采样 SARADC / 温度 / 扫码枪是否仍在总线上(RK818 不上报电流,
  这是唯一可用的侧面遥测)。
- scripts/power-load-test.sh:固定负载(屏幕最亮 + N 核忙循环)压测并在结束后自动杀掉负载。

实测结论(X9R 12V/2A 24W 临界、音响插平板 USB 口会冲掉 Hub + 枪)见 README 机型注意一节。
2026-09-25 17:05:42 +08:00

31 lines
1.2 KiB
Bash

#!/system/bin/sh
# power-probe.sh - sample the power picture on the RK3288 X9R (needs adb root)
#
# Why: on 2026-09-25 the field unit behaved badly on a 12V/2A adapter and fine on 12V/2.5A,
# which points at input brown-out. The OS has no "rated power" field and the RK818 driver
# reports 0mA for every rail, so the only usable telemetry is:
# - SARADC channels (ff100000.saradc, 10-bit, 1.7578125 mV/LSB)
# - SoC / GPU thermal
# - whether the USB scanner is still enumerated (brown-out can drop the HID device)
# Run it once on each adapter and compare (min/max/mean + gun=0 count).
#
# usage: pwr_sample.sh [samples] [outfile] (0.5 s per sample)
N=${1:-120}
OUT=${2:-/data/local/tmp/pwr_sample.txt}
DEV=/sys/bus/iio/devices/iio:device0
i=0
: > "$OUT"
while [ "$i" -lt "$N" ]; do
u=$(cat /proc/uptime); u=${u%% *}
a0=$(cat $DEV/in_voltage0_raw 2>/dev/null)
a1=$(cat $DEV/in_voltage1_raw 2>/dev/null)
a2=$(cat $DEV/in_voltage2_raw 2>/dev/null)
t0=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null)
t1=$(cat /sys/class/thermal/thermal_zone1/temp 2>/dev/null)
gun=$(grep -c Newtologic /proc/bus/input/devices 2>/dev/null)
echo "$u $a0 $a1 $a2 $t0 $t1 $gun" >> "$OUT"
i=$((i + 1))
sleep 0.5
done
echo "done $N samples -> $OUT"