diff --git a/test/speedtest_fullspeed.py b/test/speedtest_fullspeed.py index 7527eabb..71be19c4 100755 --- a/test/speedtest_fullspeed.py +++ b/test/speedtest_fullspeed.py @@ -66,6 +66,18 @@ def handle_data_requested(self, ep): print(f"sending {len(self.random_buffer)} bytes on {ep}") self.send(ep.number, self.random_buffer) + def handle_buffer_empty(self, endpoint: USBEndpoint): + """ Handler called when a given endpoint first has an empty buffer. + + Often, an empty buffer indicates an opportunity to queue data + for sending ('prime an endpoint'), but doesn't necessarily mean + that the host is planning on reading the data. + + This function is called only once per buffer. + """ + print(f"priming {len(self.random_buffer)} bytes on {endpoint}") + self.send(endpoint.number, self.random_buffer) + if __name__ == "__main__": default_main(USBSpeedtest) diff --git a/test/speedtest_highspeed.py b/test/speedtest_highspeed.py index 7b970c51..ad21e62a 100755 --- a/test/speedtest_highspeed.py +++ b/test/speedtest_highspeed.py @@ -99,6 +99,17 @@ def handle_data_requested(self, ep): print(f"sending {len(self.random_buffer)} bytes on {ep}") self.send(ep.number, self.random_buffer) + def handle_buffer_empty(self, endpoint: USBEndpoint): + """ Handler called when a given endpoint first has an empty buffer. + + Often, an empty buffer indicates an opportunity to queue data + for sending ('prime an endpoint'), but doesn't necessarily mean + that the host is planning on reading the data. + + This function is called only once per buffer. + """ + print(f"priming {len(self.random_buffer)} bytes on {endpoint}") + self.send(endpoint.number, self.random_buffer) if __name__ == "__main__": default_main(USBSpeedtest)