03.12.2018, 15:03
Hi,
What I am doing wrong?
I want to control Arcam receiver over IP and put in Command function this code:
Then from event script using this:
Manual of receiver is her: Manual of control
What I am doing wrong?
I want to control Arcam receiver over IP and put in Command function this code:
Code:
function tcp_arcam(data, ip, port)
local sock, res, err
sock = require('socket').tcp()
sock:settimeout(5)
res, err = sock:connect(ip, port or 50000)
if res then
res, err = sock:receive(5)
if res == 'PJ_OK' then
sock:send('PJREQ')
res, err = sock:receive(5)
if res == 'PJACK' then
sock:send(data)
res, err = sock:receive(6)
else
alert('invalid/no ack: ' .. tostring(res))
end
else
alert('invalid/no init: ' .. tostring(res))
end
else
alert('connect failed: ' .. tostring(err))
end
sock:close()
return res, err
end
Code:
cmdon = string.char(0x21, 0x01, 0x00, 0x01, 0xF0, 0x0D)
cmdoff = string.char(0x21, 0x01, 0x00, 0x00, 0xF0, 0x0D)
ip = '192.168.11.112'
if (event.getvalue()==true) then
res, err = tcp_arcam(cmdon, ip)
else
res, err = tcp_arcam(cmdoff, ip)
os.sleep(2.5)
res, err = tcp_arcam(cmdoff, ip)
end
log (res, err)
Manual of receiver is her: Manual of control