Shrink the logger
* Move _write function to the log.c * Change the way to setup the logger * Update the readme * Add terminal commands
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <errno.h>
|
||||
#include <sys/unistd.h>
|
||||
#include "log.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -431,24 +430,6 @@ static void MX_GPIO_Init(void)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
int _write(int file, char *data, int len) {
|
||||
HAL_StatusTypeDef status;
|
||||
|
||||
switch (file) {
|
||||
case STDOUT_FILENO:
|
||||
case STDERR_FILENO:
|
||||
status = HAL_UART_Transmit(&huart1, (uint8_t*)data, len, HAL_MAX_DELAY);
|
||||
if (status != HAL_OK) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user