faft: Add USB Type C PD infrastructure

Added support for Type C PD testing via the usbpd console. For case
where the usbpd console is the same as the ec console (glados, plankton, etc),
the usbpd conosle is assigned to be the same as the ec console.

Added changes to access both Plankton and a PD capable DUT (samus, glados, ..)
at the same time. The plankton servo host is only started if plankton servo
arguments are detected in the args section of the test script command line.

Inluded one example test PDConnect that disconnects then reconnects via
changing the dualrole setting, and verifies that a new PD contract is established.

BRANCH=none
BUG=chromium:561007
TEST=Manual
Tested both samus to plankton and glados to plankton cases using my own local machine.

Change-Id: Ic51173f02e9932f5c1d907288037bea54c8f1c3d
Signed-off-by: Scott Collyer <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/314252
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/servo/plankton.py b/server/cros/servo/plankton.py
index 0caa646..917caa5 100644
--- a/server/cros/servo/plankton.py
+++ b/server/cros/servo/plankton.py
@@ -2,12 +2,12 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import logging
 import re
 import time
 import xmlrpclib
 
 from autotest_lib.client.bin import utils
+from autotest_lib.server.cros.servo import chrome_ec
 
 
 class PlanktonError(Exception):
@@ -57,9 +57,9 @@
         """
         if args_dict is None:
             args_dict = {}
-        plankton_host = args_dict.get('plankton_host', self.DEFAULT_SERVO_HOST)
+        plankton_hostname = args_dict.get('plankton_host', self.DEFAULT_SERVO_HOST)
         plankton_port = args_dict.get('plankton_port', self.DEFAULT_SERVO_PORT)
-        remote = 'http://%s:%s' % (plankton_host, plankton_port)
+        remote = 'http://%s:%s' % (plankton_hostname, plankton_port)
         self._server = xmlrpclib.ServerProxy(remote)
         self.init_io_expander()
 
@@ -75,13 +75,20 @@
 
 
     def set(self, control_name, value):
-        """Sets the value of a control using servod."""
+        """Sets the value of a control using servod.
+
+        @param control_name: plankton servo control item
+        @param value: value to set plankton servo control item
+        """
         assert control_name
         self._server.set(control_name, value)
 
 
     def get(self, control_name):
-        """Gets the value of a control from servod."""
+        """Gets the value of a control from servod.
+
+        @param control_name: plankton servo control item
+        """
         assert control_name
         return self._server.get(control_name)
 
@@ -162,3 +169,12 @@
         self.set(self.USBC_MUX, mux)
         time.sleep(self.USBC_COMMAND_DELAY)
 
+
+class PlanktonConsole(chrome_ec.ChromeEC):
+    """Manages control of a Plankton PD console.
+
+    We control the PD conolse via the UART of a Servo board. ChromePlankton
+    provides many interfaces to set and get its behavior via console commands.
+    This class is to abstract these interfaces.
+    """
+    pass