Results 1 to 2 of 2

Thread: 2 way communication from devices to Girder

  1. #1
    Join Date
    Dec 2014
    Posts
    8

    Default 2 way communication from devices to Girder

    Hi there,

    I am trying to get Girder to receive the current status from my amplifier. In my LUA script I have the following:

    local onDataReceived = function(self, data)
    print("Received: ", data)
    if string.sub(data, 1,3) == "VOL" then
    volume=string.sub(data, 4,6)
    print("Volume: ", volume)
    end
    end

    I can see in the Lua console that this is working:

    Fri Feb 20 20:15:35 2015 Received: VOL130
    Fri Feb 20 20:15:35 2015 Volume: 130

    However I cannot get this into a javascript variable in my LHTML web page. In fact I cannot get the volume variable to resolve at all. My test lhtml file had the following:

    <%
    print(volume)
    %>
    <%
    test="Hello World!"
    print(test)
    %>

    The script successfully prints Hello World! which tells me the LUA parsing is happening, but I get nothing output for the volume variable - it seems like it isnt able to be seen by the lhtml script? is there a way to make it global? or is there something i am missing

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    It's possible that "volume" is local to the module it is in. Where does your onDataReceived live? If in a separate Lua file then export volume like this:

    Code:
    -- at the top of the file before module (...)
    local _G = _G
    then your code

    Code:
    local onDataReceived = function(self, data)
       print("Received: ", data)
       if string.sub(data, 1,3) == "VOL" then 
           volume=string.sub(data, 4,6)
    _G.volume = volume
           print("Volume: ", volume) 
       end
    end
    Ron
    No support through PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •