Problem displaying messages in serial port /dev/ttyACM0

huangapple go评论59阅读模式
英文:

Problem displaying messages in serial port /dev/ttyACM0

问题

I can connect to /dev/ttyACM0 through kermit, putty and python serial but could not be able to display the messages on the terminal. I am building a project using stm32f091rc nucleo board.

连接到 /dev/ttyACM0,速度 38400
转义字符:Ctrl-\ (ASCII 28, FS):已启用
输入转义字符,后跟 C 以返回,
或后跟 ? 以查看其他选项

I can see that the port is displayed in /dev folder but I am not sure if I am really connected to the port.

静态初始化 USART2_UART 函数如下:

UART_HandleTypeDef huart2;
/* 用户代码开始 USART2_Init 0 */

/* 用户代码结束 USART2_Init 0 */

/* 用户代码开始 USART2_Init 1 */

/* 用户代码结束 USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 38400;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
HAL_UART_Init(&huart2);

/* 用户代码开始 USART2_Init 2 */

/* 用户代码结束 USART2_Init 2 */

UART init functions parameters match with the configurations I have made through Putty and kermit.

About the program, I have a main function calling UART_Transmit function with the following codes.

void printWelcomeMessage(void) {
    HAL_UART_Transmit(&huart2, (uint8_t*)WELCOME_MSG, strlen(WELCOME_MSG), HAL_MAX_DELAY);
    HAL_UART_Transmit(&huart2, (uint8_t*)MAIN_MENU, strlen(MAIN_MENU), HAL_MAX_DELAY);
}
英文:

I can connect to /dev/ttyACM0 through kermit, putty and python serial but could not be able to display the messages on the terminal. I am building a project using stm32f091rc nucleo board.

Connecting to /dev/ttyACM0, speed 38400
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options

I can see that the port is displayed in /dev folder but I am not sure if I am really connected to the port.

static void MX_USART2_UART_Init(void)
{

	UART_HandleTypeDef huart2;
  /* USER CODE BEGIN USART2_Init 0 */

  /* USER CODE END USART2_Init 0 */

  /* USER CODE BEGIN USART2_Init 1 */

  /* USER CODE END USART2_Init 1 */
	huart2.Instance = USART2;
	huart2.Init.BaudRate = 38400;
	huart2.Init.WordLength = UART_WORDLENGTH_8B;
	huart2.Init.StopBits = UART_STOPBITS_1;
	huart2.Init.Parity = UART_PARITY_NONE;
	huart2.Init.Mode = UART_MODE_TX_RX;
	huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
	huart2.Init.OverSampling = UART_OVERSAMPLING_16;
	huart2.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED;
	huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
	HAL_UART_Init(&huart2);

	/* USER CODE BEGIN USART2_Init 2 */

  /* USER CODE END USART2_Init 2 */

}

UART init functions parameters match with the configurations I have made through Putty and kermit.

About the program, I have a main function calling UART_Transmit function with the following codes.

void printWelcomeMessage(void) {
        HAL_UART_Transmit(&huart2, (uint8_t*)WELCOME_MSG, strlen(WELCOME_MSG), HAL_MAX_DELAY);
        HAL_UART_Transmit(&huart2, (uint8_t*)MAIN_MENU, strlen(MAIN_MENU), HAL_MAX_DELAY);
}

答案1

得分: 0

I have solved the problem after deleting the UART_HandleTypedef struct initialization line.

英文:

I have solved the problem after deleting the UART_HandleTypedef struct initialization line.

huangapple
  • 本文由 发表于 2023年4月19日 15:44:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76051902.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定