CHERRY-PICK: Whale: Add serial server for Beaglebone USB serial control

serial_server.py is a generalized class for Beaglebone to make a (or
multiple) serial connections. Dolphin can also use this for Plankton
board control via XMLRPC.

The control path for Dolphin Plnakton board MCU is:
DUT/NUC --(ethernet)--> Beaglebone --> Servo V3 USB HUB --
--(USB cable)--> Larvae --(PL connector)--> Plankton-Raiden(Dolphin)

In Samus, we need to control two Dolphins on each side of Larvae, run
dolphin_server.py on Beaglebone as an XMLRPC server and make serial
connection to both Dolphins.

serial_utils.py is copied from factory/py/test

BUG=chrome-os-partner:29166
TEST=Manually on Beaglebone
  1. Check help string
     $ python serial_server.py -h
     $ python serial_client.py -h

  2. Start dolphin_server
     $ python dolphin_server.py -d
     Check the message Dolphins are connected on ttyUSB0 and ttyUSB1

  3. Run clients for different commands
     ex. serial_client.py <function> <index> [arguments]
     $ python serial_client.py send [0/1] usbc_action usb(check LED DS1)
     $ python serial_client.py send [0/1] usbc_action dp (check LED DS1)
     $ python serial_client.py receive [0/1] 0 (get received data)

  4. Test remote control
     On Beaglebone:
     $ iptables -A INPUT -p tcp --dport 9997 -j ACCEPT
     $ python dolphin_server.py -d --host=0.0.0.0
     On DUT (on same domain as Beaglebone):
     Use xmlrpclib.ServerProxy('http://<BB's IP>:9997')

Change-Id: I0f9c3f3a25c259ac4a4fd6c499465dd2e7204354
Original: Change-Id: Idc2042cb51c9dd1289eef4c3f00b5fc9d46fc809
Reviewed-on: https://chromium-review.googlesource.com/232261
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Reviewed-by: Dean Liao <deanliao@chromium.org>
Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
4 files changed