cancel
Showing results for 
Search instead for 
Did you mean: 

UART2 Output Stripped - NUCLEO-F401RE

Ghomi.1
Associate

Working on a prototype and am using HAL_UART_Transmit to output to UART2. Upon output over UART2 the string seems to be truncated. Code below:

```

char stuff[] = "HELLO YOU FINE FELLOW";

HAL_UART_Transmit(&huart2,stuff,sizeof(stuff),1);

```

Output is HELLO YOU FINE FEL.

Any advice would be helpful.

4 REPLIES 4
Ghomi.1
Associate

Ask a noob question and voila I stumble across the answer. Strangely enough the answer was the timeout in HAL_UART_Transmit ?

Bob S
Principal

Not causing THAT problem, but also a "noob" mistake with the "size" parameter. Question: what is the difference between sizeof(stuff) and strlen(stuff)? And why is there a difference? Is it sending what you expect?

Use strlen() for strings otherwise you'll get the NUL terminator transmitted too. The timeout needs to provide for sufficient time to transmit all the bytes at the baud rate you're using.

at 9600 baud around millisecond a character.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

Actually I wonder why there is a notion of a timeout for a usart TX.... to generate posts ?