Skip to main content
SayanSeth
Associate II
February 10, 2020
Solved

Receiving wrong Data in UART in Nucleo Board.

  • February 10, 2020
  • 4 replies
  • 1620 views

Hi, I was testing UART communication using F446RE Nucleo Board. I was sending data to COM port by a python program running in PC and trying the receive to same data.

ser.write(serial.to_bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))
print(ser.read(15))
memset(rx_buffer,0, 15);
		HAL_UART_Receive(&huart2,rx_buffer, 15, HAL_MAX_DELAY);
		HAL_UART_Transmit(&huart2,rx_buffer, 15, HAL_MAX_DELAY);

I'm getting below data.

b'\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'

I tried same code in two different board. both are giving same result.

This topic has been closed for replies.
Best answer by berendi

Because you send these bytes, and the STM32 sends them back.

The python interpreter then decided to display the sequence of bytes using some escape sequences. The python documentation on data types and the print function might document the exact reason why 9 is turned into '\t', 10 into '\n', and 11 into '\x0b' etc.

4 replies

berendi
Principal
February 10, 2020

And what's the problem with that? The STM32 sends the same sequence back, you might want to convert the byte sequence to an array of bytes on the python side.

SayanSeth
SayanSethAuthor
Associate II
February 10, 2020

Why the below parts are coming?

\t\n\x0b\x0c\r\

berendi
berendiBest answer
Principal
February 10, 2020

Because you send these bytes, and the STM32 sends them back.

The python interpreter then decided to display the sequence of bytes using some escape sequences. The python documentation on data types and the print function might document the exact reason why 9 is turned into '\t', 10 into '\n', and 11 into '\x0b' etc.