# HG changeset patch # User Ideenmodellierer # Date 1725219486 -7200 # Node ID d398ecc7d103f72e64913f937d4a8fd027ce3c6e # Parent 8d3f3a635397d7e957fe3a8c7e0ba1868fd32d60 Improve communication stability: In case e.g. the bluetooth module has just been started some 'noice' characters may be in the receive buffer causing an error in the modul responds function. In case the legth of the response is unexpected then the buffer will be evaluated till it is empty or an matching answer is found. diff -r 8d3f3a635397 -r d398ecc7d103 Discovery/Src/tComm.c --- a/Discovery/Src/tComm.c Sun Sep 01 21:35:50 2024 +0200 +++ b/Discovery/Src/tComm.c Sun Sep 01 21:38:06 2024 +0200 @@ -2038,9 +2038,11 @@ { do { - answer = HAL_UART_Receive(&UartHandle, (uint8_t*)&aRxBuffer[indexBuf], 1, 10); + answer = HAL_ERROR; if (indexBuf < UART_CMD_BUF_SIZE) { + answer = HAL_UART_Receive(&UartHandle, (uint8_t*)&aRxBuffer[indexBuf], 1, 10); + if(answerOkay[indexRef] == aRxBuffer[indexBuf]) { indexRef++; @@ -2054,7 +2056,7 @@ } indexBuf++; } - }while(answer == HAL_OK); + }while((answer == HAL_OK) && (indexRef != sizeAnswer)); if(indexRef != sizeAnswer) { result = HAL_ERROR;