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