diff --git a/native/drivers/native-uart0.c b/native/drivers/native-uart0.c index 3af009eee4dff864c07483bdfefd74bf493718d9..fc5eed29c3a80bb9a9b71d0a9b2d998f80af0a9a 100644 --- a/native/drivers/native-uart0.c +++ b/native/drivers/native-uart0.c @@ -27,6 +27,10 @@ void _native_handle_uart0_input() char buf[42]; int nread; + if (!FD_ISSET(_native_uart_in, &_native_rfds)) { + DEBUG("_native_handle_uart0_input - nothing to do\n"); + return; + } DEBUG("_native_handle_uart0_input\n"); _native_in_syscall = 0; _native_in_isr = 1; @@ -44,15 +48,18 @@ void _native_handle_uart0_input() cpu_switch_context_exit(); } +int _native_set_uart_fds(void) +{ + DEBUG("_native_set_uart_fds"); + FD_SET(_native_uart_in, &_native_rfds); + return _native_uart_in; +} + void _native_init_uart0() { _native_uart_out = STDOUT_FILENO; _native_uart_in = STDIN_FILENO; - /* set fds for select in lpm */ - FD_ZERO(&_native_uart_rfds); - FD_SET(_native_uart_in, &_native_uart_rfds); - puts("RIOT native uart0 initialized."); } diff --git a/native/include/board_internal.h b/native/include/board_internal.h index 752cbcdfb5333430baf8d37d01d14cd888d76f69..368d5287de63a9dbbb6a7a2bcdcc4eb0cd58ee3f 100644 --- a/native/include/board_internal.h +++ b/native/include/board_internal.h @@ -1,6 +1,6 @@ #ifdef MODULE_UART0 #include <sys/select.h> -extern fd_set _native_uart_rfds; void _native_handle_uart0_input(void); void _native_init_uart0(void); +int _native_set_uart_fds(void); #endif