Receive data with unknown length via UART
Hello, I'm using the STM32L476RG and trying to receive data via UART.
When I use the following code:
int main(void){
...
HAL_UART_Receive_IT(&huart4, data_RX,20);
....
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
printf("\nMessage received is: %s",data_RX);
}
This works just fine if ONLY the message received is 20 characters long.
But not if the message is for example 15. I know that when my data_Rx is full, it then will be printed.
I was wondering if anyone came across this problem and was successful implementing a solution. I tried some of the codes I found on the internet, but lot of them where really confusing.
Sorry if this topic was already discuss.
Any help would be awesome!
Thank you.
