From 44c8069855aff9adb65448692de3272d0bb1603a Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 13 Apr 2011 12:21:28 -0700 Subject: USRP2/N210: firmware UART read no longer drops 20th char --- firmware/zpu/lib/hal_io.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'firmware') diff --git a/firmware/zpu/lib/hal_io.c b/firmware/zpu/lib/hal_io.c index 1d137943c..4ed694b9d 100644 --- a/firmware/zpu/lib/hal_io.c +++ b/firmware/zpu/lib/hal_io.c @@ -255,12 +255,14 @@ fngets(hal_uart_name_t u, char * const s, int len) int fngets_noblock(hal_uart_name_t u, char * const s, int len) { - char *x = s; - - while(((*x=(char)hal_uart_getc_noblock(u)) != '\n') && (*x != 255) && ((x-s) < len)) x++; - *x = 0; - //printf("Returning from fngets() with string %d of length %d\n", s[0], x-s); - return (x-s); + int i; + for(i=0; i < len; i++) { + s[i] = (char) hal_uart_getc_noblock(u); + if((s[i] == 255) || (s[i] == '\n')) break; + } + s[i] = 0; + + return i; } char * -- cgit v1.2.3