README.md
1# PyWALT
2Python scripts for [WALT Latency Timer](https://github.com/google/walt) on Linux and ChromeOS.
3
4 * Based on [ChromeOS scroll test implementation](https://chromium.googlesource.com/chromiumos/platform/touchbot/+/master/quickstep/)
5 * Currently supprots tap and drag (scroll) latency measurements
6 * For tests using evetest or drm (all touch and screen tests) pywalt needs to run as root
7 * In order to find the name/number of your touch device run `evtest`. It will list available input devices and once you enter a device number it will show incoming events when you touch that touchpad / touchscreen.
8
9
10Synopsis:
11```
12$ walt --help
13usage: walt [-h] [-i INPUT] [-s SERIAL] [-t TYPE] [-l LOGDIR] [-n N] [-p PORT]
14 [-d]
15
16Run a latency test using WALT Latency Timer
17
18optional arguments:
19 -h, --help show this help message and exit
20 -i INPUT, --input INPUT
21 input device, e.g: 6 or /dev/input/event6 (default:
22 None)
23 -s SERIAL, --serial SERIAL
24 WALT serial port (default: /dev/ttyACM0)
25 -t TYPE, --type TYPE Test type:
26 drag|tap|screen|sanity|curve|bridge|tapaudio|tapblink
27 (default: None)
28 -l LOGDIR, --logdir LOGDIR
29 where to store logs (default: /tmp)
30 -n N Number of laser toggles to read (default: 40)
31 -p PORT, --port PORT port to listen on for the TCP bridge (default: 50007)
32 -d, --debug talk more (default: False)
33 ```
34
35
36## Tap Latency ##
37See the [tap latency section](../docs/usage/WALT_usage.md#tap-latency) in Android app usage doc.
38
39Below is output from an example run of a tap latency test that reads touch events from `/dev/input/event4` (in this case a touchpad). After 40 events (20 down and 20 up) are detected, the script prints median delays and exits.
40
41The input device option is mandatory since several touch devices might be preset (e.g. touchpad and touch screen). You can use a shorthand notation `-i 4` which is expanded to `-i /dev/input/event4`.
42
43The following must be run as root.
44
45```
46$ ./walt.py -t tap -n 40 -i /dev/input/event4
47
48Starting tap latency test
49Clock zeroed at 1487105210 (rt 0.250 ms)
50Event: time 1487105212.048997, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
51
52shock t 1990338, tap t 1487105212.048997, tap val 1. dt=63738.9
53Event: time 1487105212.262449, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
54
55shock t 2219992, tap t 1487105212.262449, tap val 0. dt=47537.0
56Event: time 1487105212.702711, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
57
58...
59
60Processing data...
61dt_down = [63.74, 26.96, 27.14 ...
62dt_up = [47.54, 47.03, 41.52...
63
64Median latency, down: 23.9, up: 47.1
65```
66
67## Drag / Scroll Latency ##
68See the [drag latency section](../docs/usage/WALT_usage.md#dragscroll-latency) in Android app usage doc.
69
70Below is a drag latency measurement of the trackpad on Asus Flip. The trackpad input device is `/dev/input/event4` which was selected using the `-i 4` argument.
71
72The `-n 20` option tells the script to record 20 laser events. Any change in laser sensor reading counts as one event, therefore one crossing of the beam counts as two events (laser goes off and back on), and a full cycle of the finger going up and down counts as 4 events. This measurement recorded 20/4 = 5 full cycles of the finger moving up and down.
73
74In addition to moving your finger up and down please also move it slowly along the beam. The calculation used by pywalt needs some spread of the x coordinates for better precision.
75
76Drag latency uses evtest and must therefore be run as root.
77
78```
79#./walt.py -t drag -i 4 -n 20
80Starting drag latency test
81Input device : /dev/input/event4
82Serial device : /dev/ttyACM1
83Laser log file : /tmp/WALT_2017_03_07__1532_12_laser.log
84evtest log file: /tmp/WALT_2017_03_07__1532_12_evtest.log
85Clock zeroed at 1488918733 (rt 0.306 ms)
86....................
87Processing data, may take a minute or two...
88Drag latency (min method) = 21.07 ms
89```
90