1# Copyright 2019 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5ATMEL_USB_VENDOR_ID = "03eb" 6SERVO_USB_KBD_DEV_ID = ATMEL_USB_VENDOR_ID + ":2042" 7 8 9def is_servo_usb_keyboard_present(host): 10 """ 11 Check if DUT can see the servo USB keyboard. 12 13 Run lsusb and look for USB devices with SERVO_USB_KBD_DEV_ID. 14 15 @param host: An Autotest host object 16 17 @return Boolean, True if the USB device is found. False otherwise. 18 """ 19 return host.run( 20 "lsusb -d " + SERVO_USB_KBD_DEV_ID, ignore_status=True).exit_status == 0 21 22 23def is_servo_usb_wake_capable(host): 24 """ 25 Check if servo USB keyboard can wake the DUT from S3/S0ix. 26 27 Run lsusb -vv -d SERVO_USB_KBD_DEV_ID and check if the keyboard has wake 28 capability. 29 30 @param host: An Autotest host object 31 32 @return Boolean, True if the USB device is found and has wake capability. 33 False otherwise. 34 35 """ 36 # If the DUT cannot see the USB device return False. 37 if not is_servo_usb_keyboard_present(host): 38 return False 39 result = host.run( 40 "lsusb -vv -d " + SERVO_USB_KBD_DEV_ID, 41 ignore_status=True).stdout.strip() 42 # lsusb should print "Remote Wakeup" if the device has remote wake 43 # capability. 44 return "Remote Wakeup" in result 45