Help, about getting data from binary serial output

I want to do an experiment using two arduino that communicating via serial. Here is the setup: One arduino is hooked up to a 9DOF sensor stick,and I have already converted the sensor output to yaw pitch roll data(in degrees), then I convert these data to binary and transfer them to another arduino using serial write function. here is part of the code:

float ypr[3];
ypr[0] = TO_DEG(yaw);
ypr[1] = TO_DEG(pitch);
ypr[2] = TO_DEG(roll);
Serial.write((byte*) ypr, 12); // No new-line

this part of the code is working, I can see a bunch of unrecognized symbol in serial terminal, the problem is I don't know how to convert these binary data back to yaw pitch roll data on the other end. Any ideas?

Why do you need to send it as binary? On the other end it is trying to display the char() equivalent and so is not snowing what you want
try and keep it simple and forget the binary conversion altogether just one value after another
and make sure in terminal that you are set at the proper baudrate as selected in serial.begin()

winner10920:
Why do you need to send it as binary?

because I think binary is more efficient than ASCII, in the end these sensor data will be used to control three servos, and I want them to have real time performance, or at least keep the delay to minimum.

It is being sent in binary. That's the only thing that computers use (well, except for some of the odd tri-state stuff), and everything else is just an interpretation of binary. The serial monitor is interpreting it as best it can, to display it. The receiving end will get what you sent it, in the same form that you sent it.

You can use a union on the receiving end:

union
{
   float f;
   byte b[4];
} u;

Read 4 bytes into u.b[0] to u.b[3], then u.f is the float that was sent.

Thanks!! Union works! I also found the solution in java for processing:

float readFloat(Serial s) {
return Float.intBitsToFloat(s.read() + (s.read() << 8) + (s.read() << 16) + (s.read() << 24));
}

while (serial.available() >= 12) {
yaw = readFloat(serial);
pitch = readFloat(serial);
roll = readFloat(serial);
}