X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/5b760b6cac721c6abd036c0689e713b5a7c700c5..f057bddb70733c45eb6110b48df944d01a4be864:/client/scripting.c diff --git a/client/scripting.c b/client/scripting.c index f9f4999d..331a8877 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -40,10 +40,23 @@ static int l_SendCommand(lua_State *L){ ==> A 544 byte buffer will do. **/ //Pop cmd - UsbCommand *c = (UsbCommand *)lua_touserdata(L, 1); - luaL_argcheck(L, c != NULL, 1, "'UsbCommand' expected"); - SendCommand(c); + size_t size; + const char *data = luaL_checklstring(L, 1, &size); + if(size != sizeof(UsbCommand)) + { + printf("Got data size %d, expected %d" , (int) size,(int) sizeof(UsbCommand)); + lua_pushstring(L,"Wrong data size"); + return 1; + } + +// UsbCommand c = (*data); + SendCommand(data); return 0; + //UsbCommand *c = (UsbCommand *)lua_touserdata(L, 1); + //luaL_argcheck(L, c != NULL, 1, "'UsbCommand' expected"); + + //SendCommand(c); + //return 0; } /** * @brief The following params expected: @@ -59,7 +72,7 @@ static int l_WaitForResponseTimeout(lua_State *L){ printf("in l_WaitForResponseTimeout, got cmd 0x%0x\n",(int) cmd); //UsbCommand response; - //We allocate the usbcommand as userdata on the Lua-stack + //We allocate the usbcommand as userdata on the Lua-stack size_t nbytes = sizeof(UsbCommand); UsbCommand *response = (UsbCommand *)lua_newuserdata(L, nbytes); @@ -93,7 +106,7 @@ static int l_WaitForResponseTimeout(lua_State *L){ static int l_nonce2key(lua_State *L){ return CmdHF14AMfRdSc(luaL_checkstring(L, 1));} static int l_PrintAndLog(lua_State *L){ return CmdHF14AMfDump(luaL_checkstring(L, 1));} -void set_pm3_libraries(lua_State *L) +int set_pm3_libraries(lua_State *L) { static const luaL_Reg libs[] = { {"SendCommand", l_SendCommand},