cancel
Showing results for 
Search instead for 
Did you mean: 

I concanate two strings using strcat. Then I transmit that strings through uart2 but when I check in the putty terminal the string is showing half of it. It is not showing full string on the putty terminal. Any idea about this?

cjaya.1
Associate II
 
16 REPLIES 16
AScha.3
Chief III

try:

char buffer[30];

.... &

 HAL_UART_Transmit(UART_HandleType ....) // Send an amount of data in blocking mode.

If you feel a post has answered your question, please click "Accept as Solution".

For strcat() to work properly buffer[] needs to have a leading NUL character to indicate it is empty. Typically you'd avoid that with a strcpy() for the first string, and strcat()

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

thank you for the replies. I even initialized the char buffer[30] = {0} and then use strncat(). Also used HAL_UART_Transmit() but it just one character not transmitting. It transmitting most of it just misses one character from the string. Its transmitting "setfrequency 10" instead of "100". Dont know why?. Any suggestions?

> transmitting most of it just misses one character from the string.

Do you use UART (TTL) to USB adapter?

no I am not using UART(TTL) to USB adapter

Is your buffer array defined within a function or is it global? If it's in a function and you pass the address of the buffer to HAL_UART_Transmit_IT() then leave that function, the buffer array is no longer static. So any other resources can use that memory location and overwrite your buffer data.

Again, you've pasted snippets of your code but we don't know if the buffer array is inside or outside of a function that uses HAL_UART_Transmit_IT()? We don't know if you're in a loop? Paste your code with a little more information.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

buffer array is defined within a function and it is not global. Does this buffer needs to be defined static and global.