diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/zpu/lib/hal_io.c | 5 | ||||
-rw-r--r-- | firmware/zpu/lib/hal_uart.c | 2 | ||||
-rw-r--r-- | firmware/zpu/lib/udp_uart.c | 5 |
3 files changed, 7 insertions, 5 deletions
diff --git a/firmware/zpu/lib/hal_io.c b/firmware/zpu/lib/hal_io.c index 4ed694b9d..d4be324f5 100644 --- a/firmware/zpu/lib/hal_io.c +++ b/firmware/zpu/lib/hal_io.c @@ -257,8 +257,9 @@ fngets_noblock(hal_uart_name_t u, char * const s, int len) { int i; for(i=0; i < len; i++) { - s[i] = (char) hal_uart_getc_noblock(u); - if((s[i] == 255) || (s[i] == '\n')) break; + int ret = hal_uart_getc_noblock(u); + s[i] = (char) ret; + if((ret == -1) || (s[i] == '\n')) break; } s[i] = 0; diff --git a/firmware/zpu/lib/hal_uart.c b/firmware/zpu/lib/hal_uart.c index 6a37cceb6..af60bed6a 100644 --- a/firmware/zpu/lib/hal_uart.c +++ b/firmware/zpu/lib/hal_uart.c @@ -108,7 +108,7 @@ hal_uart_getc_noblock(hal_uart_name_t u) // int timeout = 0; // while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS)) // mdelay(1); - if(uart_regs[u].rxlevel == 0) return 255; + if(uart_regs[u].rxlevel == 0) return -1; return uart_regs[u].rxchar; } diff --git a/firmware/zpu/lib/udp_uart.c b/firmware/zpu/lib/udp_uart.c index 6f6b9ee91..a3940c05f 100644 --- a/firmware/zpu/lib/udp_uart.c +++ b/firmware/zpu/lib/udp_uart.c @@ -94,8 +94,9 @@ void udp_uart_poll(void){ //read all characters we can without blocking for (size_t j = state->len; j < sizeof(_states[0].buf); j++){ - uint8_t ch = hal_uart_getc_noblock((hal_uart_name_t)i); - if (ch == 255) break; + int ret = hal_uart_getc_noblock((hal_uart_name_t)i); + if (ret == -1) break; + char ch = (char) ret; if (ch == '\n' || ch == '\r') newline = true; state->buf[j] = ch; state->len++; |