From 1e7c280491232110e1006d545f9a61ca05d469d5 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sat, 16 Apr 2016 13:59:11 -0700 Subject: [PATCH] g: fix usb console LF handling It was observed that when connecting to the CR50 console over USB, there the line feed (LF) characters are not supplemented by carriage return (CR), which causes weird console output. Detailed examination has shown that uart_putc() does not do the right thing itself and also bypasses __tx_char() used by uart_puts(), which does the right thing. The simplest solution is to have uart_putc() re-use all the smarts of uart_puts(). BRANCH=none BUG=none TEST=verified that usb console output does not suffer from the "lost CR" syndrome any more. Change-Id: I2a1f84b2524c41eb6e84186141b0b9ac55e87ee0 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/339217 Reviewed-by: Mary Ruthven --- chip/g/usb_console.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/chip/g/usb_console.c b/chip/g/usb_console.c index 8195b5b433..27a8d15b95 100644 --- a/chip/g/usb_console.c +++ b/chip/g/usb_console.c @@ -294,19 +294,6 @@ int usb_getc(void) return -1; } -int usb_putc(int c) -{ - int ret = usb_wait_console(); - - if (ret) - return ret; - - ret = QUEUE_ADD_UNITS(&tx_q, &c, 1); - if (ret) - handle_output(); - return ret ? EC_SUCCESS : EC_ERROR_OVERFLOW; -} - int usb_puts(const char *outstr) { int ret; @@ -330,6 +317,15 @@ int usb_puts(const char *outstr) return *outstr ? EC_ERROR_OVERFLOW : EC_SUCCESS; } +int usb_putc(int c) +{ + char string[2]; + + string[0] = c; + string[1] = '\0'; + return usb_puts(string); +} + int usb_vprintf(const char *format, va_list args) { int ret;