How do I receive a command through UART in polling mode?
I'm new to STM32 processors. I'm learning on a Nucleo F103rb board. I was able to receive a single character through UART in polling mode, but unfortunately I have difficulties in receiving more than 1 character. It would be used for the device to wait for a user command and then execute it.
I'm using the HAL_UART_Receive function. This code allows me to receive a singe character and then use it e.g. in a switch/case instruction
while(1)
{
if (__HAL_UART_GET_FLAG(&uart, UART_FLAG_RXNE) == SET)
{
uint8_t value;
HAL_UART_Receive(&uart, &value, 1, 100);
switch (value)The value variable needs to be a uint8_t type. However now I need to receive a table of chars. How do I do that? If I need a 3-character command, shall I change 1 to 3 (or 4, because there is a \0 character on the end of each string)?
I would then use the string with an if and a strcmp() method, but I do need to know how to receive and store multiple characters with the terminal waiting for the full input.
This is probably a basic c programming matter and surely easy peasy for many experienced programmers. But I need to learn this somehow. I will be thankful for any help.
