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")
function send2lcd(lcdstr)
local msg = string.format([[xap-header
{
target=dbzoo.livebox.controller:lcd
class=xAPBSC.cmd
}
output.state.1
{
id=*
text=%s
}]], lcdstr)
delay(5)
xap.sendShort(msg)
os.exit()
end
function delay(duration)
duration = duration or 1
local time_to = os.time() + duration
while os.time() < time_to do end
end
xap.init("dbzoo.lua.testlcd","FF00DD00","br0")
send2lcd("test123")
xap.process()
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()
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
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.
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()