WildCopperAV
-
Posts
6 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Gallery
Downloads
Events
Posts posted by WildCopperAV
-
-
OK was just curious. I have no need to.
Can you explain why I would be asked to not use it?
-
I beleive that a Control 4 processor has Node.JS built in.
Is it possible to utilise it from a driver?
-
Ive altered the code to have a timeout of 0 so it dosent block and set up a timer (C4:AddTimer) to wait for second before calling receive and that works.
-
The code below works, but this is not the proper way of doing things, we dont want to be using blocking sockets on a Control4!
local socket = require("socket")
local udp = assert(socket.udp())
local udp_datafunction test2()
myip = C4:GetMyNetworkAddress()
udp:close()
udp = assert(socket.udp())udp:settimeout(1)
assert(udp:setsockname("*",0))
assert(udp:setpeername(myip,2345))message = "this is a test"
assert(udp:send(message))
udp_data = udp:receive()if (udp_data ~= nil) then
MessagePrint(udp_data)
else
MessagePrint("UDP request failed")
endudp:close()
end -
I am seding out a UDP request to device and its answer is 1407 bytes long, ive tested in Node.JS and it works.
When doing it from Control4 I only get 1024 bytes, ReceivedFromNetwork is only called once, so I cannot get the remainder of the data.
Is there a way around this?
function test()
myip = C4:GetMyNetworkAddress()
C4:NetDisconnect(6998, 2345)
C4:CreateNetworkConnection (6998, myip)
C4:NetConnect (6998, 2345, 'UDP')
endfunction OnConnectionStatusChanged(idBinding, nPort, strStatus)
if (idBinding == 6998) then
if (strStatus == "ONLINE") then
test_message = "this is a test"
C4:SendToNetwork(6998, 2345, test_message)
end
end
endfunction ReceivedFromNetwork(idBinding, nPort, StrData)
MessagePrint("ReceivedFromNetwork idBinding=" .. idBinding .. " port=" .. nPort)
len=string.len(StrData)
MessagePrint("Length=" .. len)
end
Node.JS
in Driver Discussion
Posted
Fair enough.
And yes I have already been using a PI for node exactly as you describe, so will stick with that.