英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论