Results 1 to 4 of 4

Thread: Callback Data works differently?

  1. #1
    Join Date
    Sep 2005
    Posts
    108

    Default Callback Data works differently?

    I run the following piece of code in Girder4 and the callback "data" returns 1 line at a time, so "string.find(data, "state: ", 0)" returns 1 7. In Girder5 it returns 212 217 each time so it seems that the data in the callback is returning the whole 20 lines or so that the command "status" calls.

    Before I update all my code to address this, should it be doing this or is it a bug???

    Thanks

    Bill

    --------------------------------------------------------------
    function zone1callback(data, code)
    if string.find(data, "state: ", 0) then
    zones.state[thisZone1] = string.gsub(data, "state: ", "")
    end
    end

    function zone1keepAlive()
    zone1Socket:Write('status\n')
    end

    zone1Socket = gip.Open('192.168.102.101', 6605)
    zone1Socket:Callback(2, '\r\n', 1000, zone1callback)

    zone1Status = gir.CreateTimer("", "zone1keepAlive()", "", true)
    zone1Status:Arm(1000)
    --------------------------------------------------------------

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    12,543

    Default

    We made one change to the way the terminated callback works. Before it would match either the \r or the \n. This is however not very logical. The logical way would be to match the whole thing "\r\n". My guess is that the \r\n never happens in your stream or only at the end. Try specifying the \r or \n alone.
    Ron
    No support through PM

  3. #3
    Join Date
    Sep 2005
    Posts
    108

    Default

    Thanks Ron,

    \n did the trick.

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    12,543

    Default

    Glad it works!
    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
  •