First off, the transmitted data array 'command' has a 0x00 as it's second byte. The is the string terminator character. The only thing that will be sent is the first character in the array, 0xF2. If you want to transmit binary data you need to send it using putc.
You would need to use scanf("%s", command).
scanf(command) is returning 0 meaning that it found zero items that matched. Likely because command is defaulting to all zeros, meaning it is an empty string and therefore it has no items to search for.
scanf("%s", command) isn't returning because it is (I think) still looking for a carriage return which isn't being sent.
scanf also isn't appropriate for binary data.
You need to set up a loop using a timeout and and checking for data on the incoming serial line using micro.available() (I think that's right, I might be thinking of some other system).
As a test try changing in the sending mbed
from:
const char command[9]={0xF2, 0x00, 0x09, 0xff, 0x22, 0x00, 0x05, 0x79, 0x6F};
to:
const char command[] = "ABCD\r";
Hello! I'm trying to send a string from one mbed to another using the Serial functions printf and scanf and it doesn´t works. The code I have on the mbed who sends is the next:
And in the mbed who receives:
After executing the scanf works but it receives all 0 and returns a 0 too. I use the USBTX and USBRX to see in the Terminal what is happening. I tried too using "%s" before the string (micro.scanf("%s", command)) but in this way, I don´t receive anything. The scanf doesn´t work. I also realized that the printf and the scanf returns an integer, but I have no idea what it means (I didn't find information anywhere)
Does anybody what is wrong in my code?
Thank you so much!!!!
María.