How start with LUA scripting


Hi All,

I am very much new to this LUA scripting. I have been using open AT for quiet some time now.
I have the lateset OASiS 2.10, can any of u please tell me how do i start with this LUA scripting?
i read the document but fail to understand the usage of the “lua_interactive” sample available in LUA.

Is this LUA scripting tougher than using Open AT? :question:



what part didn’t you understand?

The way to get started is to:

  • first, of course, downlowd lua_interactive on the WMP devkit!

  • set up and lauch an IP connection between the PC and the module, over the UART/Com ports link (UART1 by default). This part is a bit painful, as windows has a cumbersome support for PPP over serial cables. Just follow carefully the indications in the appropriate manual appendix.

  • start a telnet, with putty.exe, to the WMP. You’ve now got a shell on the WMP, on which you can enter instructions and/or programs interactively, and with which you can monitor the system.

  • you will want to write .lua programs on your PC, upload them from your PC to your WMP, and run them on the WMP. To du that you need a web server on your PC’s port 8765, which will serve your *.lua source files. the WMP will use this web server to retrieve the source files to run automatically. I think there is the nanohttpd basic web server in the distribution, probably in c:\openat\plugins\lua\samples\scripts. There must be a “runserver.bat” batch file there, just double-click on it. Now, supposing that you have a “at_over_tcp.lua” script in the directory and you want to run it on the WMP, just type " l ‘at_over_tcp’ " in the telnet shell: the WMP will download the script (using the web server), compile it, and run it for you.

This interactive mode, in which you can immediatly load, modify, reload, debug etc. your programs in a matter of seconds is extremely practical for faster development. Once you’re happy with it, there’s an appendix in the doc describing how to compile your lua program into a regular static .dwl Open AT application, that you can deploy on your final product, and lwhich lets you benefit from all Open AT specific services such a IDS. You can come back and ask questions about this process once your application will be correctly running in interactive mode.


Re: How start with LUA scripting
Postby fft » Thu Nov 06, 2008 4:56 pm
what part didn’t you understand?

Why a lot of the standard examples just do not work including this
lua_interactive thing…

Fastrack supreme : 20
Development kit R73
Windows XP(SP3)
SuSE linux 11

After a lot of hacking, I DID manage to get a C example application running using
visual C+6.0 as the development system - this method ALMOST works…
The code uses the RTC,SMS and GPIO to sense the state of GPIO 21&25
and send SMS messages. Quite a bit of the Wavecom GPIO stuff appears not to
work, but hacked around that. Not very enouraging though…

The way to get started is to:

  • first, of course, downlowd lua_interactive on the WMP devkit!

On the face of it, seems quite reasonable this…

If one uses the wavecom ‘wizard’ as instructed to build lua_interactive example
for 1MB+ and uploads it on to a fastrack supreme : 20 (R73) then
nothing happens on giving AT+WOPEN=1.
The wavecom still responds to terminal commands, so the uploaded
application has just not run at all…

If the build is done for 256K instead, then one gets

�����[LUAW][MEM] reserving 101 KB for Lua mempools
[LUAW][MEM] Reserving 2600 bytes out of 104160 for 8-blocks pool
[LUAW][MEM] Reserving 5160 bytes out of 101560 for 16-blocks pool
[LUAW][MEM] Reserving 19320 bytes out of 96400 for 20-blocks pool
[LUAW][MEM] Reserving 23160 bytes out of 77080 for 24-blocks pool
[LUAW][MEM] Reserving 9000 bytes out of 53920 for 28-blocks pool
[LUAW][MEM] Reserving 20560 bytes out of 44920 for 32-blocks pool
[LUAW][MEM] Reserving 24360 bytes out of 24360 for 76-blocks pool
[LUAW][MEM] memory pools ready
[LUAW] load library base…uses 3246 bytes
[LUAW] load library table…uses 756 bytes
[LUAW] load library string…uses 1030 bytes
[LUAW] load library package…uses 1753 bytes
[LUAW] load library debug…uses 1396 bytes
[LUAW] load library strict…uses 2074 bytes
[LUAW] load library scheduling…uses 11945 bytes
[LUAW] load library timer…uses 569 bytes
[LUAW] load library options…uses 1376 bytes
[LUAW] load library channels…uses 13415 bytes
[LUAW] load library bearers…uses 5249 bytes
[LUAW] load library tcp…uses 4253 bytes
[LUAW] load library flash_read…uses 2486 bytes
[LUAW] load library flash_write…uses 6110 bytes
[LUAW] load library rawflash…uses 1273 bytes
[LUAW] load library shell…uses 13385 bytes
[LUAW] load library misc…uses 979 bytes
[LUAW] load library bootload…uses 6570 bytes
[LUAW] load library ad…uses 2320 bytes
[LUAW] load library at…uses 9822 bytes
[LUAW] load library mem…uses 1344 bytes
[LUAW] load library print…uses 3296 bytes
[LUAW] load library sms…uses 45 bytes
[LUAW] RUN [thread 0x180ed22c]
[LUAW] Starting telnet server
[WIP] new TCPSERVER 0x180eef0c
[UART1]: startsrv: -> CONNECTING

