[CCC DEV] REAL32 to FFI
Adam Sampson
ats at offog.org
Mon Jun 28 23:22:40 BST 2010
Matt Jadud <jadudm at gmail.com> writes:
> Another question: REAL32s on the Arduino are, I assume, not going to
> pass through the FFI nicely. At least, I assume they aren't.
That's probably a safe assumption, but I've not tried it. What it
"ought" to do for types larger than the word size is what it does for
VAL INT64 arguments on a 32-bit platform: pass a pointer instead.
You never know, it might even work. ;-)
> Should I shift them into a pair of INT16s, pass them through, and
> reconstitute them on the other side?
Yes, retyping it into an array should work; something like:
(extern) PROC ffi.garble (VAL [2]INT16 value)
PROC garble (VAL REAL32 value)
VAL [2]INT16 ivalue RETYPES value:
ffi.garble (ivalue)
:
...
void _ffi_garble (word *w) {
float value = *((float *) w[1]);
...
}
(Did we have endianness problems in the past?)
--
Adam Sampson <ats at offog.org> <http://offog.org/>
More information about the developers
mailing list