Problem displaying messages in serial port /dev/ttyACM0

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

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.

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

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

  1. 静态初始化 USART2_UART 函数如下:
  2. UART_HandleTypeDef huart2;
  3. /* 用户代码开始 USART2_Init 0 */
  4. /* 用户代码结束 USART2_Init 0 */
  5. /* 用户代码开始 USART2_Init 1 */
  6. /* 用户代码结束 USART2_Init 1 */
  7. huart2.Instance = USART2;
  8. huart2.Init.BaudRate = 38400;
  9. huart2.Init.WordLength = UART_WORDLENGTH_8B;
  10. huart2.Init.StopBits = UART_STOPBITS_1;
  11. huart2.Init.Parity = UART_PARITY_NONE;
  12. huart2.Init.Mode = UART_MODE_TX_RX;
  13. huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  14. huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  15. huart2.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED;
  16. huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  17. HAL_UART_Init(&huart2);
  18. /* 用户代码开始 USART2_Init 2 */
  19. /* 用户代码结束 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.

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

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.

  1. Connecting to /dev/ttyACM0, speed 38400
  2. Escape character: Ctrl-\ (ASCII 28, FS): enabled
  3. Type the escape character followed by C to get back,
  4. 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.

  1. static void MX_USART2_UART_Init(void)
  2. {
  3. UART_HandleTypeDef huart2;
  4. /* USER CODE BEGIN USART2_Init 0 */
  5. /* USER CODE END USART2_Init 0 */
  6. /* USER CODE BEGIN USART2_Init 1 */
  7. /* USER CODE END USART2_Init 1 */
  8. huart2.Instance = USART2;
  9. huart2.Init.BaudRate = 38400;
  10. huart2.Init.WordLength = UART_WORDLENGTH_8B;
  11. huart2.Init.StopBits = UART_STOPBITS_1;
  12. huart2.Init.Parity = UART_PARITY_NONE;
  13. huart2.Init.Mode = UART_MODE_TX_RX;
  14. huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  15. huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  16. huart2.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED;
  17. huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  18. HAL_UART_Init(&huart2);
  19. /* USER CODE BEGIN USART2_Init 2 */
  20. /* USER CODE END USART2_Init 2 */
  21. }

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.

  1. void printWelcomeMessage(void) {
  2. HAL_UART_Transmit(&huart2, (uint8_t*)WELCOME_MSG, strlen(WELCOME_MSG), HAL_MAX_DELAY);
  3. HAL_UART_Transmit(&huart2, (uint8_t*)MAIN_MENU, strlen(MAIN_MENU), HAL_MAX_DELAY);
  4. }

答案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:

确定