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 机型注意一节。
This commit is contained in:
parent
02db6c8a5a
commit
3701da40df
42
scripts/power-load-test.sh
Normal file
42
scripts/power-load-test.sh
Normal file
@ -0,0 +1,42 @@
|
||||
#!/system/bin/sh
|
||||
# power-load-test.sh - put the X9R under a reproducible load while sampling the power picture.
|
||||
#
|
||||
# Load = screen brightness max + N CPU busy loops (+ whatever the app/scanner does concurrently).
|
||||
# Sampling = SARADC channels / thermals / CPU freq / whether the USB scanner is still enumerated.
|
||||
# The busy loops are killed at the end (never left running) and brightness is restored by the caller.
|
||||
#
|
||||
# usage: power-load-test.sh [seconds] [cpus] [outfile]
|
||||
SECS=${1:-120}
|
||||
CPUS=${2:-4}
|
||||
OUT=${3:-/data/local/tmp/pwr_load.txt}
|
||||
DEV=/sys/bus/iio/devices/iio:device0
|
||||
|
||||
PIDS=""
|
||||
i=0
|
||||
while [ "$i" -lt "$CPUS" ]; do
|
||||
(while :; do :; done) &
|
||||
PIDS="$PIDS $!"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
: > "$OUT"
|
||||
n=0
|
||||
while [ "$n" -lt "$SECS" ]; 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)
|
||||
f0=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 2>/dev/null)
|
||||
f3=$(cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq 2>/dev/null)
|
||||
gun=$(grep -c Newtologic /proc/bus/input/devices 2>/dev/null)
|
||||
echo "$u $a0 $a1 $a2 $t0 $t1 $f0 $f3 $gun" >> "$OUT"
|
||||
n=$((n + 1))
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
for p in $PIDS; do kill -9 "$p" 2>/dev/null; done
|
||||
sleep 1
|
||||
echo "done $SECS samples -> $OUT"
|
||||
echo "load pids killed:$PIDS"
|
||||
30
scripts/power-probe.sh
Normal file
30
scripts/power-probe.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/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"
|
||||
120
scripts/scan-forensics.ps1
Normal file
120
scripts/scan-forensics.ps1
Normal file
@ -0,0 +1,120 @@
|
||||
# scan-forensics.ps1
|
||||
# One-shot evidence capture for the "scanner stops working" fault (WMS X9R tablet).
|
||||
#
|
||||
# Why: on 2026-09-25 the field log proved the break is BELOW the JS layer
|
||||
# (60s heartbeat keys=0 while every JS gate was green). The only thing JS cannot see is
|
||||
# whether the kernel/Activity still gets the key events. This script captures that layer.
|
||||
#
|
||||
# Usage (tablet plugged in, USB debugging on):
|
||||
# powershell -NoProfile -ExecutionPolicy Bypass -File scripts\scan-forensics.ps1
|
||||
# powershell -NoProfile -ExecutionPolicy Bypass -File scripts\scan-forensics.ps1 -Seconds 30
|
||||
#
|
||||
# Run it WHILE the fault is present, and scan the gun 3-5 times during the capture window.
|
||||
# Everything is kept (no cleanup) under -OutDir.
|
||||
#
|
||||
# Verdict rules:
|
||||
# kernel key DOWN > 0 but app heartbeat keys=0 -> Android dispatch / WebView / IME layer
|
||||
# kernel key DOWN = 0 -> gun / cable / USB port (hardware) or scan service
|
||||
#
|
||||
# ASCII only on purpose: `powershell -File` reads non-ASCII scripts as ANSI on this machine.
|
||||
|
||||
param(
|
||||
[int]$Seconds = 20,
|
||||
[string]$OutDir = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Continue'
|
||||
|
||||
function Find-Adb {
|
||||
$candidates = @(
|
||||
(Join-Path $env:LOCALAPPDATA 'Android\Sdk\platform-tools\adb.exe'),
|
||||
'C:\Android\Sdk\platform-tools\adb.exe',
|
||||
'D:\Android\Sdk\platform-tools\adb.exe'
|
||||
)
|
||||
foreach ($c in $candidates) {
|
||||
if (Test-Path $c) { return $c }
|
||||
}
|
||||
$cmd = Get-Command adb -ErrorAction SilentlyContinue
|
||||
if ($cmd) { return $cmd.Source }
|
||||
throw 'adb.exe not found. Set PATH or edit Find-Adb in this script.'
|
||||
}
|
||||
|
||||
if (-not $OutDir) {
|
||||
$OutDir = Join-Path $env:TEMP ('scan-forensics\' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
|
||||
|
||||
$adb = Find-Adb
|
||||
Write-Host "adb = $adb"
|
||||
Write-Host "out dir = $OutDir"
|
||||
Write-Host ''
|
||||
|
||||
function Sh($cmd) { & $adb shell $cmd 2>&1 }
|
||||
function Save($name, $lines) {
|
||||
$path = Join-Path $OutDir $name
|
||||
$lines | Out-File -FilePath $path -Encoding utf8
|
||||
Write-Host (" saved {0}" -f $name)
|
||||
}
|
||||
|
||||
# 1) device present?
|
||||
$devices = & $adb devices 2>&1
|
||||
$serial = ($devices | Select-String -Pattern '^\S+\s+device$' | ForEach-Object { $_.Line.Split()[0] }) | Select-Object -First 1
|
||||
if (-not $serial) {
|
||||
Write-Host '!! no adb device. Check: USB debugging on, try another USB port (this box only works on some ports), replug.' -ForegroundColor Red
|
||||
Write-Host ($devices -join "`n")
|
||||
exit 2
|
||||
}
|
||||
Write-Host "device = $serial"
|
||||
& $adb root 2>&1 | Out-Null
|
||||
& $adb wait-for-device 2>&1 | Out-Null
|
||||
|
||||
# 2) static environment
|
||||
Save '00-device.txt' @(
|
||||
"serial = $serial",
|
||||
"captured = $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')",
|
||||
"id = $(Sh 'id')",
|
||||
"model = $(Sh 'getprop ro.product.model')",
|
||||
"android = $(Sh 'getprop ro.build.version.release') build=$(Sh 'getprop ro.build.type') selinux=$(Sh 'getenforce')",
|
||||
"uptime = $(Sh 'cat /proc/uptime') (seconds since boot - tells whether a reboot just happened)",
|
||||
"pkg = $(Sh 'dumpsys window | grep -E ''mCurrentFocus|mFocusedApp''')"
|
||||
)
|
||||
|
||||
Save '01-input-devices.txt' (Sh 'cat /proc/bus/input/devices')
|
||||
Save '02-dmesg-usb-input.txt' (Sh "dmesg | grep -iE 'usb|newtologic|hid|input:' | tail -n 120")
|
||||
Save '03-app-logcat.txt' (Sh "logcat -d -s WMSScan:V WMSPage:V UniConsole:V UniViewConsole:V | tail -n 400")
|
||||
Save '04-dumpsys-input.txt' (Sh 'dumpsys input | head -n 250')
|
||||
|
||||
# 3) kernel key stream (scan now!)
|
||||
$gevPath = Join-Path $OutDir '05-getevent.txt'
|
||||
Write-Host ''
|
||||
Write-Host ("==> SCAN THE GUN 3-5 TIMES NOW (you have {0} seconds) <==" -f $Seconds) -ForegroundColor Yellow
|
||||
& $adb shell "timeout $Seconds getevent -lt" 2>&1 | Out-File -FilePath $gevPath -Encoding utf8
|
||||
Write-Host (" saved 05-getevent.txt")
|
||||
|
||||
# 4) verdict
|
||||
$gev = Get-Content $gevPath -ErrorAction SilentlyContinue
|
||||
$keyDown = @($gev | Select-String -Pattern 'EV_KEY\s+(KEY_[0-9A-Z_]+)\s+DOWN' -AllMatches)
|
||||
$enterDown = @($gev | Select-String -Pattern 'EV_KEY\s+KEY_ENTER\s+DOWN')
|
||||
$gunLines = @($gev | Select-String -Pattern 'event\d+.*EV_KEY')
|
||||
$logcat = Get-Content (Join-Path $OutDir '03-app-logcat.txt') -ErrorAction SilentlyContinue
|
||||
$health = @($logcat | Select-String -Pattern 'health.*keys=' | Select-Object -Last 1)
|
||||
|
||||
Write-Host ''
|
||||
Write-Host '================ VERDICT ================'
|
||||
Write-Host ("kernel : key DOWN events = {0} (ENTER = {1})" -f $keyDown.Count, $enterDown.Count)
|
||||
Write-Host (" gun/kernel EV_KEY lines = {0}" -f $gunLines.Count)
|
||||
if ($health.Count -gt 0) {
|
||||
Write-Host ("app : last heartbeat -> {0}" -f $health[0].Line.Trim())
|
||||
} else {
|
||||
Write-Host 'app : no WMSScan heartbeat in logcat buffer (buffer may have wrapped)'
|
||||
}
|
||||
Write-Host ''
|
||||
if ($keyDown.Count -ge 3) {
|
||||
Write-Host 'kernel HAS key events -> the break is ABOVE the kernel (Android dispatch / WebView / IME / app).' -ForegroundColor Green
|
||||
Write-Host ' Next: compare with the app heartbeat keys= above. keys=0 here means the app never got them.'
|
||||
} else {
|
||||
Write-Host 'kernel has NO (or almost no) key events -> gun / cable / USB port / scan service (hardware).' -ForegroundColor Red
|
||||
Write-Host ' Next: swap cable+port, watch dmesg in 02-dmesg-usb-input.txt for disconnect/reconnect.'
|
||||
}
|
||||
Write-Host ''
|
||||
Write-Host 'Keep this folder for the vendor/customer report. Nothing was deleted.'
|
||||
Loading…
x
Reference in New Issue
Block a user