Testing Lua code on the command line

Hi,

Is there anywhere in the Wiki it explains how I can SSH in, edit some Lua code on the command line, compile (or whatever other processes need to occur) and then run it up in an execution process for testing?

Thanks,

Alex

They’re a little old, but the following will give you a start:

http://wiki.micasaverde.com/index.php/Logon_Vera_SSH
http://wiki.micasaverde.com/index.php/Luup_Somfy_Walkthrough
http://wiki.micasaverde.com/index.php/Logs
http://wiki.micasaverde.com/index.php/Luup_Debugging

additionally, once you’re comfortable uploading files and generally testing on Vera, you can move to using [tt]scp[/tt] natively to copy the files from your development machine over to Vera, and then running [tt]pluto -c[/tt] on them to create their [tt].lzo[/tt] counterparts.

I use scripts that [tt]copy and compress[/tt] my development code over to Vera, under /etc/cmh-ludl/, performing effectively the same functions that occur if you upload via a Browser. This allows you to rev Plugin code quickly.

I use an external Lua interpreter to test basic Lua programming constructs, on my local machine, for stuff that doesn’t require [tt]luup.xxxxx[/tt] extensions.

Thanks guessed - I’ve been using ssh over the weekend to take a look around on the box and to look at the logging.

The plugin link in particular is helpful thanks, but I can’t see anything that would let me execute the Lua code on the command line for test purposes?

I’d rather not have to go through the web UI every time I want to test code.

Is it possible to test code without the UI?

Thanks, again,

Alex

It’s possible using curl and a POST request invoking the RunLua UPnP action. Test some Lua code from the UI and watch the request with FireBug to see the message format and the required headers. Have a look in /www/cmh/js/ui3/cpanel_data.js at the test_lua_upnp_code function to see how the message is composed.

e.g.
http://127.0.0.1/port_49451/upnp/control/hag

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <u:RunLua xmlns:u="urn:schemas-micasaverde-org:service:HomeAutomationGateway:1"> <DeviceNum></DeviceNum> <Code>luup.log("Hello world!")</Code> </u:RunLua> </s:Body> </s:Envelope>

Great, thanks.