X
Xenon02
Guest
Hello !
I've wanted to ask a bit how RX UART works like when I want to receive more than I want.
I've had a bluetooth HC-06 and tested it on STM32-NucleoL073RZ, the thing is that I've sent a command via HAL_UART_Transmit(), and the command is "AT\r\n", I've sent it and it sends back a message "OK" and I guess it adds at the end "\0" maybe. The thing is I have an RX buffor that is receive[50] and typed "HAL_UART_Receive(&huart2, (uint8_t *)receive, sizeof(receive)-1, HAL_MAX_DELAY)"
Size of receive is 50-1 so it is 49, so I want to receive 49 characters although it is only 2 characters.
Now it worked correctly I've received first 2 characters as O, and K, then the rest of characters are "\0". How does it work ? The bluetooth all the time sends "\0" character no matter what ?
I understood that RX waits for start byte from TX of bluetooth after getting all data it sends that RX is full and then the data is taken from RX and sent to the buffer.
Someone correct me if it's ok : normally it works that it should give an error and something happens to RX I guess.
Or perhaps it can fill those empty spaces with zero or null but how can RX fill itself when usually it waits all the time for the TX start bit. Can someone tell me ?
I've wanted to ask a bit how RX UART works like when I want to receive more than I want.
I've had a bluetooth HC-06 and tested it on STM32-NucleoL073RZ, the thing is that I've sent a command via HAL_UART_Transmit(), and the command is "AT\r\n", I've sent it and it sends back a message "OK" and I guess it adds at the end "\0" maybe. The thing is I have an RX buffor that is receive[50] and typed "HAL_UART_Receive(&huart2, (uint8_t *)receive, sizeof(receive)-1, HAL_MAX_DELAY)"
Size of receive is 50-1 so it is 49, so I want to receive 49 characters although it is only 2 characters.
Now it worked correctly I've received first 2 characters as O, and K, then the rest of characters are "\0". How does it work ? The bluetooth all the time sends "\0" character no matter what ?
I understood that RX waits for start byte from TX of bluetooth after getting all data it sends that RX is full and then the data is taken from RX and sent to the buffer.
Someone correct me if it's ok : normally it works that it should give an error and something happens to RX I guess.
Or perhaps it can fill those empty spaces with zero or null but how can RX fill itself when usually it waits all the time for the TX start bit. Can someone tell me ?