Scripts not working

5 replies [Last post]
Reading, United Kingdom
Joined: 7 Jul 2010

I want to get started with the more intelligent stuff. So, I started with sample script to switch off the relay1 after its on for 30 secs., but I get this error:-


# cd /etc

# cd plugboard

# ls


# lua relay1AutoOffApplet.lua

lua: relay1AutoOffApplet.lua:7: bad argument #1 to 'module' (string expected, got nil)

stack traceback:

        [C]: in function 'module'

        relay1AutoOffApplet.lua:7: in main chunk

        [C]: ?

I have checked the zap-livebox.ini and it shows that scripting is enabled
output of ps is :-
    1 root      2256 S    init
    2 root         0 SW   [keventd]
    3 root         0 RWN  [ksoftirqd_CPU0]
    4 root         0 SW   [kswapd]
    5 root         0 SW   [bdflush]
    6 root         0 SW   [kupdated]
    7 root         0 SW   [mtdblockd]
    8 root         0 SW   [khubd]
   29 root         0 SWN  [jffs2_gcd_mtd2]
  107 root      1668 S    dropbear -p 22
  120 root      2240 S    inetd
  126 root      1028 S    /usr/bin/xap-hub -i br0
  129 root      3368 S    /usr/bin/xap-pachube -i br0
  130 root      1068 S    /usr/bin/xap-livebox -s /dev/ttyS0 -i br0
  139 root      5000 S    /usr/bin/kloned
  141 root      5012 S    /usr/bin/kloned
  142 root      2608 S    /usr/bin/xap-currentcost -s /dev/ttyUSB0 -i br0
  144 root      3628 S    /usr/bin/xap-twitter -i br0
  147 root      3712 S    lua /etc_ro_fs/plugboard/plugboard.lua
  157 root      5012 S    /usr/bin/kloned
  161 root      1740 S    dropbear -p 22
  162 root      2260 S    -ash
  187 root      1740 S    dropbear -p 22
  188 root      2276 S    -ash
  198 root      1456 S    /usr/bin/iServer -i br0
  199 root      1456 S    /usr/bin/iServer -i br0
  210 root      2244 R    ps
What am I missing?  - I looked at the wiki, but it seems to be for an older version in terms of where the files need to be etc.
I am running build 289/1.0
Any pointers gratefully received


Ayr, United Kingdom
Joined: 25 Sep 2011

Have you rebooted the box with the Applet in the /etc/plugboard directory. I don't think you can run it using the command line (lua  relay1AutoOffApplet.lua) the plugboard script needs to pick it up when the box starts up.

Providence, United States
Joined: 9 Jan 2010
Everybody does this

I'm sure that is documented here

Applet cannot run standalone without modifications (minor), as supplied they are configured to ran by the plugboard engine.


Reading, United Kingdom
Joined: 7 Jul 2010
That worked but...

It might be just that I am not reading the docs thouroughly enough, but I rebooted and the script didnt work until I manually ran xap-plugboard from the command line.

Surely it should pick it up automatically. Could this be because I have an old chip (new one on order)

Providence, United States
Joined: 9 Jan 2010
Nothing to do with a chip

The LUA engine is not dependant on any AVR firmware version.

Rebooting will load the applet but if you want to see what is going on its best to stop the plugboard daemon and run it manually from the command line.

# /etc/init.d/xap stop plugboard
# xap-plugboard -i br0

The applet should fire after 30sec of detecting an ON event for relay 1.

I might add that anytime the plugboard engine crashes, when started automatically it will log into /var/log a stack trace for diagnosis.  Rebooting erases this area so if you want to find out why it broke, do so BEFORE rebooting.

Reading, United Kingdom
Joined: 7 Jul 2010
My bad it didnt break

I was just a bit too quick after the reboot. A look at xfx viewer showed two responses, which suggests to me that I had two instances of plugboard running - the automatic one and the one I started manually.




Still - I learnt something!

Hardware Info