diff --git a/components/base_nodemcu/uart.c b/components/base_nodemcu/uart.c index 014cacc4..43debd92 100644 --- a/components/base_nodemcu/uart.c +++ b/components/base_nodemcu/uart.c @@ -131,6 +131,7 @@ static int uart_write( lua_State* L ) if( len > 255 ) return luaL_error( L, "invalid number" ); platform_uart_send( id, (uint8_t)len ); + platform_uart_flush( id ); } else { @@ -138,6 +139,7 @@ static int uart_write( lua_State* L ) buf = lua_tolstring( L, s, &len ); for( i = 0; i < len; i ++ ) platform_uart_send( id, buf[ i ] ); + platform_uart_flush( id ); } } return 0; diff --git a/components/platform/include/platform.h b/components/platform/include/platform.h index 2ba8b076..be08f8f7 100644 --- a/components/platform/include/platform.h +++ b/components/platform/include/platform.h @@ -72,6 +72,7 @@ enum static inline int platform_uart_exists( unsigned id ) { return id < NUM_UART; } uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int parity, int stopbits ); void platform_uart_send( unsigned id, uint8_t data ); +void platform_uart_flush( unsigned id ); int platform_uart_set_flow_control( unsigned id, int type ); diff --git a/components/platform/platform.c b/components/platform/platform.c index 70d1b8b5..c5fb989f 100644 --- a/components/platform/platform.c +++ b/components/platform/platform.c @@ -68,6 +68,12 @@ void platform_uart_send( unsigned id, uint8_t data ) putchar (data); } +void platform_uart_flush( unsigned id ) +{ + if (id == CONSOLE_UART) + fflush (stdout); +} + // ***************************************************************************** // Sigma-Delta platform interface