LogicMachine Forum
Send and recieve UDP commands to/from Pharos - Printable Version

+- LogicMachine 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: Send and recieve UDP commands to/from Pharos (/showthread.php?tid=5842)



Send and recieve UDP commands to/from Pharos - stonecroft - 14.01.2025

Hello.
I use this script to send UDP commands to a Pharos Designer LPC and it works fine.
Now I need to recieve status from the Pharos controler via UDP.
Seartch the forum but cant find any good start. Someone who has an example?

Code:
value = event.getvalue() if (value == 0) then   scen = 'fran' elseif (value == 1) then   scen = 'scen01' elseif (value == 2) then   scen = ' scen02' elseif (value == 3) then   scen = ' scen03' elseif (value == 4) then   scen = ' scen04' elseif (value == 5) then   scen = ' scen05' elseif (value == 6) then   scen = 'scen06' elseif (value == 7) then   scen = ' scen07' elseif (value == 8) then   scen = ' scen08' elseif (value == 9) then   scen = ' scen09' elseif (value == 10) then   scen = ' scen10' elseif (value == 11) then   scen = ' scen11' elseif (value == 12) then   scen = ' scen12' elseif (value == 13) then   scen = ' scen13' elseif (value == 14) then   scen = ' scen14' elseif (value == 15) then   scen = ' scen15' elseif (value == 16) then   scen = ' scen16' elseif (value == 17) then   scen = ' scen17' elseif (value == 18) then   scen = ' scen18' elseif (value == 19) then   scen = ' scen19' end ip = '172.16.61.90' port = 5000 local sock = require('socket').udp() if sock then       sock:setoption('broadcast', true)   sock:sendto(scen, ip, port)     sock:settimeout(200)   data = sock:receive()   sock:close()   end return data



RE: Send and recieve UDP commands to/from Pharos - admin - 14.01.2025

You need to bind your receiving socket:
Code:
sock:setpeername('*', port)



RE: Send and recieve UDP commands to/from Pharos - stonecroft - 14.01.2025

My script is a event base script.
To recieve I think I need a resident script or am I totaly wrong?


RE: Send and recieve UDP commands to/from Pharos - admin - 14.01.2025

Yes, you need a resident script.