Terminate an incomming UART packet by recognising a terminating ASCII character (using UART interrupts)
Hi, I'm new to this community and I hope you can help with my first question.
After a lot of effort in trying to get arbtrary length packet reception over UART working on an STM32F3 processor i've changed tack and I'm trying to get the UART to terminate when a specific ASCII character code is recognised. I have the bare bones of a solution, but the last piece in the jigsaw illudes me. On receiving the character I need to fool the processor into thinking that the RxBUFFer is full, in whuch case it will trigger the HAL-RxCpltCallBack function triggered by UART_Receive_IT via the HAL_UART_IRQHandler.
Can anyone advise me, by example how to achieve this please. Code snippets for the ISR and RxCpltCallBack are copied below.
Thanks in advance.
void USART2_IRQHandler(void)
{++IntCount;
/* USER CODE END USART2_IRQn 0 */ HAL_UART_IRQHandler(&huart2); /* USER CODE BEGIN USART2_IRQn 1 *///test if the latest byte received in RxBuf == the terminating character code
if(RxBuf[IntCount-1] == 0x7e){// If terminating, need to fool system into thinking that RxBuff is full
// thus forcing the system to reset and fill up the RxBuf from RxBuf[0]? // Also need to know how many bytes in RxBuf are valid, // Currently using IntCount but isn't this already done lower down? __nop(); }/* USER CODE END USART2_IRQn 1 */
}/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){ HAL_UART_Receive_IT(&huart2, RxBuf, RxBufLen); IntCount = 0; __nop();}
/* USER CODE END 4 */