MP70 - string.unpack() problem

Hello All,

I am using MP70 gateway in my project. Applications are built using Lua scripting.
There is some problem with the “string.unpack()” function.

I have a sample program,

local myStr = string.char(0x31)
myStr = myStr … string.char(0x32)
myStr = myStr … string.char(0x33)
myStr = myStr … string.char(0x34)

I expect the following output,
875770417 5
(The above output is seen in the online lua interpreter)

But the MP70 throws an error as follows,
/bin/lua: main.lua:29: bad argument #1 to ‘unpack’ (bad code `1’)
stack traceback:
[C]: in function ‘unpack’
main.lua:29: in function ‘main’
main.lua:48: in main chunk
[C]: ?

Could anyone please help me out to resolve this issue?

Hi @c-nv

You need to require “pack” library for for packing and unpacking binary data.
require “pack”
local _,mystring,myfloat = string.unpack(bindata, “zf”)

Please refer to this link for more details

Can you share your AAF application (main.lua file) and Firmware version MP70 so I can give it a try?

Hi Donald,

Thanks a lot.
Its working after adding “pack” library.