Starting with Plugboard V2

Hello,

Should following script work - ie. is the syntax/spelling ok?  Or it should not with M8?  Have been trying with 279.14/1.0 and lcd does not change; see no errors and do not manage to snoop related xAP messages either.

Regards,
Aivo 


require("xap")

Member for

16 years 10 months

brett

15 years 6 months ago

I'm not sure where to begin this is just broken in so many ways.

I suggest you have a look at the sample applets in /etc_ro_fs./plugboard/sample

As a script this would HOLD everything else to ransom. This delay() loop, which is a busy spin (extremely bad), will max the the HAH cpu at 100%..  If you want to send period events you need to use the Timer class and a callback.

As a skeleton you would so something like this - which will call the updateClock function every 10 seconds.

function updateClock()
end
xap.init(...)
xap.Timer(updateClock, 10):start()
xap.process()

Member for

15 years 8 months

aivo

15 years 6 months ago

Ok Brett, such delay is bad, will take a note and try to make things more intelligent.

My effort with this test was to update lcd though - ie construct valid message and send it.  I have looked at new samples but clearly then .. have not managed to learn enough ;).

Stripping the sample to one below - if this should work standalone from lua - just one go to send2lcd and out?

Aivo


require("xap")

function send2lcd()
  xap.sendShort([[
xap-header
{
target=dbzoo.livebox.controller:lcd
class=xAPBSC.cmd
}
output.state.1
{
id=*
text=test123
}]])
end

xap.init("dbzoo.lua.testlcd","FF00DD00","br0")
send2lcd()

Brett: fixed above script to be the minimum required you don't need xap.process unless you are going to a receive xap events, or are using a Timer.

http://www.dbzoo.com/livebox/hah_xap_python#xap_lcd_clock  A Python version of your clock.

Member for

15 years 8 months

aivo

15 years 6 months ago

Thank you Brett,

I was trying with this to produce script that would scroll info (1w temp, cc watts etc) on lcd.
For the moment however the minimal script above also is not changing lcd for me on 279.14/1.0.  Will try again when 328 chip arrives.

Kind regards,
Aivo

Member for

16 years 5 months

BoxingOrange

15 years 6 months ago

Hi Avio,

I've got this script running as a standalone Lua application, ie running lua clock2.lus.  You could use this as a starting point for your script and easily turn it into an Applet.

Regards

Karl

 

require("xap")

info = {version="0.02", description="HAH LCD Clock"}

-- Update the LCD every 5 seconds with the current time
function init()
    print("HAH LCD Clock")
    xap.Timer(doclock, 5):start()
end

function doclock()
    print("HAH LCD doclock")
    xap.send(string.format("xap-header\
    {\
    v=12\
    hop=1\
    source=dbzoo.lua.lcdclock\
    uid=FF00DD00\
    class=xAPBSC.cmd\
    target=dbzoo.livebox.Controller:lcd\
    }\
    output.state\
    {\
    id=*\
    text=%s\
    }\
    ",os.date("%H:%M:%S")))
end

xap.init("dbzoo.lua.lcdclock","FF00DD00","br0")
init()
xap.process()

Member for

15 years 8 months

aivo

15 years 6 months ago

Thank you Karl,

Also with this one lcd does not change for me, print lines appear normally.  What version of livebox are you running?

Regards,
Aivo

Member for

16 years 5 months

BoxingOrange

15 years 6 months ago

I'm running an alpha/beta version at the moment, I can't connect to it right now so can't give the specific version. 

Have you tried using the xFx viewer program to "see" the xAP messages on the LAN, http://www.xapautomation.org/index.php?title=xFx_Viewer.  This is a great tool to help troubleshoot problems. 

Have you been able to set the LCD using the web GUI interface?  I used this to see the xAP message, and built my code from there.

The reccuring print lines were used for troubleshooting the code, so I could see which code block was being executed, you would obviously take these out when the script is converted to an Applet.

 

Karl

Member for

15 years 8 months

aivo

15 years 6 months ago

will do that.  I did try the xFx Viewer few weeks ago but did not manage to catch any messages, even when firewall off on pc.  Will give it another go and use really simple unmanaged bridge too if needed.

Yes, via webinterface lcd can be updated.

Regards,
Aivo

Member for

16 years 10 months

brett

15 years 6 months ago

Be aware if you are using V4 of xFxviewer you need to also have a HUB running otherwise you will get no data at all.   V3 did not have this requirement.  I tend to use V3 as I don't run any other xap programs on my windows box so starting a hub just so I can run V4 is really annoying.

Member for

15 years 8 months

aivo

15 years 6 months ago

on 279.14/1.0.  Needed was state.1 and also state value, i.e
output.state.1
    {
    state=on
    ..

Thanks,
Aivo