Fix buffer overwrite while DMA is not completed
This commit is contained in:
+7
-3
@@ -109,14 +109,18 @@ void vUARTLogger(void *argument)
|
|||||||
DEBUG_PRINT("Waiting for CAN traffic...\r\n");
|
DEBUG_PRINT("Waiting for CAN traffic...\r\n");
|
||||||
if (osMessageQueueGet(xUARTQueue, &message, NULL, osWaitForever) == osOK)
|
if (osMessageQueueGet(xUARTQueue, &message, NULL, osWaitForever) == osOK)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("CAN frame detected\r\n");
|
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
|
||||||
int len = format_can_message(tx_buffer, message.source, &message);
|
int len = format_can_message(tx_buffer, message.source, &message);
|
||||||
|
|
||||||
if (HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len) == HAL_OK)
|
if (HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len) == HAL_OK)
|
||||||
{
|
{
|
||||||
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
|
|
||||||
DEBUG_PRINT("CAN frame sent via UART\r\n");
|
DEBUG_PRINT("CAN frame sent via UART\r\n");
|
||||||
}
|
}
|
||||||
else DEBUG_PRINT("HAL error, CAN frame NOT sent!\r\n");
|
else
|
||||||
|
{
|
||||||
|
osSemaphoreRelease(xUARTDMASemaphore);
|
||||||
|
DEBUG_PRINT("HAL error, CAN frame NOT sent!\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user