Hi
I’m looking for some help with the following code.
It seems to run successfully (the matrix’s Input changes and a response is captured) but it doesn’t seem to progress (and print out) the required analysis results/response based on what the the HDMI matrix sent back.
[code]function HDMIA1()
local socket = require(“socket”)
host = “192.168.1.204”
c = assert(socket.connect(host, 4002))
c:settimeout(5)
local sres, serr = c:send(string.char(0x02,0x32,0x31,0x31,0x03))
print(“Send:”, sres, serr)
local data, rerr = c:receive(175)
luup.log (data)
print (“Receive:”, data, rerr)
c:close()
– if successful the hdmi switch will return a message which includes the words “Status code:100031111110001” - so I’ve tried to use a lua expression to extract that if it’s there.
local result = data:match “%a+%s%a+:%d+”
print (“” …result)
if (result == “Status code:100031111110001”)
then
luup.log(“it worked”)
print(“it worked”)
if (result ~= “Status code:100031111110001”)
then
luup.log(“it failed”)
print(“it failed”)
else print(“neither were seen it has just failed”)
end
end
end
HDMIA1()[/code]