X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FUSBInterface.py;h=ddc30cc103b120c00c9a246a9efc72579d5d1a01;hp=449b55781282ab5a40263f0272f034b6bd2533f1;hb=0c1cae929512565296940bf6322087a73b2cecd0;hpb=85180b93353582dd0cb8c344b6170192c858f86d diff --git a/client/USBInterface.py b/client/USBInterface.py index 449b557..ddc30cc 100644 --- a/client/USBInterface.py +++ b/client/USBInterface.py @@ -30,6 +30,17 @@ class USBInterface: 11 : self.handle_set_interface_request } + self.configuration = None + + for e in self.endpoints: + e.set_interface(self) + + self.device_class = None + self.device_vendor = None + + def set_configuration(self, config): + self.configuration = config + # USB 2.0 specification, section 9.4.3 (p 281 of pdf) # HACK: blatant copypasta from USBDevice pains me deeply def handle_get_descriptor_request(self, req): @@ -52,13 +63,13 @@ class USBInterface: if response: n = min(n, len(response)) - self.device.maxusb_app.send_on_endpoint(0, response[:n]) + self.configuration.device.maxusb_app.send_on_endpoint(0, response[:n]) if self.verbose > 5: print(self.name, "sent", n, "bytes in response") def handle_set_interface_request(self, req): - self.device.maxusb_app.stall_ep0() + self.configuration.device.maxusb_app.stall_ep0() # Table 9-12 of USB 2.0 spec (pdf page 296) def get_descriptor(self): @@ -77,7 +88,8 @@ class USBInterface: if self.iclass: iclass_desc_num = USB.interface_class_to_descriptor_type(self.iclass) - d += self.descriptors[iclass_desc_num] + if iclass_desc_num: + d += self.descriptors[iclass_desc_num] for e in self.endpoints: d += e.get_descriptor()