-->
Page 1 of 1

Calling LUA function from C, help!

PostPosted: Wed Jun 10, 2015 6:30 am
by hbouzas
I am re-compiling the NodeMCU LUA successfully as I am trying to package several LUA calls together and mix them with C API calls. Has anybody tried to call a NodeMCU LUA function like wifi.ap.getmac from C? Again, I am trying to mix C and LUA and the stuff compiles fine but it makes the module crash and go into a loop here is an example of the code I'm using:

void get_mac_add( lua_State* L)
{
lua_State* L;
lua_getglobal(L, "wifi.ap.getmac");
lua_pcall(L, 0, 1, 0);
const char * macadd = lua_tostring(L, -1);
INFO(macadd); // macro to print to UART
}

Any help will be much appreciated.
Thanks

Horacio.

Re: Calling LUA function from C, help!

PostPosted: Wed Jun 10, 2015 12:17 pm
by cal
Start by removing

Code: Select alllua_State* L;


I would expect that you get an exceptiion 28 or 29.

Cal