Logic Machine Forum
SpaceLynk delay - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: SpaceLynk delay (/showthread.php?tid=2520)



SpaceLynk delay - weblima - 17.03.2020

We are having some problems integrating an IR/RF controller with Spacelynk. The device works with the scripts we've found  at KNX Groep BV forum and already used in other projects to send IR signals (for air conditioning the delay was not noticed, but for a curtain, let's say that the client is not happy at all). We are using either:


function tcpsend(message)
 host, port = "192.168.126.56", 4998 --IP adres en poort
 socket = require('socket')
 tcp = assert(socket.tcp())
 tcp:connect(host, port);
 tcpConfusedend(message);
  while true do
    s, status, partial = tcp:receive()
    print(s or partial)
    if status == "closed" then break end
  end
 tcp:close()
end

and

-- TCP Send
function tcpbose(message)
 host, port = "192.168.0.101", 4999
  socket = require("socket")
  client = socket.tcp()
  clientConfusedettimeout(1)
  client:connect(host, port)
  clientConfusedend(message)
  client:receive()
  client:close()
end

The device in question can integrate Somfy RF courtain commands and IR as well. But we are facing a huge delay between pressing a push button and having the courtain moving (arround 10 seconds).
We are using event based scripts for that. By logs we've seen that the KNX telegram is quickly received by Spacelynk and the delay happens between the reception of the telegram and the script initialization (we´ve noticed by checking object timestamp and log events written on the first line of the script and another before the send message command). The 10 seconds happen between the reception of the telegram and the beginning of the script. (Socket connection TCP function and etc happen immediatelly).
The benchwork test had pratically only this funcion running and no KNX bus traffic apart from the blinds command telegram. The delay always happens. 
Can anyone help me out?
 
Thanks in advance.


RE: SpaceLynk delay - admin - 18.03.2020

Can you provide a backup from that device?


RE: SpaceLynk delay - weblima - 24.03.2020

(18.03.2020, 15:32)admin Wrote: Can you provide a backup from that device?
Hi! Here it is..
Group address 0/1/1 activates the TCP function. Please check the timestamp when the telegram is sent and the timestamp for the alerts.

Thanks.


RE: SpaceLynk delay - admin - 24.03.2020

You have some script code in common functions which gets executed when any script runs, including os.sleep(5) call. There should not be any code that's executed directly there. Remove it and your script will work without delays.


RE: SpaceLynk delay - weblima - 24.03.2020

(24.03.2020, 07:09)admin Wrote: You have some script code in common functions which gets executed when any script runs, including os.sleep(5) call. There should not be any code that's executed directly there. Remove it and your script will work without delays.
Thanks for the prompt reply.
So, the script with the  os.sleep is from a doorbird integration presented in the forum. Where would it be correct to run this doorbird script and not compromise performance?
Regards,


RE: SpaceLynk delay - admin - 25.03.2020

Put it into a separate script and remove everything after "-- doorbird APP" from Common functions. Since there's script.disable(_SCRIPTNAME) at the end of the doorbird script it means that is should run only once and then it will automatically disable itself.

Further explanation: Common functions is a library which is loaded by every script. In your case all event scripts are delayed for at least 5 seconds because you have os.sleep(5) is Common functions. You also have a code that writes HTML to a file. Since this code is executed for every script you can quickly degrade internal SD card this way.