I have a custom STM32F4 MCU board. I need to receive different types of sequences from Master board in a RS485 n/w. Lengths of data to be received is variable say 10 bytes, 25 bytes and so on. I have to handle every sequence and respond accordingly.
How to properly make use of HAL functions HAL_UART_Receive_IT and HAL_UART_RxCpltCallback to receive variable data properly?
I see that 3rd argument of HAL_UART_Receive_IT is looking for number of bytes to be fixed like shown:
HAL_UART_Receive_IT(&huart1, &uart1_rx_byte, no_of_bytes);
Please suggest a good implementation...
Receiving frame format:
| Start byte | Slave Addr | Byte count | Func. ID | Data1 | Data2 |...|Data n| Checksum byte 1 | Checksum byte 2 |
Where Byte count = no. of bytes from Func. ID to Checksum byte 2
question from:
https://stackoverflow.com/questions/65930701/how-uart-rx-interrupt-routine-is-implemented-for-variable-length-data 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…