That's normal behavior.
Starting from 4.7.0 a 'buffer' is not a string, but a table with special metamethods, that behaves like a object/class.
The value you get in return is a 'buffer' object (you can check by reading its metatable, or with the dedicated function
isbuffer()
):
Code: Select all
> buf = sim.packFloatTable({0.1, 0.2, 0.3})
> type(buf) -- this type indication is not very specific in Lua
'table'
> isbuffer(buf) -- looks into the table's metatable
true
> #buf -- length op is overridden (and many others)
12
> buf[1] -- gets the first byte as string
> string.byte(buf, 1) -- get the first byte value (8 bit int)
205
> isbuffer(buf .. buf)
true
it implements most metamethods of string, so you don't have to use
table.concat
, but simply
use it as if it was a string (e.g. pass it around as it is, concatenate it using the
..
operator, use
tostring(buf)
to convert it to a string if needed (probably not), etc...)
e.g.:
Code: Select all
@@
> printBytes(sim.packFloatTable({0.1, 0.2, 0.3}))
cd cc cc 3d cd cc 4c 3e 9a 99 99 3e
More info on the manual page:
Buffers.