i’m sorry i’m a very late asking these question… seems like i couldn’t compile my LuaSamples application. i wonder if my LuaSamples is the right one. because there is so many Samples in my folder. here is the source code of my LuaSamples.
#include "adl_global.h"
#include "wip.h"
#include "wiplua.h"
/* If defined, the shell wants a login/password authentication. */
// #define WANT_LOGIN_PASSWORD_SHELL_AUTH
/* If defined, the shell wants a password authentication (no login name). */
// #define WANT_PASSWORD_SHELL_AUTH
/* If none of the above is defined, there is no shell authentication. */
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
#if __OAT_API_VERSION__ >= 400
const u16 wm_apmCustomStackSize = 4096*2;
#else
u32 wm_apmCustomStack[1024];
const u16 wm_apmCustomStackSize = sizeof(wm_apmCustomStack);
#endif
/* Don't barf on edl_memGet() failures: */
static bool evh_openat_error(u16 errid, ascii *msg) {
if( ADL_ERR_MEM_GET == errid) return FALSE;
else return TRUE;
}
/* Go to emergency mode after 150Kb RAM have been spent: */
const int LUAW_MEM_ALARM_THRESHOLD = 150 * 1024;
/* Reserve RAM for memory pools: */
#define WITH_POOLS
#ifdef WITH_POOLS
#define K 5
u8 MEMPOOL[ LUAW_MEMPOOL_SIZE( 32*K, 8) + LUAW_MEMPOOL_SIZE( 32*K, 16) +
LUAW_MEMPOOL_SIZE( 96*K, 20) + LUAW_MEMPOOL_SIZE( 96*K, 24) +
LUAW_MEMPOOL_SIZE( 32*K, 28) + LUAW_MEMPOOL_SIZE( 64*K, 32) +
LUAW_MEMPOOL_SIZE( 32*K, 76) ];
#endif
//#include "lstate.h"
//static int getmainthread( lua_State *LL) {
// extern lua_State *L;
// setthvalue(LL, LL->top, L);
// LL->top++;
// return 1;
//}
/* What modules to load? */
static const luaL_Reg initializers[] = {
/* Lua standard libs */
{ "base", luaopen_base },
{ "table", luaopen_table },
{ "string", luaopen_string },
{ "package", luaopen_package },
{ "debug", luaopen_debug },
/* Turn undeclared global variables into errors. */
{ "strict", luaopen_strict },
/* Multitasking core (mandatory) */
{ "scheduling", luaopen_scheduling },
/* Timer events */
{ "timer", luaopen_timer },
/* WIP: */
{ "options", luaopen_options },
{ "channels", luaopen_channels },
{ "bearers", luaopen_bearers },
{ "tcp", luaopen_tcp },
/* Flash objects handling: */
{ "flash_read", luaopen_flash_read },
{ "flash_write", luaopen_flash_write },
{ "rawflash", luaopen_rawflash },
/* Misc stuff. */
{ "shell", luaopen_shell },
{ "misc", luaopen_misc },
{ "at", luaopen_at },
{ "mem", luaopen_mem },
{ "print", luaopen_print },
{ "sms", luaopen_sms },
{ NULL, NULL } };
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | x | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType ) {
int r;
adl_errSubscribe( evh_openat_error);
TRACE (( 1, "Embedded Application : Main" ));
/* Initialize the stack */
r = wip_netInitOpts(
WIP_NET_OPT_SOCK_MAX, 12,
WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1, /* WIP traces on UART1 */
WIP_NET_OPT_END);
#ifdef WITH_POOLS
/* Set up the memory pools: */
wip_debug( "[LUAW][MEM] reserving %iKB for lua optimized memory pools\n",
sizeof( MEMPOOL)/1024);
r = luaW_memPoolInit( MEMPOOL, sizeof( MEMPOOL),
32*K, 0, 8, 32*K, 0, 16,
96*K, 0, 20, 96*K, 0, 24,
32*K, 16, 28, 64*K, 20, 32,
32*K, 49, 76, 0);
if( OK == r) wip_debug( "[LUAW][MEM] memory pools ready\n");
else wip_debug( "\n *** Fscked-up memory pools! ***\n\n");
#endif
// Not compatible with older WIP versions:
// wip_logEvents = TRUE;
luaW_start( initializers); /* Start Lua engine */
luaW_atLuaCmdSubscribe(); /* Register AT command AT+LUA */
luaW_run( /* Start PPP server on UART2 */
"global ('LOCAL_ADDR', 'PEER_ADDR', 'PPP_UART', 'LOGIN', 'PASSWORD') "
"LOCAL_ADDR = LOCAL_ADDR or '192.168.1.4' "
"PEER_ADDR = PEER_ADDR or '192.168.1.5' "
"PPP_UART = PPP_UART or 'UART2' "
"LOGIN = LOGIN or 'wipuser' "
"PASSWORD = PASSWORD or '123456' "
#ifdef WANT_LOGIN_PASSWORD_SHELL_AUTH
"wip.shell.auth = { "
" method = 'basic', "
" users = { [LOGIN] = PASSWORD } } "
#elif defined(WANT_PASSWORD_SHELL_AUTH)
"wip.shell.auth = { method = 'basic', password=PASSWORD } "
#endif
"wip.shell.telnet_server(23) "
"wip.bearer_server (PPP_UART, { "
" auth_table = { [LOGIN]=PASSWORD }, "
" ip_addr = LOCAL_ADDR, "
" ip_dst_addr = PEER_ADDR })");
}
and i also wanted to ask about the PPP connection with the PC. i’m currently using a devKit for q2686 with 2 serial ports. i’m using UART1 as the PPP connection. but i don’t get the explanation in LUA tutorial about the UART2 function. would u mind explain it to me briefly?
and last, i get that before i could use the LUA scripting i should download the LUAsample into the DevKit first? am i making a mistake here? so using LUA is like using WIPSoft?
Thanx,
Edy