|
|
@ -418,6 +418,34 @@ static int l_lwip(lua_State *L) |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static int l_sendto(lua_State *L) |
|
|
|
|
|
{ |
|
|
|
|
|
int MsgCenter_SendTo(const char *pszDstName, uint32_t uiMsgID, const void *pData, uint32_t uiDataLen); |
|
|
|
|
|
const char *pszDstName = luaL_checkstring(L, 1); |
|
|
|
|
|
uint32_t uiMsgID = (uint32_t)luaL_checkinteger(L, 2); |
|
|
|
|
|
const void *pData = NULL; |
|
|
|
|
|
uint32_t uiDataLen = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (lua_istable(L, 3)) |
|
|
|
|
|
{ |
|
|
|
|
|
uiDataLen = (uint32_t)lua_rawlen(L, 3); |
|
|
|
|
|
if (uiDataLen > 32) |
|
|
|
|
|
return luaL_error(L, "data too long (max 32)"); |
|
|
|
|
|
static uint8_t buf[32]; |
|
|
|
|
|
for (uint32_t i = 0; i < uiDataLen; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
lua_rawgeti(L, 3, i + 1); |
|
|
|
|
|
buf[i] = (uint8_t)luaL_checkinteger(L, -1); |
|
|
|
|
|
lua_pop(L, 1); |
|
|
|
|
|
} |
|
|
|
|
|
pData = buf; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int ret = MsgCenter_SendTo(pszDstName, uiMsgID, pData, uiDataLen); |
|
|
|
|
|
lua_pushinteger(L, ret); |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#ifdef USE_ONCHIP_FLASH |
|
|
#ifdef USE_ONCHIP_FLASH |
|
|
|
|
|
|
|
|
#define LUA_START_ADDR 0x08020000UL |
|
|
#define LUA_START_ADDR 0x08020000UL |
|
|
@ -731,6 +759,10 @@ int luaopen_stm32(lua_State *L) |
|
|
lua_pushcfunction(L, l_lwip); |
|
|
lua_pushcfunction(L, l_lwip); |
|
|
lua_setglobal(L, "lwip"); // lwip = l_lwip
|
|
|
lua_setglobal(L, "lwip"); // lwip = l_lwip
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
lua_pushcfunction(L, l_sendto); |
|
|
|
|
|
lua_setglobal(L, "sendto"); // sendto = l_sendto
|
|
|
|
|
|
|
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|