1 # Copyright (c) 2015 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 """ 5 MBIM_CID_DEVICE_SERVICES Sequence 6 7 Reference: 8 [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 22 9 http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf 10 """ 11 import common 12 from autotest_lib.client.cros.cellular.mbim_compliance import mbim_channel 13 from autotest_lib.client.cros.cellular.mbim_compliance \ 14 import mbim_command_message 15 from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants 16 from autotest_lib.client.cros.cellular.mbim_compliance import mbim_control 17 from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors 18 from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 19 import sequence 20 21 22 class MBIMCIDDeviceServicesSequence(sequence.Sequence): 23 """ 24 Implement |MBIMCIDDeviceServicesSequence|. 25 In this sequence, cid |MBIM_CID_DEVICE_SERVICES| is used to query the device 26 services supported by the MBIM devices and their properties. 27 """ 28 29 def run_internal(self): 30 """ Run the MBIM_CID_DEVICE_SERVICES Sequence. """ 31 # Step 1 32 command_message = mbim_command_message.MBIMDeviceServicesQuery() 33 packets = command_message.generate_packets() 34 device_context = self.device_context 35 channel = mbim_channel.MBIMChannel( 36 device_context._device, 37 device_context.mbim_communication_interface.bInterfaceNumber, 38 device_context.interrupt_endpoint.bEndpointAddress, 39 device_context.max_control_transfer_size) 40 response_packets = channel.bidirectional_transaction(*packets) 41 channel.close() 42 43 # Step 2 44 response_message = mbim_control.parse_response_packets(response_packets) 45 46 # Step 3 47 is_message_valid = isinstance( 48 response_message, 49 mbim_command_message.MBIMDeviceServicesInfo) 50 if ((not is_message_valid) or 51 (response_message.message_type != 52 mbim_constants.MBIM_COMMAND_DONE) or 53 (response_message.status_codes != 54 mbim_constants.MBIM_STATUS_SUCCESS)): 55 mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError, 56 'mbim1.0:9.4.3') 57 58 return command_message, response_message 59