diff --git a/uCNC/src/modules/softuart.c b/uCNC/src/modules/softuart.c index 5ef799ae6..cf5b52ea8 100644 --- a/uCNC/src/modules/softuart.c +++ b/uCNC/src/modules/softuart.c @@ -69,7 +69,7 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout) return 0; } - return mcu_uart2_getc(); + val = mcu_uart2_getc(); #endif } else @@ -82,6 +82,11 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout) } } + __TIMEOUT_ASSERT__(ms_timeout) + { + return 0; + } + port->waithalf(); uint8_t bits = 8; @@ -99,10 +104,5 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout) port->waithalf(); } - __TIMEOUT_ASSERT__(ms_timeout) - { - return 0; - } - return (int16_t)val; } diff --git a/uCNC/src/utils.h b/uCNC/src/utils.h index 514bdb32e..9410b7ccc 100644 --- a/uCNC/src/utils.h +++ b/uCNC/src/utils.h @@ -434,7 +434,7 @@ extern "C" #define __TIMEOUT_US__(timeout) for (int32_t elap_us_##timeout, curr_us_##timeout = mcu_free_micros(); ((int32_t)timeout) >= 0; elap_us_##timeout = mcu_free_micros() - curr_us_##timeout, timeout -= ABS(elap_us_##timeout), curr_us_##timeout = mcu_free_micros()) #define __TIMEOUT_MS__(timeout) timeout*=1000; __TIMEOUT_US__(timeout) -#define __TIMEOUT_ASSERT__(timeout) if(timeout < 0) +#define __TIMEOUT_ASSERT__(timeout) if(((int32_t)timeout) < 0) #if defined(__GNUC__) && __GNUC__ >= 7 #define __FALL_THROUGH__ __attribute__ ((fallthrough));