mark chrome_cr50 ccd commands

Some devices have the cr50 console connected to the servo header, so
they don't need to rely on CCD to send cr50 console commands. Cr50 tests
are written to be used with CCD or without. Having ccd enabled on cr50
changes the sleep behavior, so some of the tests enable or disable CCD
at different points. These commands are unnecessary on devices that are
using the servo header instead of suzyq.

This change adds a decorator for the cr50 functions that should only be
used on tests getting the cr50 console through ccd. The wrapper will
ignore the function call if the test is not using ccd.

TEST=run firmware_Cr50DeepSleepStress on poppy and verify ccd_enable and
disable are ignored, but the idle calls still work.

Change-Id: I99fba44d3e58158dd7ea792cf85a9725fa69e35d
Signed-off-by: Mary Ruthven <>
Reviewed-by: Wai-Hong Tam <>
diff --git a/server/cros/servo/ b/server/cros/servo/
index 18f9fe6..511a451 100644
--- a/server/cros/servo/
+++ b/server/cros/servo/
@@ -2,7 +2,11 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
-import ast, logging, re, time
+import ast
+import functools
+import logging
+import re
+import time
 from autotest_lib.client.bin import utils
 from autotest_lib.client.common_lib import error
@@ -278,6 +282,16 @@
         super(ChromeUSBPD, self).__init__(servo, "usbpd_uart")
+def ccd_command(func):
+    """Decorator for methods only relevant to devices using CCD."""
+    @functools.wraps(func)
+    def wrapper(instance, *args, **kwargs):
+        if instance.using_ccd():
+            return func(instance, *args, **kwargs)
+"not using ccd. ignoring %s", func.func_name)
+    return wrapper
 class ChromeCr50(ChromeConsole):
     """Manages control of a Chrome Cr50.
@@ -366,6 +380,12 @@
         return self.get_version_info(self.ACTIVE)
+    def using_ccd(self):
+        """Returns true if the console is being served using CCD"""
+        return self._servo.get_servo_version().startswith('servo_v4')
+    @ccd_command
     def get_ccd_state(self):
         """Get the CCD state from servo
@@ -375,6 +395,7 @@
         return self._servo.get('ccd_state')
+    @ccd_command
     def wait_for_ccd_state(self, state, timeout):
         """Wait up to timeout seconds for CCD to be 'on' or 'off'
@@ -392,16 +413,19 @@"ccd is '%s'", state)
+    @ccd_command
     def wait_for_ccd_disable(self, timeout=60):
         """Wait for the cr50 console to stop working"""
         self.wait_for_ccd_state('off', timeout)
+    @ccd_command
     def wait_for_ccd_enable(self, timeout=60):
         """Wait for the cr50 console to start working"""
         self.wait_for_ccd_state('on', timeout)
+    @ccd_command
     def ccd_disable(self):
         """Change the values of the CC lines to disable CCD""""disable ccd")
@@ -409,6 +433,7 @@
+    @ccd_command
     def ccd_enable(self):
         """Reenable CCD and reset servo interfaces""""reenable ccd")