Posts: 23
Threads: 7
Joined: Aug 2017
Reputation:
0
Hi,
What I am doing wrong?
I want to control Arcam receiver over IP and put in Command function this code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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 Then from event script using this:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
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
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
Try this:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
function tcp_arcam (
data ,
ip ,
port )
local sock ,
res ,
err ,
len
sock =
require (
'socket' ).
tcp ()
sock :
settimeout (
1 )
res ,
err =
sock :
connect (
ip ,
port or 50000 )
if res then
sock :
send (
data )
res ,
err =
sock :
receive (
5 )
if type (
res ) ==
'string' and #
res ==
5 then
len =
res :
byte (
5 )
res ,
err =
sock :
receive (
len +
1 )
else
alert (
'receive failed: ' ..
tostring (
err ))
end
else
alert (
'connect failed: ' ..
tostring (
err ))
end
sock :
close ()
return res ,
err
end
Posts: 23
Threads: 7
Joined: Aug 2017
Reputation:
0
(04.12.2018, 07:16) admin Wrote: Try this:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
function tcp_arcam (
data ,
ip ,
port )
local sock ,
res ,
err ,
len
sock =
require (
'socket' ).
tcp ()
sock :
settimeout (
1 )
res ,
err =
sock :
connect (
ip ,
port or 50000 )
if res then
sock :
send (
data )
res ,
err =
sock :
receive (
5 )
if type (
res ) ==
'string' and #
res ==
5 then
len =
res :
byte (
5 )
res ,
err =
sock :
receive (
len +
1 )
else
alert (
'receive failed: ' ..
tostring (
err ))
end
else
alert (
'connect failed: ' ..
tostring (
err ))
end
sock :
close ()
return res ,
err
end
I am got nil and timeout. What you think whats wrong?
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
Do you get any entries in alerts?
Posts: 23
Threads: 7
Joined: Aug 2017
Reputation:
0
(04.12.2018, 10:01) admin Wrote: Do you get any entries in alerts?
Yes receive filed: timeout
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
Try using IR simulation commands for on/off:
Code:
1 2
cmdon =
string.char (
0x21 ,
0x01 ,
0x08 ,
0x02 ,
0x10 ,
0x7B ,
0x0D )
cmdoff =
string.char (
0x21 ,
0x01 ,
0x08 ,
0x02 ,
0x10 ,
0x7C ,
0x0D )
Posts: 23
Threads: 7
Joined: Aug 2017
Reputation:
0
(04.12.2018, 10:16) admin Wrote: Try using IR simulation commands for on/off:
Code:
1 2
cmdon =
string.char (
0x21 ,
0x01 ,
0x08 ,
0x02 ,
0x10 ,
0x7B ,
0x0D )
cmdoff =
string.char (
0x21 ,
0x01 ,
0x08 ,
0x02 ,
0x10 ,
0x7C ,
0x0D )
It's working.
Posts: 23
Threads: 7
Joined: Aug 2017
Reputation:
0
Some ideas how need to get status of Arcam in LM:
It is possible that the state of the AV may be changed as a result of user input via the front panel buttons or via the IR remote control. Any change
resulting from these inputs is relayed to the RC using the appropriate message type.
For example, if the user changed the front panel display brightness using the DISPLAY button on the front panel, a display message (defined below)
would be sent to the RC. A similar action would be taken for all other state changes (including decode mode changes).
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
For this you will need a resident script to constantly poll status values from remote host.