yoneken / rosserial_stm32

This is a part of [rosserial](https://github.com/ros-drivers/rosserial) repository to communicate with ROS system through a USART for STM32 embedded system.
BSD 2-Clause "Simplified" License
218 stars 72 forks source link

Why to call flush() in HAL_UART_TxCpltCallback()? #2

Closed techping closed 6 years ago

techping commented 6 years ago

Hello, I saw all your examples are publishers, and both call flush() in HAL_UART_TxCpltCallback(). If I want to implement a subscriber, whether I need to do something in HAL_UART_RxCpltCallback()?

techping commented 6 years ago

I use your code to implement a subscriber, but it always causes the error: Lost sync with device, restarting.. Finally, I found out that the problem is that the receive buffer rbuflen overflowed. So, I call HAL_UART_Receive_DMA(huart, rbuf, rbuflen); in HAL_UART_RxCpltCallback(), and then the problem is solved.

yoneken commented 6 years ago

@techping I fixed the issue with your kindly advice. Thanks a lot!

techping commented 6 years ago

@yoneken You are welcome. :-) BTW, I have modified your code to run on my stm32f407 discovery board. And it can work now.:grinning:

yoneken commented 6 years ago

Pull requests are always welcome! :smiley_cat: