2020-07-29 08:26 AM
i am try to interface the STM32F103C8T6 with GSM & usb to Serial converter (Multi USART). But in GSM AT Comment Response Data Length is Different for Each & every time.
I don't know how to handle the UART Receive with unknown data length Please help me Solve this Problem.
If there is any reference link to Know how to handle that, Please Share that also.
2020-07-29 08:46 AM
There are 2 methods:
Your application and MCU selection should help make a decision.
2020-07-29 08:54 AM
You keep reading data, and parse what actually arrives.
The STM32F1 is going to interrupt for each byte received, so build a state machine. Use DMA for TX. Decide if the complication of using DMA for RX outweighs other considerations. Have an algorithm that sweeps the buffer at HT, TC and 1ms. Cellular Modems have response times in the 100ms to several minutes.
2020-07-29 10:52 AM
All answers are right.
for fastest response time:
make a big enough buffer and fill it with incoming usart bytes via DMA. Also enable usart idle line detection interrupt. when a packet received, you will get into idle line ISR. There you can parse the new received bytes based on DMA CNDTR register.
2020-07-30 12:06 PM
Hi, I made and approach based in polling and timeout with 2 functions. With usr_uart_SerialAvailable you check is there is incoming data based in a timeout value USR_UART_BUFFER_TIMEOUT, if there is incoming data it keep reading it until the buffer is full or the timeout is reached, the buffer size is USR_UART_BUFFER_SIZE, after that you call usr_uart_ReadString for copy the incoming data. Please check it