This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

localhost socket stuck with specific data ?
#1
Hi!
I have a project with Lutron integration and I follwed the thread below to setup Lutron library.

https://forum.logicmachine.net/showthrea...ght=lutron

As I have a lot of group addresses which requires to send command to Lutron server, I have setup localhost socket inside LM as always, in order to unite the place to open TCP port for Lutron.

My scripts are below.

Event script to simulate Lutron button press and release.
Code:
1234567891011121314151617181920212223242526
--1    ALL ON --2    Reading --3    Relax --4    Goodnight --5    ALL OFF --18    Dim down --19    Dim up --20    Dim down button release (stop dimming) --21    Dim up button release (stop) device = '5101' value = event.getvalue() if value == 20 then   cmd = '#DEVICE,'..device..',18,4\r\n'   log(cmd..'_dim down↓stop') elseif value == 21 then   cmd = '#DEVICE,'..device..',19,4\r\n'   log(cmd..'_dim up↑stop') else   cmd = '#DEVICE,'..device..','..value..',3\r\n' end sock = require('socket').udp() log(cmd..'_sent to udp socket in the event') sock:sendto(cmd, '127.0.0.1', 5485) sock:close()

Resident script which collects the udp information and send to Lutron server
(address "10/1/2" indicates if there is a conection error with Lutron server)
Code:
12345678910111213141516171819202122232425262728293031323334
require('user.lutron') require('socket') if not server then    server = socket.udp()   server:setsockname('127.0.0.1', 5485) end data = server:receive() if data then   log(data..'_data before sent to lutron tcp')   tcp, err = lutron_login()   if not tcp then     grp.checkwrite('10/0/2', true)     log('no connection to device', err)   end   if tcp == nil then     grp.checkwrite('10/0/2', true)   else     tcp:send(data)     log(data)     os.sleep(0.3)   end   if tcp == nil then     grp.checkwrite('10/0/2', true)   elseif lutron_receive(tcp)~= nil then     if lutron_receive(tcp)[1] ~= nil then       if lutron_receive(tcp)[1]== "no connection to device" then         log(lutron_receive(tcp)[1])         grp.checkwrite('10/0/2', true)       end     end   end end

When I execute the event above, this is what I can see in the log.
For some reason, when I send val 18 or 19 to press dim up /down button on lutron
I cannot send button release command (val 20 or 21) within next 20 seconds even though I simulate to press them way earlier than that.
This happens only when I send val 18 or 19 to this event....how am I making the socket stuck?

Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
localhost socket stuck with specific data ? - by Hadeel - 16.07.2024, 14:25

Forum Jump: