servo: make uart capture more permissible

This change allows uart_capture to work if the uart is not_applicable on
a device. This is important for cr50 controls on v3.

BUG=chromium:996328
TEST=manual testing

Change-Id: I6791e8dd9a56769beb8fd880a4c1e8c058ead001
Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1764536
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Garry Wang <xianuowang@chromium.org>
diff --git a/server/cros/servo/servo.py b/server/cros/servo/servo.py
index 581a307..ee5c807 100644
--- a/server/cros/servo/servo.py
+++ b/server/cros/servo/servo.py
@@ -164,8 +164,17 @@
                       uart)
         uart_cmd = '%s_uart_capture' % uart
         if self._servo.has_control(uart_cmd):
-            self._servo.set(uart_cmd, 'on' if start else 'off')
-            return True
+            # Do our own implementation of set() here as not_applicable
+            # should also count as a valid control.
+            level = 'on' if start else 'off'
+            logging.debug('Trying to set %s to %s.', uart_cmd, level)
+            self._servo.set_nocheck(uart_cmd, level)
+            result = self._servo.get(uart_cmd)
+            if result in [level, 'not_applicable']:
+              logging.debug('Managed to set %s to %s.', uart_cmd, result)
+              return True
+            logging.debug('Failed to set %s to %s. Got %s.', uart_cmd, level,
+                          result)
         return False
 
     def start_capture(self):