2024-03-05 02:02 AM
Hi everyone!
I'm using a NucleoWB55 and the LPUART protocole to communicate with a SIMCOM module. I'm able to send via the LPUART the AT commands that I want and to receive it's answers. I'm now trying to print on my terminal the content of my web page. I connected a USB to TTL (CP2102 module) to observe the UART RX of the SIMCOM module. The module transmits the entire content of the web page but I can't get it on my STM32 via LPUART. To make it easy to understand here are some screenshots :
Here is the terminal where I transmit via UART the received data:
Here is the terminal where the transmit data of the SIMCOM module is connected:
We can see the entire content of the web page.
Finally the interesting parts of my code :
Commands and reception buffers:
I presume there's a problem in receiving and displaying the data received. I know my "received" buffer doesn't contain many characters at the moment, but I should still be able to receive the start of the page, shouldn't I?
Does anyone know what the problem might be?
Thanks a lot!
Solved! Go to Solution.
2024-03-05 05:15 AM
Don't use blocking functions (HAL_UART_Transmit) inside of an interrupt callback. Any characters caught during this time will lead to an overflow error condition. Perhaps set a flag and handle the transmission back in the main thread.
Monitor for errors by implementing HAL_UART_ErrorCallback or examining the software state machine (hlpuart1).
Don't mess with writing recu in the main thread--it may be being written in the interrupt. If you want to zero-initialize it, do so right before HAL_UARTEx_ReceiveToIdle_IT.
2024-03-05 05:15 AM
Don't use blocking functions (HAL_UART_Transmit) inside of an interrupt callback. Any characters caught during this time will lead to an overflow error condition. Perhaps set a flag and handle the transmission back in the main thread.
Monitor for errors by implementing HAL_UART_ErrorCallback or examining the software state machine (hlpuart1).
Don't mess with writing recu in the main thread--it may be being written in the interrupt. If you want to zero-initialize it, do so right before HAL_UARTEx_ReceiveToIdle_IT.
2024-03-05 06:33 AM
Don't use sizeof() for strings, you'll send the NUL over the wire. Make a function for strings that uses strlen(), or use sizeof()-1 each time.
The terminal and website may have different ideas about CR/LF, remember UNIX/LINUX typically doesn't use them as a pair.
With AT commands it's generally better to process the responses in a stateful manner, looking for OK, ERROR, NO CARRIER, etc rather than blind / arbitrary delays.
2024-03-06 10:37 AM
I used HAL_UART_Transmit_IT and it's working fine!
Thank you!