cancel
Showing results for 
Search instead for 
Did you mean: 

Receive data with unknown length via UART

Emm1592
Associate II

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.

14 REPLIES 14

@Emm1592​ , could you please share the code? Thank you

Can I get a copy of your code ?

 Could you please share the code? Thank you.

@Emm1592​  could you please share the code?

I am doing the same with stm32f030cctc and quectel m66.

Kolab
Senior

@Emm1592​ could I get your code too,please? I am facing the same problem.