+ /* Data lost considerations:
+ * 1. When buffer is full at early satage of startup, we will have to start sending
+ * before console_is_ready() returns true. Data can be lost even if sending data
+ * seems to be successful on USB. hid_listen on host is not ready perhaps?
+ * Sometime first few packets are lost when buffer is full at startup.
+ * 2. When buffer is full and USB pipe is not ready, new coming data will be lost.
+ * 3. console_task() cannot send data in buffer while main loop is blocked.
+ */
+ /* retry timeout */
+ const uint8_t CONSOLE_TIMOUT = 5; // 1 is too small, 2 seems to be enough for Linux
+ static uint8_t timeout = CONSOLE_TIMOUT;
+ uint16_t prev = timer_read();
+ bool done = false;
+
+ uint8_t ep = Endpoint_GetCurrentEndpoint();