Ok im receiving all the bytes correctly, but how i can concatenate this 4 bytes in a float variable?
I tried in the traditional mode ( variable << 8 , etc, etc), but i can't, well arduino don't let me
I think there's a couple of ways you could approach this...
The first is to use a data type known as union
, which I think would work something a little like this (type-as-I-think,-probably-won't-run-code :-)):
So, you'd fill the byte array using the bytes you get (e.g. foo.asBytes = 0x00
) and then read the value as float (e.g. foo.asFloat
)--however, this requires the format of the float to be the same as what the computer sends.
Alternatively you could try casting (a pointer?) to the float as a byte array and accessing the bytes individually.
I'm a little hazy on the exact details and it's possible the actual result may be "undefined" in certain situations, but hopefully it's a pointer in some direction... :-)