exclude PluginsFieldTrialTest.NoPrefLeftBehind from valgrind bot
[chromium-blink-merge.git] / tools / usb_gadget / composite_echo_gadget.py
blob4f3cd165453434786d0d988d003022ca1aa9cb0e
1 # Copyright 2015 The Chromium 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.
5 import uuid
7 import composite_gadget
8 import echo_gadget
9 import hid_echo_gadget
10 import hid_gadget
11 import usb_constants
12 import usb_descriptors
15 class CompositeEchoGadget(composite_gadget.CompositeGadget):
17 def __init__(self):
18 device_desc = usb_descriptors.DeviceDescriptor(
19 idVendor=usb_constants.VendorID.GOOGLE,
20 idProduct=usb_constants.ProductID.GOOGLE_COMPOSITE_ECHO_GADGET,
21 bcdUSB=0x0210, # USB 2.1 to indicate support for BOS descriptors.
22 iManufacturer=1,
23 iProduct=2,
24 iSerialNumber=3,
25 bcdDevice=0x0100)
27 echo_feature = echo_gadget.EchoCompositeFeature(
28 endpoints=[(0, 5, 0x81, 0x01), (1, 6, 0x82, 0x02), (2, 7, 0x83, 0x03)])
30 hid_echo_feature = hid_echo_gadget.EchoFeature()
31 hid_feature = hid_gadget.HidCompositeFeature(
32 report_desc=hid_echo_gadget.EchoFeature.REPORT_DESC,
33 features={0: hid_echo_feature},
34 interface_number=3,
35 interface_string=4,
36 in_endpoint=0x84, out_endpoint=0x04)
38 super(CompositeEchoGadget, self).__init__(
39 device_desc, [echo_feature, hid_feature])
40 self.AddStringDescriptor(1, 'Google Inc.')
41 self.AddStringDescriptor(2, 'Echo Gadget')
42 self.AddStringDescriptor(3, '{:06X}'.format(uuid.getnode()))
43 self.AddStringDescriptor(4, 'HID Echo')
44 self.AddStringDescriptor(5, 'Interrupt Echo')
45 self.AddStringDescriptor(6, 'Bulk Echo')
46 self.AddStringDescriptor(7, 'Isochronous Echo')
48 # Enable Microsoft OS 2.0 Descriptors for Windows 8.1 and above.
49 self.EnableMicrosoftOSDescriptorsV2(vendor_code=0x02)
50 # These are used to force Windows to load WINUSB.SYS for the echo functions.
51 self.SetMicrosoftCompatId(0, 'WINUSB')
52 self.SetMicrosoftCompatId(1, 'WINUSB')
53 self.SetMicrosoftCompatId(2, 'WINUSB')
55 def RegisterHandlers():
56 """Registers web request handlers with the application server."""
58 import server
59 from tornado import web
61 class WebConfigureHandler(web.RequestHandler):
63 def post(self):
64 server.SwitchGadget(CompositeEchoGadget())
66 server.app.add_handlers('.*$', [
67 (r'/composite_echo/configure', WebConfigureHandler),