Lua-interactive failure

I’m using Lua-interactive to communicate with a Fastrack Supreme. When I
try to list all the SMSes with at+cmgl the setup crashes almost every time:
once in about 8 to 10 tries all the SMSes are listed correctly. There
are 18 very short SMSes (the messages are ‘m01’, ‘m02’, … ‘m18’).
Here are the commands of a newly started session.

Lua interactive shell
$ =at(‘at+cpin=1234’);
= { “\r\nOK” }
$ =at(‘at+cmgl=“REC READ”’)

A few seconds after entering the at+cmgl command the following three error
dialogs pop up:

Link to q26-gsm failed. Reconnecting …

PuTTY: Connection closed by remote host.

PuTTY Fatal Error: Software caused connection abort.

q26-gsm is the name of the shortcut that establishes the network
connection. After this the network reconnects and I must restart PuTTY.
It makes no difference if the output of the +cmgl command is displayed or
not.

If I read the messages one at a time with the following loop it all works
fine.

for k = 1,25 do
p(at(string.format(‘at+cmgr=%d’, k)))
end

Any idea what is actually failing or why at+cmgl fails?

Setup info:
CPU: FSU005 (Fastrack Supreme)
Firmware: R73_00gg.FSU005
OS: 6.20
M2M Studio 1.0.2.200903311200

Thanks
chris

Hi,

the most likely reason why you have this issue is Open AT’s watchdog: if the user application remains busy for too long, the whole CPU reset as a “safety” measure. Newer versions of the Lua VM keep the watchdog quiet as long as the VM isn’t stuck, so you don’t have to take care of the watchdog anymore in Lua.

I’ll put the latest version online ASAP (or you can get them by svn from https://svn.anyware-tech.com/wavecom/openat-lua/oatlua/), please tell me whether it fixes your issue.

I tried to compile the new oatlua-1.40 library and lua_interactive program under OS-6.20.4, Firmware 7.3 and WIP 5.10.2020 using wmmake. (I created the projects with the Project Wizard and then switched to the commandline functions.) Compiling the library was okay; there were some warning messages about incompatible pointer types and discarded pointer qualifiers but things should work okay.

For lua_interactive I’ve added the following wmnew options to use the new oatlua-1.40 library:

-libname gcc_oatlua-140.lib -extlib d:/openat-tests/oatlua-1.40/gcc/out -inc d:/openat-tests/oatlua-1.40/itf

and added plugin WIP. When I compile lua_interactive using wmmake I get the following errors:

… Compiling appli.c

In file included from appli.c:32:
mempool.h:11: error: variable-size type declared outside of any function
appli.c: In function ‘adl_main’:
appli.c:129: warning: passing argument 1 of ‘luaW_memPoolInit’ from incompatible pointer type
appli.c:129: error: too many arguments to function ‘luaW_memPoolInit’
make.exe: *** [appli.o] Error 1
Done.
[wmmake error #1] Build error.

If I move the line

#include “mempool.h”

into adl_main() the first error (mempool.h:11: error: …) goes away but then there is another error (mempool.h:35: error: …, see below)

… Compiling appli.c

In file included from appli.c:117:
mempool.h: In function ‘adl_main’:
mempool.h:35: error: invalid storage class for function ‘evh_openat_error’
appli.c:130: warning: passing argument 1 of ‘luaW_memPoolInit’ from incompatible pointer type
appli.c:130: error: too many arguments to function ‘luaW_memPoolInit’
c:\bin\openat-2.20\IDE\MINGW\3.8.0.1\bin\make.exe: *** [appli.o] Error 1
Done.
[wmmake error #1] Build error.

The biggest problem appears to be the definition of luaW_memPoolInit() that has changed. The old version had multiple arguments passed to this function but the new version takes a luaW_memPoolHeader and I can’t figure out how to use this struct. I’m also not sure if this will fix the problem because precompiled library functions may depend on the old function definition.

I’ve also tried to use an older version of wiplua.h (some of the functions are defined there) but this was not succesful.

Any ideas how to fix the problem?

BTW, what happened to wmnew and wmmake in M2M studio? Is it still possible to work on the commandline?

Thanks
chris

I forgot to mention that the memory initialization process has been changed: you don’t need mempool.h anymore, adn the prototype for luaW_mempoolInit() has changed as well. A new version of the sample can be found here: http://people.anyware-tech.com/~fabien/lua_interactive.c

Fabien,
Thanks a lot for the help, it is working fine now. To make sure the watchdog is not triggered I created a loop and retrieved all the SMSes several times, the total time being more than 8 seconds, and it worked perfectly.
Thanks again
chris

If I use sms.list() in the new version of oatlua I get an error about
at.parse being a nil value.

$ =at(‘at+cpin=1234’)
= { “\r\nOK” }
$ m = sms.list(“REC READ”)
run(): error: src_lua\sms_lua.lua:25: attempt to call field ‘parse’ (a nil value)
stack traceback:
src_lua\sms_lua.lua:25: in function ‘list’
shell:1: in function ‘code’
src_lua/shell.lua:82: in function <src_lua/shell.lua:80>

In older versions of oatlua at.parse() used to be in src_lua/at.lua but I
can’t find it anywhere in the latest version. If I comment out
the call at.parse(x) in sms.list() then processing fails because x is not in
the correct format:

$ m = sms.list(“REC READ”)
run(): error: shell:11: table index is nil
stack traceback:
shell:11: in function ‘list’
shell:1: in function ‘code’
src_lua/shell.lua:82: in function <src_lua/shell.lua:80>

For now I just plugged in an older version of at.parse() to keep going but it would probably better to fix sms.list() in the long run.
chris

at.parse() proved to be less practical, and much more resource-hungry than a simple regular expression, and as such should be considered deprecated. oatlua being open source, the correct way to override deprecation is to copy/paste the old definition in your program, which is just what you did.

If you’re using the sample given with oatlua to parse SMS, here’s a regexp-based version of the relevant loop (warning, untested code):

local lines = at'at+cmgl="ALL"'
   for i=1, #lines-4, 3 do
      local sms = { text = lines[i+2] }
      sms.n, sms.phone, sms.date = lines[i+1] :match '+CMGL: (%d+),".-","(.-)",.-,"(.-)"'
      sms_table[sms.n] = sms
   end

The money quote is the call to method :match(); a description of Lua regular expressions can be found in the official Lua manual. To tune your regexps, I suggest to test them interactively on the telnet shell; spending an hour or so learning to toy with them will pay off in no time if you do any kind of parsing, of AT commands results or any other non-binary protocol.

Fabien
Thanks for the help. I forgot to respond to ypur post after I read it yesterday. I’m familiar for regular expressions as used in awk/sed, etc as well as with Lua’s pattern matching. And you are right, the responses can easily be parsed with these.

Thanks
chris