fixed failure to construct full config descriptor; handle linux's inability to deal...
[goodfet] / client / USB.py
1 # USB.py
2 #
3 # Contains definition of USB class, which is just a container for a bunch of
4 # constants/enums associated with the USB protocol.
5 #
6 # TODO: would be nice if this module could re-export the other USB* classes so
7 # one need import only USB to get all the functionality
8
9 class USB:
10     state_detached                      = 0
11     state_attached                      = 1
12     state_powered                       = 2
13     state_default                       = 3
14     state_address                       = 4
15     state_configured                    = 5
16     state_suspended                     = 6
17
18     request_direction_host_to_device    = 0
19     request_direction_device_to_host    = 1
20
21     request_type_standard               = 0
22     request_type_class                  = 1
23     request_type_vendor                 = 2
24
25     request_recipient_device            = 0
26     request_recipient_interface         = 1
27     request_recipient_endpoint          = 2
28     request_recipient_other             = 3
29
30     feature_endpoint_halt               = 0
31     feature_device_remote_wakeup        = 1
32     feature_test_mode                   = 2
33
34     desc_type_device                    = 1
35     desc_type_configuration             = 2
36     desc_type_string                    = 3
37     desc_type_interface                 = 4
38     desc_type_endpoint                  = 5
39     desc_type_device_qualifier          = 6
40     desc_type_other_speed_configuration = 7
41     desc_type_interface_power           = 8
42     desc_type_hid                       = 33
43     desc_type_report                    = 34
44
45     # while this holds for HID, it may not be a correct model for the USB
46     # ecosystem at large
47     if_class_to_desc_type = {
48             3 : desc_type_hid
49     }
50
51     def interface_class_to_descriptor_type(interface_class):
52         return USB.if_class_to_desc_type[interface_class]
53