+
+// measure the USB Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time.
+// Note: this mimics GetFromBigbuf(), i.e. we have the overhead of the UsbCommand structure included.
+void printUSBSpeed(void)
+{
+ Dbprintf("USB Speed:");
+ Dbprintf(" Sending USB packets to client...");
+
+ #define USB_SPEED_TEST_MIN_TIME 1500 // in milliseconds
+ uint8_t *test_data = BigBuf_get_addr();
+ uint32_t end_time;
+
+ uint32_t start_time = end_time = GetTickCount();
+ uint32_t bytes_transferred = 0;
+
+ LED_B_ON();
+ while(end_time < start_time + USB_SPEED_TEST_MIN_TIME) {
+ cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, 0, USB_CMD_DATA_SIZE, 0, test_data, USB_CMD_DATA_SIZE);
+ end_time = GetTickCount();
+ bytes_transferred += USB_CMD_DATA_SIZE;
+ }
+ LED_B_OFF();
+
+ Dbprintf(" Time elapsed: %dms", end_time - start_time);
+ Dbprintf(" Bytes transferred: %d", bytes_transferred);
+ Dbprintf(" USB Transfer Speed PM3 -> Client = %d Bytes/s",
+ 1000 * bytes_transferred / (end_time - start_time));
+
+}
+