xref: /aosp_15_r20/external/walt/README.google (revision bf47c6829f95be9dd55f4c5bbc44a71c90aad403)
1*bf47c682SAndroid Build Coastguard WorkerOverview
2*bf47c682SAndroid Build Coastguard Worker========
3*bf47c682SAndroid Build Coastguard Worker
4*bf47c682SAndroid Build Coastguard WorkerThis project is included in the internal Android source tree to support
5*bf47c682SAndroid Build Coastguard Workerautomated latency testing with Salad Fingers, a robot designed and built by
6*bf47c682SAndroid Build Coastguard WorkerSteve Pfetsch (spfetsch@). The three main components we use and modify are:
7*bf47c682SAndroid Build Coastguard Worker
8*bf47c682SAndroid Build Coastguard Worker  - the android app (android/)
9*bf47c682SAndroid Build Coastguard Worker  - the WALT device firmware (arduino/)
10*bf47c682SAndroid Build Coastguard Worker  - the TCP-to-serial bridge (pywalt/)
11*bf47c682SAndroid Build Coastguard Worker
12*bf47c682SAndroid Build Coastguard WorkerSalad Fingers uses a single Teensyduino running WALT firmware to test multiple
13*bf47c682SAndroid Build Coastguard Workerdevices without human intervention. The devices under test are connected to the
14*bf47c682SAndroid Build Coastguard Workersame host as the Teensy. An end-to-end connection for a single device (only one
15*bf47c682SAndroid Build Coastguard Workerdevice can use the WALT at a time) looks like this:
16*bf47c682SAndroid Build Coastguard Worker
17*bf47c682SAndroid Build Coastguard Worker    Device ------ Host ------ Teensy
18*bf47c682SAndroid Build Coastguard Worker  (android/)    (pywalt/)   (arduino/)
19*bf47c682SAndroid Build Coastguard Worker
20*bf47c682SAndroid Build Coastguard WorkerFor the device to communicate with the host over TCP on a physical USB
21*bf47c682SAndroid Build Coastguard Workerconnection, a "reverse" port has to be set up with adb. For example:
22*bf47c682SAndroid Build Coastguard Worker
23*bf47c682SAndroid Build Coastguard Worker  $ adb reverse tcp:50007 tcp:45454
24*bf47c682SAndroid Build Coastguard Worker
25*bf47c682SAndroid Build Coastguard WorkerAny traffic the device sends to 127.0.0.1:50007 will come into the host on port
26*bf47c682SAndroid Build Coastguard Worker45454 and vice versa. Port 50007 is defined in the app source, but the device
27*bf47c682SAndroid Build Coastguard Workerport can be selected arbitrarily.
28*bf47c682SAndroid Build Coastguard Worker
29*bf47c682SAndroid Build Coastguard WorkerThe TCP-to-serial bridge runs on the host and connects the app's TCP pipe to
30*bf47c682SAndroid Build Coastguard Workerthe Teensy's serial pipe. However, there are two special commands the app can
31*bf47c682SAndroid Build Coastguard Workersend to the bridge to synchronize the clocks between the device and the Teensy:
32*bf47c682SAndroid Build Coastguard Worker"bridge sync" and "bridge update".
33*bf47c682SAndroid Build Coastguard Worker
34*bf47c682SAndroid Build Coastguard WorkerThis setup requires some modifications from the original source, which are
35*bf47c682SAndroid Build Coastguard Workerexplained in the next section, but behaves very similarly to a direct, Teensy-
36*bf47c682SAndroid Build Coastguard Workerto-device USB connection.
37*bf47c682SAndroid Build Coastguard Worker
38*bf47c682SAndroid Build Coastguard Worker
39*bf47c682SAndroid Build Coastguard WorkerModifications
40*bf47c682SAndroid Build Coastguard Worker=============
41*bf47c682SAndroid Build Coastguard Worker
42*bf47c682SAndroid Build Coastguard Worker- Clock synchronization
43*bf47c682SAndroid Build Coastguard Worker  Despite the reliability and accuracy of NTP, device and host wall clocks can
44*bf47c682SAndroid Build Coastguard Worker  become significantly out of sync, especially if a device loses Wi-Fi
45*bf47c682SAndroid Build Coastguard Worker  connectivity. To avoid this problem and take advantage of the low-latency
46*bf47c682SAndroid Build Coastguard Worker  connection between the host and device, the clocks are synchronized based on
47*bf47c682SAndroid Build Coastguard Worker  the time difference between when the bridge zeroed the Teensy's clock and
48*bf47c682SAndroid Build Coastguard Worker  when the reply to the "bridge sync" command was sent to the device. This
49*bf47c682SAndroid Build Coastguard Worker  required parallel changes in pywalt/ and android/.
50*bf47c682SAndroid Build Coastguard Worker
51*bf47c682SAndroid Build Coastguard Worker- Automation intents
52*bf47c682SAndroid Build Coastguard Worker  The test scripts which control the robot (Salad Fingers) on which the Teensy
53*bf47c682SAndroid Build Coastguard Worker  is mounted require the ability to control certain aspects of the app running
54*bf47c682SAndroid Build Coastguard Worker  on a device. These are defined in a separate RobotAutomationEvent interface.
55*bf47c682SAndroid Build Coastguard Worker  This required changes to android/.
56*bf47c682SAndroid Build Coastguard Worker
57*bf47c682SAndroid Build Coastguard Worker- Reverse port support
58*bf47c682SAndroid Build Coastguard Worker  The WaltTcpConnection class was originally intended to communicate over a
59*bf47c682SAndroid Build Coastguard Worker  true network from a Chromebook to a dedicated bridge with a specific IP
60*bf47c682SAndroid Build Coastguard Worker  address. This address was changed to localhost in android/.
61*bf47c682SAndroid Build Coastguard Worker
62*bf47c682SAndroid Build Coastguard Worker- Strict networking and request ordering
63*bf47c682SAndroid Build Coastguard Worker  To prevent crashes due to network accesses performed on the main thread,
64*bf47c682SAndroid Build Coastguard Worker  which is disallowed in strict mode, all such accesses were moved to a
65*bf47c682SAndroid Build Coastguard Worker  dedicated network thread. As a side benefit, all requests sent to the bridge
66*bf47c682SAndroid Build Coastguard Worker  now wait for a response before the next request is sent. This complies with
67*bf47c682SAndroid Build Coastguard Worker  the serial nature of the device and guarantees correct ordering. This
68*bf47c682SAndroid Build Coastguard Worker  required changes to android/.
69*bf47c682SAndroid Build Coastguard Worker
70*bf47c682SAndroid Build Coastguard Worker- Hardware-specific firmware
71*bf47c682SAndroid Build Coastguard Worker  The Teensy on Salad Fingers uses sensors that are not bundled with the
72*bf47c682SAndroid Build Coastguard Worker  standard WALT hardware, so new thresholds for accelerometer shocks and photo-
73*bf47c682SAndroid Build Coastguard Worker  diode readings were required to achieve accurate results. This required
74*bf47c682SAndroid Build Coastguard Worker  changes to arduino/.
75*bf47c682SAndroid Build Coastguard Worker
76*bf47c682SAndroid Build Coastguard Worker
77*bf47c682SAndroid Build Coastguard WorkerUsage
78*bf47c682SAndroid Build Coastguard Worker=====
79*bf47c682SAndroid Build Coastguard Worker
80*bf47c682SAndroid Build Coastguard WorkerThis project is not intended to be automatically built. Instead, as needed, the
81*bf47c682SAndroid Build Coastguard Workerapp will be built manually and checked in as a prebuilt that PTS will pick up.
82*bf47c682SAndroid Build Coastguard WorkerThe firmware cannot be built or loaded automatically, as it requires a modded
83*bf47c682SAndroid Build Coastguard Workerversion of the Arduino project for Teensy. The required software can be loaded
84*bf47c682SAndroid Build Coastguard Workeron a laptop to flash the Teensy mounted on Salad Fingers.
85*bf47c682SAndroid Build Coastguard Worker
86*bf47c682SAndroid Build Coastguard Worker
87*bf47c682SAndroid Build Coastguard WorkerSee Also
88*bf47c682SAndroid Build Coastguard Worker========
89*bf47c682SAndroid Build Coastguard Worker
90*bf47c682SAndroid Build Coastguard WorkerProject metadata: vendor/google_meta/platform/external/walt/
91*bf47c682SAndroid Build Coastguard WorkerPTS integration:  vendor/google_testing/pts/tests/salad_fingers/
92