OSC receive float problem

20 Apr 2011

I am sending osc messages through wifi to a wifly module which then sends the data over uart to the mbed serial port (p9 and p10). The mbed receives the address but not the float value. The messages come through as 47 49 0 0 44 102 0 0 63 128. i have converted the ascii characters where i get '/1(null)(null),f(null)(null)?ç' where '/1' is the address, ',f' its accepting receiving floats then '?ç' this is a toggle switch on touchOsc for iphone. if the toggle is turned off then just '/1(null)(null),f(null)(null)'.

I have been using .getc(). any suggestions?

Thanks

20 Apr 2011

Bear in mind that the float value is being sent as four consecutive bytes. They must be reassembled into a floating point representation.

A snippet that does this:

union {
    float f1;
    char b[4];
} testunion;

// Assemble the test data
    testunion.b[0] = 0;     // The first char returned in the osc floating point string
    testunion.b[1] = 0;
    testunion.b[2] = 63;
    testunion.b[3] = 128;   // The last char returned in the osc floating point string
// Now print it as a "float"    
    printf("Float value = %E\r\n", testunion.f1);

This prints "Float value = -0.000000E+00". (Actually, it's -5.7856363e-39, but the compiler seems to round off!)

You will need to check whether the iPhone sends the MSB or LSB first. Also, make sure that none of the intervening links are altering the ASCII data as it passes through...