From a75834ee98e94cea329aea224a4daaed1a4bf681 Mon Sep 17 00:00:00 2001 From: flabbergast Date: Fri, 18 Dec 2015 20:50:59 +0000 Subject: [PATCH] Do timeout when writing to CONSOLE EP queue. Fixes TMK bug #266. --- tmk_core/protocol/chibios/usb_main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 85548fbb..ee2788e5 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -1323,10 +1323,13 @@ int8_t sendchar(uint8_t c) { return 0; } osalSysUnlock(); - /* should get suspended and wait if the queue is full - * but it's not blocking even if noone is listening, - * because the USB packets are sent anyway */ - return(chOQPut(&console_queue, c)); + /* Timeout after 5us if the queue is full. + * Increase this timeout if too much stuff is getting + * dropped (i.e. the buffer is getting full too fast + * for USB/HIDRAW to dequeue). Another possibility + * for fixing this kind of thing is to increase + * CONSOLE_QUEUE_CAPACITY. */ + return(chOQPutTimeout(&console_queue, c, US2ST(5))); } #else /* CONSOLE_ENABLE */ -- 2.46.0