After which, the serial terminal connection is gone.
The first time this happened, I wired the boot pin on the connecter to ground
and used the DWLWIN application to dump the standard firmware back in
thinking that something must have gone wrong with the build/install.

After repeating everything and getting the same result again, I then assumed
that UART1 had been ‘grabbed’…

I tried the (documented) procedure for PPP connection from windows (XP:SP3 )-but
without much confidence. Justified. Failed to connect.

Used pppd under linux to try and get a connect that way.
After some tinkering, managed to get the connect attempt past
the PAP challenge

[This is (presumably) one of the reasons that the windows connect is
failing, but I don’t know where all that stuff is hidden on windows,
so probably easier to use linux…]

but now unable to stop the wavecom from
disconnecting. I does not appear to behave like a normal
dial-up modem as there seems to be no ‘chat’ dialogue.

set up and lauch an IP connection between the PC and the module, over the UART/Com ports link (UART1 by default).
This part is a bit painful, as windows has a cumbersome support for PPP over serial cables.
Dead right… I could put it stronger than that.

Just follow carefully the indications in the appropriate manual appendix.
Naahh- something seriously wrong here. At a guess, being blocked by some kind
of security measure, but can’t see what.

Here is the pppd stuff that (appears to) get as far as the dial attempt…
Quite a bit of this is guesswork - but no choice really without any
clear information to go on.

rjp@pctop:~> sudo bin/ setup

wavecom pppd added to /etc/ppp/peers/wavecom_linux
/dev/ttyS0 115200 crtscts noauth debug nodeflate
connect ‘/usr/sbin/chat -v -f /etc/ppp/wavecom_chat’

wavecom chat added to /etc/ppp/wavecom_chat
“name:” “^Uwipuser”
“word:” “\q123456”
“ispts” “\q^Uppp”

rjp@pctop:~> sudo bin/ start
Starting pppd …
Connect script failed
pppd code: 8

rjp@pctop:~> tail /var/log/messages
Mar 23 10:55:51 pctop sudo: rjp : TTY=pts/1 ; PWD=/home/rjp ; USER=root ; COMMAND=bin/ setup
Mar 23 10:55:59 pctop sudo: rjp : TTY=pts/1 ; PWD=/home/rjp ; USER=root ; COMMAND=bin/ start
Mar 23 10:55:59 pctop pppd[4566]: pppd 2.4.4 started by rjp, uid 0
Mar 23 10:55:59 pctop chat[4567]: abort on (ERROR)
Mar 23 10:55:59 pctop chat[4567]: abort on (ALARM)
Mar 23 10:55:59 pctop chat[4567]: expect (name:)
Mar 23 10:56:44 pctop chat[4567]: alarm
Mar 23 10:56:44 pctop chat[4567]: Failed
Mar 23 10:56:44 pctop pppd[4566]: Connect script failed
Mar 23 10:56:44 pctop pppd[4566]: Exit.

Frig to ‘get past’ PAP challenge.

rjp@pctop:~> sudo cat /etc/ppp/pap-secrets

Secrets for authentication using PAP

client server secret IP addresses

localhost * 123456

That’s about it for now.
Any ideas anyone? Judging by the rest of the stuff in this forum, someone HAS
managed to get LUA to connect/run. Question is how did they do it?



I’m afraid that I’m not knowledgeable about UART + PPP to help you a lot. The PPP bearer handling in Lua is delegated to WIP, Open AT’s IP stack. Have you tried and managed to run WIP samples over PPP? The choice of the bearer is done by setting up with a #define at the beginning of appli.c if I remember correctly. Tell me if you manage to get IP samples to work over PPP; if so, then you really have a Lua-specific issue, but it’s not the most likely explanation.

Maybe IP PPP samples come with some troubleshooting help? I’m not sure, but it’s certainly worth checking. Also, since they are fully mature products, you can get help from your distributor or from Wavecom to get them running. Unfortunately, and as you have noticed, PPP comes with very few ways of diagnosing problems, at leqast under Windows, and it seems also under Linux…

Notice that you can open a shell over a raw serial line, but that will be of little help, as you won’t be able to easily hot-swap your programs through FTP/HTTP (run AT command at+lua=“‘UART1’)”, changing the UART name if applicable; enable local characters echo and automatic translation of into “\r\n”).

Lua interactive shell
$ print 'hello world'
hello world
$ _

Note that we hope to someday get, through the “open USB” API, the devkit to present itself as a simplified ethernet-USB adapter. This would make Open AT Lua a plug-n-play experience, which it definitely isn’t over PPP! As for your questions about Open AT Lua usage, it’s most frequent customer use is to embed an AJAX web server, e.g. in set-top-boxes. Of source, such architectures tend to have Ethernet support, which greatly simplifies IP-based development.