Use better logging codes
This commit is contained in:
@@ -127,8 +127,6 @@ void vCANListener(void *argument)
|
|||||||
|
|
||||||
osMessageQueuePut(xUARTQueue, &message, 0U, 0U);
|
osMessageQueuePut(xUARTQueue, &message, 0U, 0U);
|
||||||
}
|
}
|
||||||
else DEBUG_PRINT("No CAN yet!\r\n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* END vCANListener */
|
/* END vCANListener */
|
||||||
|
|||||||
+4
-13
@@ -151,7 +151,7 @@ void vUARTLogger(void *argument)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("Waiting for CAN traffic...\r\n");
|
DEBUG_PRINT("[D] Waiting for CAN traffic...\r\n");
|
||||||
|
|
||||||
#ifdef DEBUG_DUMMY_FRAME
|
#ifdef DEBUG_DUMMY_FRAME
|
||||||
uint32_t queue_timeout = 1000U;
|
uint32_t queue_timeout = 1000U;
|
||||||
@@ -170,20 +170,11 @@ void vUARTLogger(void *argument)
|
|||||||
{
|
{
|
||||||
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) Error_Handler();
|
||||||
{
|
else DEBUG_PRINT("[E] HAL error, CAN frame NOT sent!\r\n");
|
||||||
DEBUG_PRINT("CAN frame sent via UART\r\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osSemaphoreRelease(xUARTDMASemaphore);
|
osSemaphoreRelease(xUARTDMASemaphore);
|
||||||
DEBUG_PRINT("HAL error, CAN frame NOT sent!\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DEBUG_PRINT("ERROR: Semaphore timeout! UART might be stuck in BUSY state.\r\n");
|
|
||||||
}
|
}
|
||||||
|
else DEBUG_PRINT("[E] Semaphore timeout! UART might be stuck in BUSY state.\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -104,7 +104,7 @@ int main(void)
|
|||||||
ITM->TCR = ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_SWOENA_Msk;
|
ITM->TCR = ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_SWOENA_Msk;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINT("Booting system\r\n");
|
DEBUG_PRINT("[L] Booting system\r\n");
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
@@ -113,7 +113,7 @@ int main(void)
|
|||||||
HAL_Init();
|
HAL_Init();
|
||||||
|
|
||||||
/* USER CODE BEGIN Init */
|
/* USER CODE BEGIN Init */
|
||||||
DEBUG_PRINT("Configuring system clock\r\n");
|
DEBUG_PRINT("[L] Configuring system clock\r\n");
|
||||||
|
|
||||||
/* USER CODE END Init */
|
/* USER CODE END Init */
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ int main(void)
|
|||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
|
|
||||||
/* USER CODE BEGIN SysInit */
|
/* USER CODE BEGIN SysInit */
|
||||||
DEBUG_PRINT("Initializing configured peripherals...\r\n");
|
DEBUG_PRINT("[L] Initializing configured peripherals...\r\n");
|
||||||
/* USER CODE END SysInit */
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
@@ -132,14 +132,14 @@ int main(void)
|
|||||||
MX_SDIO_SD_Init();
|
MX_SDIO_SD_Init();
|
||||||
MX_USART1_UART_Init();
|
MX_USART1_UART_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
DEBUG_PRINT("Initializing CAN bus logger\r\n");
|
DEBUG_PRINT("[L] Initializing CAN bus logger\r\n");
|
||||||
CAN_Logger_Init(&hcan1, &hcan2);
|
CAN_Logger_Init(&hcan1, &hcan2);
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Init scheduler */
|
/* Init scheduler */
|
||||||
osKernelInitialize();
|
osKernelInitialize();
|
||||||
|
|
||||||
DEBUG_PRINT("Creating RTOS entities\r\n");
|
DEBUG_PRINT("[L] Creating RTOS entities\r\n");
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_TASKS */
|
/* USER CODE BEGIN RTOS_TASKS */
|
||||||
const osThreadAttr_t CAN1rxAttributes = {
|
const osThreadAttr_t CAN1rxAttributes = {
|
||||||
@@ -200,7 +200,7 @@ int main(void)
|
|||||||
/* USER CODE END RTOS_EVENTS */
|
/* USER CODE END RTOS_EVENTS */
|
||||||
|
|
||||||
/* Start scheduler */
|
/* Start scheduler */
|
||||||
DEBUG_PRINT("Starting RTOS init scheduler\r\n");
|
DEBUG_PRINT("[L] Starting RTOS init scheduler\r\n");
|
||||||
osKernelStart();
|
osKernelStart();
|
||||||
|
|
||||||
/* We should never get here as control is now taken by the scheduler */
|
/* We should never get here as control is now taken by the scheduler */
|
||||||
@@ -212,7 +212,7 @@ int main(void)
|
|||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
DEBUG_PRINT("ERROR: RTOS scheduler crashed!\r\n");
|
DEBUG_PRINT("[E] RTOS scheduler crashed!\r\n");
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ static void MX_CAN1_Init(void)
|
|||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN CAN1_Init 2 */
|
/* USER CODE BEGIN CAN1_Init 2 */
|
||||||
DEBUG_PRINT("CAN1 initialized!\r\n");
|
DEBUG_PRINT("[L] CAN1 initialized\r\n");
|
||||||
/* USER CODE END CAN1_Init 2 */
|
/* USER CODE END CAN1_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -332,7 +332,7 @@ static void MX_CAN2_Init(void)
|
|||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN CAN2_Init 2 */
|
/* USER CODE BEGIN CAN2_Init 2 */
|
||||||
DEBUG_PRINT("CAN2 initialized!\r\n");
|
DEBUG_PRINT("[L] CAN2 initialized\r\n");
|
||||||
/* USER CODE END CAN2_Init 2 */
|
/* USER CODE END CAN2_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ static void MX_SDIO_SD_Init(void)
|
|||||||
// Error_Handler();
|
// Error_Handler();
|
||||||
//}
|
//}
|
||||||
/* USER CODE BEGIN SDIO_Init 2 */
|
/* USER CODE BEGIN SDIO_Init 2 */
|
||||||
//DEBUG_PRINT("SDIO initialized!\r\n");
|
//DEBUG_PRINT("[L] SDIO initialized\r\n");
|
||||||
/* USER CODE END SDIO_Init 2 */
|
/* USER CODE END SDIO_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -401,7 +401,7 @@ static void MX_USART1_UART_Init(void)
|
|||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN USART1_Init 2 */
|
/* USER CODE BEGIN USART1_Init 2 */
|
||||||
DEBUG_PRINT("USART1 initialized!\r\n");
|
DEBUG_PRINT("[L] USART1 initialized\r\n");
|
||||||
/* USER CODE END USART1_Init 2 */
|
/* USER CODE END USART1_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -427,7 +427,7 @@ static void MX_DMA_Init(void)
|
|||||||
HAL_NVIC_EnableIRQ(DMA2_Stream7_IRQn);
|
HAL_NVIC_EnableIRQ(DMA2_Stream7_IRQn);
|
||||||
|
|
||||||
/* USER CODE BEGIN MX_DMA_Init 1 */
|
/* USER CODE BEGIN MX_DMA_Init 1 */
|
||||||
DEBUG_PRINT("DMA initialized!\r\n");
|
DEBUG_PRINT("[L] DMA initialized\r\n");
|
||||||
/* USER CODE END MX_DMA_Init 1 */
|
/* USER CODE END MX_DMA_Init 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ static void MX_GPIO_Init(void)
|
|||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||||
DEBUG_PRINT("GPIO initialized!\r\n");
|
DEBUG_PRINT("[L] GPIO initialized\r\n");
|
||||||
/* USER CODE END MX_GPIO_Init_2 */
|
/* USER CODE END MX_GPIO_Init_2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,7 +532,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||||||
*/
|
*/
|
||||||
void Error_Handler(void)
|
void Error_Handler(void)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("ERROR: entering error handler\r\n");
|
DEBUG_PRINT("[E] Entering error handler\r\n");
|
||||||
|
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
/* User can add his own implementation to report the HAL error return state */
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
|
|||||||
Reference in New Issue
Block a user