I was trying UART
using STM32F407V6T6
and CubeMx
.
As I have posted some problems with strstr()
function. Here is some new problems.
Here is the code:
char rxBuff[10];
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
Green_Blink(100);
Orange_Blink(100);
Blue_Blink(100);
Red_Blink(100);
while (1)
{
HAL_UART_Transmit_IT(&huart2,(uint8_t*)"hello\r\n",10);
HAL_Delay(1000);
Orange_Blink(100);
if (strstr(rxBuff,"hi"))
{
}
}
}
Here what i am doing is I am transmitting hello\r\n
using Transmit interrupt. After transmitting I am checking for certain values like hi
in rxBuff[10]
.
In this particular code i am not receiving anything I just created the buffer and checking if it contains hi
or not.
Note that while transmitting I am just sending 7 bytes of data. But in HAL_UART_Transmit_IT()
at place of size I am giving 10.
HAL_UART_Transmit_IT(&huart2,(uint8_t*)"hello\r\n",10);
After flashing this code to my stm32 I can see in terminal various output like
hello\r\nhi
If I change the txt from hi
to some other thing like planets, then the output will be like
hello\r\npl
But when I give the perfect size like this
HAL_UART_Transmit_IT(&huart2,(uint8_t*)"hello\r\n",7);
I get the actual output i should be getting
hello\r\n
Transmitting the data via UART and finding if substring is present in some buffer is totally different tasks.
Any suggestions why this is happening?
P.S: Basically my project is with GSM MODULE SIM800c and STM32f407VGt6 I want to send various AT commands from the stm32 and check the response so that I can work accordingly.
Previously I have tried this project with AVR series mcus where I could send sms,receive a particular sms,send data to server using post and get methods and everything worked completely fine.
After moving to ARM I am not getting how STM32 is behaving.