UART does not do what I want

Well, you declared buf to have 4 bytes. You tried to store 8 bytes into it and then only wrote the first four of them because sizeof(buf) is 4.

Pete