Improved UART Timeout
Apparently, the UART data Rx/Tx is quite unreliable (especially under motor load) leading to very often out-of-sync issues. This change allows to reset the DMA more often, leading to a faster re-sync of the UART transmission and thus avoiding UART timeout.
This commit is contained in:
parent
32f4a2c03e
commit
34c6e4d610
10
Src/util.c
10
Src/util.c
|
@ -731,7 +731,7 @@ void readCommand(void) {
|
||||||
timeoutCntSerial = SERIAL_TIMEOUT; // Limit timout counter value
|
timeoutCntSerial = SERIAL_TIMEOUT; // Limit timout counter value
|
||||||
}
|
}
|
||||||
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
||||||
if (main_loop_counter % 30 == 0) {
|
if (command.start != IBUS_LENGTH && command.start != 0xFF && main_loop_counter % 2 == 0) {
|
||||||
HAL_UART_DMAStop(&huart);
|
HAL_UART_DMAStop(&huart);
|
||||||
HAL_UART_Receive_DMA(&huart, (uint8_t *)&command, sizeof(command));
|
HAL_UART_Receive_DMA(&huart, (uint8_t *)&command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ void readCommand(void) {
|
||||||
timeoutCntSerial = SERIAL_TIMEOUT; // Limit timout counter value
|
timeoutCntSerial = SERIAL_TIMEOUT; // Limit timout counter value
|
||||||
}
|
}
|
||||||
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
||||||
if (main_loop_counter % 30 == 0) {
|
if (command.start != SERIAL_START_FRAME && command.start != 0xFFFF && main_loop_counter % 2 == 0) {
|
||||||
HAL_UART_DMAStop(&huart);
|
HAL_UART_DMAStop(&huart);
|
||||||
HAL_UART_Receive_DMA(&huart, (uint8_t *)&command, sizeof(command));
|
HAL_UART_Receive_DMA(&huart, (uint8_t *)&command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
@ -787,7 +787,7 @@ void readCommand(void) {
|
||||||
timeoutCntSerial_L = SERIAL_TIMEOUT; // Limit timout counter value
|
timeoutCntSerial_L = SERIAL_TIMEOUT; // Limit timout counter value
|
||||||
}
|
}
|
||||||
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
||||||
if (main_loop_counter % 30 == 0) {
|
if (Sideboard_Lnew.start != SERIAL_START_FRAME && Sideboard_Lnew.start != 0xFFFF && main_loop_counter % 2 == 0) {
|
||||||
HAL_UART_DMAStop(&huart2);
|
HAL_UART_DMAStop(&huart2);
|
||||||
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&Sideboard_Lnew, sizeof(Sideboard_Lnew));
|
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&Sideboard_Lnew, sizeof(Sideboard_Lnew));
|
||||||
}
|
}
|
||||||
|
@ -810,7 +810,7 @@ void readCommand(void) {
|
||||||
timeoutCntSerial_R = SERIAL_TIMEOUT; // Limit timout counter value
|
timeoutCntSerial_R = SERIAL_TIMEOUT; // Limit timout counter value
|
||||||
}
|
}
|
||||||
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
// Most probably we are out-of-sync. Try to re-sync by reseting the DMA
|
||||||
if (main_loop_counter % 30 == 0) {
|
if (Sideboard_Rnew.start != SERIAL_START_FRAME && Sideboard_Rnew.start != 0xFFFF && main_loop_counter % 2 == 0) {
|
||||||
HAL_UART_DMAStop(&huart3);
|
HAL_UART_DMAStop(&huart3);
|
||||||
HAL_UART_Receive_DMA(&huart3, (uint8_t *)&Sideboard_Rnew, sizeof(Sideboard_Rnew));
|
HAL_UART_Receive_DMA(&huart3, (uint8_t *)&Sideboard_Rnew, sizeof(Sideboard_Rnew));
|
||||||
}
|
}
|
||||||
|
@ -818,7 +818,7 @@ void readCommand(void) {
|
||||||
timeoutFlagSerial = timeoutFlagSerial_R;
|
timeoutFlagSerial = timeoutFlagSerial_R;
|
||||||
#endif
|
#endif
|
||||||
#if defined(SIDEBOARD_SERIAL_USART2) && defined(SIDEBOARD_SERIAL_USART3)
|
#if defined(SIDEBOARD_SERIAL_USART2) && defined(SIDEBOARD_SERIAL_USART3)
|
||||||
timeoutFlagSerial = timeoutFlagSerial_L | timeoutFlagSerial_R;
|
timeoutFlagSerial = timeoutFlagSerial_L || timeoutFlagSerial_R;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VARIANT_HOVERCAR
|
#ifdef VARIANT_HOVERCAR
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
Loading…
Reference in New Issue