I highly recommend you to check the return value of the HAL_UART_Receive
function. In case of any error, check UART specific error using HAL_UART_GetError
function. I could not get it how you get the timeout error without checking function status. I can give you more accurate answers after you check the function status. Maybe try to enable UART interrupts and put a breakpoint to the interrupt function and check if code reaches the breakpoint. If not reach there, you might have some other problems rather than a coding problem.