Getting script download to work through FTP

Hello,

I am trying to download LUA file to the Fastrack Modem after install ftp server,PuTTY in my PC and load Lua interactive shell to the modem.
After type in the shell: “$ l ‘web.lua’” - I receive the following Error:

Lua interactive shell
$ l ‘web.lua’
run(): error: Can’t connect to FTP
stack traceback:
[C]: in function ‘ftp_client’
?: in function ‘ftp_client’
?: in function <?:58>
Done. Lua VM uses 61552 bytes.
$

Who can I fix it please advice???

another think I try to use the AT command ‘AT+LUA’ in the terminal and I receive ERROR Way?

please advice how can fix this problems and start to write in LUA

best regards
dz

What model of Fastrack Modem, precisely?

I’m not sure that Lua is compatible with the Fastrack M1306B - or earlier… :question:

I have Fastrack Supreme 10
And i Succed load LUA and run it
try some of the command like print,wip.tcp_client that are working
but i can not load file to it
please advice

@awneil: If he gets a telnet shell, then it is compatible :slight_smile:

@zamirdor: the FTP connection that’s in charge of downloading source code failed, without producing an FTP protocol error. The most likely reasons are:

  • either you don’t have full IP enabled, hence no FTP client (last time I checked it was a feature you had to pay for, if in doubt, check with your distributor or FAE);
  • or your FTP server on the PC isn’t set up properly (it must accept anonymous login).

Your FTP server must be able to produce connection logs. If you can’t find any, it probably means you don’t have full IP enabled. It is technically possible to replace the WIP FTP client with an implementation in Lua (there’s a sample in the wiki), but that’s not completely trivial and I can’t help you doing that. If you get traces of a connection attempt to your server (or even ethereal traces), please provide them.

The following command will cause a low level FTP connection and print every message sent by WIP FTP:

x=internal.ftp_client ('192.168.1.5', 'anonymous', 'some_dummy_password', 21, true); x:hook('*', function(...) print(...); return 'again'; end)

You should see either:

[channel FTP_CONTROL 0x18120f24 ready]        open

or:

[channel FTP_CONTROL 0x18120f24 broken]        error        <some error number>

Thanks for your help and replay

I try the code and this is the result I get:

$ x=internal.ftp_client(‘192.168.1.5’, ‘anonymous’, 'iewjdie@deij.com’, 21, true); x:hook(’*’, function(…) print(…); return ‘again’; end)
run(): error: shell:1: Can’t connect to FTP
stack traceback:
[C]: in function ‘ftp_client’
shell:1: in function ‘?’
?: in function <?:76>

If I understand right there is possible that I have some missing function in my modem like ftp client.
It possible to add the lib. or I need to buy it.
And if there any other way to download Lua file to the modem.

I try to connect to my FTP server from my PC local and I succeed to connect to the ftp and to see all files in root dir.

I try to connect from the modem with this command:

$ internal.tcp_client(‘192.168.1.5’, 21)

and the result in my Ftp server log window was:

Wed Apr 02 12:10:33 2008 0 Incoming connection request on interface 192.168.1.5
Wed Apr 02 12:10:33 2008 0 Connection request accepted from 192.168.1.4

what should I do to start develop……. :-<

Please could you write example for send sms message

thanks again

You can execute code:

  • on telnet
  • through AT+LUA="…" AT command
  • from C, with luaW_run( source_code_or_bytecode) (cf. appli.c in the default sample for details)

As soon as you’ve got sources on the module, you can compile them with the standard lua loadstring() function (which takes a source string and returns an executable function). FTP is by far the easiest and fastest way to get your code on the module, and I strongly recommend that you purchase at least one licence, for your development kit (you don’t necessarily need it on field). It will be more than worth the development time you’ll save.

Now, if for some reason you can’t get FTP, here’s a quick&dirty hack that will let you upload and run files on the module. Let’s write, on the module’s shell, a program that listens on TCP port 2037, reads whatever is sent on it, compiles it as source file and runs the resulting bytecode:

Lua interactive shell
$ function read_and_run_src(s)
+   local src=s:read '*a' -- read whole file
+   printf("read %i bytes of source", #src)
+   local f, msg = loadstring(src) -- compile it
+   if f then return f() else error(msg) end -- run it on success
+ end
$ src_server = wip.tcp_server(2037, read_and_run_src) -- use above function as callback for TCP server
$ _

Now, from your PC, send files to port 2037 and they’ll be compiled and run (here I use netcat to send stuff on TCP sockets):

FFT@wmp-pcfft:~/sandbox$ cat hw.lua
print("hello world")
FFT@wmp-pcfft:~/sandbox$ nc -w 1 192.168.1.4 2037 < hw.lua
FFT@wmp-pcfft:~/sandbox$

On the module, you should see:

read 22 bytes of source
hello world

You can also rebuild your own FTP-based solution, taking inspiration from wavecom.com/lua/wiki/tiki-in … eFtpClient, but although I don’t know how expensive full IP licences are, I’m pretty sure it won’t be worth the time spent.

Thanks for the replay

Now I understand how I need to write the code.

If I will not buy this lib. could I connect to GPRS and send data?

Because I have some problems to connect to GPRS bearers.

I config all option like PIN=1234 APN=internetg login="" password=""
and after start wip.bearer_client(‘GPRS’, gprs_config)
it respond “setting PIN code” and stack.

is it because I don’t have the lib or I do some think wrong

The full IP lib provides you applicative protocols: FTP, HTTP, SMTP, POP3. Bearers are fully supported even with basic IP.

It’s difficult to tell what goes wrong without looking at the code. If you have issue with the PIN code, I suggest that you:

  • set it up separately with an AT command: at"AT+CPIN=1234"
  • wait for the full SIM init to be performed (there’s an unsollicited code telling you when it’s done, I can’t remember which one)
  • perform the bearer opening without a “pin” parameter.

PS: beware that in the GPRS bearer config, “apn” and “login” are expected to be lowercase, not uppercase as you wrote.

Sorry that i am asking so many Q.

But what is the name of this Lib. is it plug In(like internet plug in) so i can request it from our distributor

How and where can i use the comand AT+LUA, i get error all the time when i use it.

thanks

Full IP is a feature to enable in the module’s EEPROM, ask your distributor for details. AT+LUA is only available when the Lua sample is loaded. If you don’t have a telnet running, you can try e.g. this:

at+lua="print'Hello world'"
OK
[LUAW] Hello world

(you might get additional traces about RUN and SIGNAL if you compiled with WIP debug traces enabled, which is the default setting).

Sending Lua commands through AT+LUA is by no way user-friendly, it’s mainly intended as an emergency recovery feature, if for some reason you can’t get a telnet to work.