![]() |
|
TCP receive with DENON Amplifier - 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: TCP receive with DENON Amplifier (/showthread.php?tid=5648) |
TCP receive with DENON Amplifier - Hadeel - 03.10.2024 Hi! I am trying to connect DENON Amplifier with TCP. While I can send message successfully to DENON, I cannot receive reply from it. With my laptop I tried TCP with telnet and confirmed that DENON gives back response to my terminal. Following is what I have tried with resident script (interval = 0) but I got no message. Thank you very much in advance! Code: if not server then
require('socket')
server = socket.udp()
server:setsockname('127.0.0.1', 5485)
end
if not tcp then
tcp = assert(socket.tcp())
local res, err = tcp:connect('192.168.0.1', 23)
if res then
return tcp
else
tcp:close()
return nil, err
end
end
function denon_receive(tcp)
res, err = tcp:receive()
if not res then
return nil, err
end
return res
end
while tcp do
res, err =denon_receive(tcp)
if res ~= nil then
log(res,err)
end
if (res == nil) then
log('no response')
end
endRE: TCP receive with DENON Amplifier - admin - 03.10.2024 receive without timeout will wait until a new line (\n) character is received. Try this script instead: Code: sock = require('socket').tcp()
sock:settimeout(10)
res, err = sock:connect('192.168.0.1', 23)
if res then
while true do
res, err, partial = sock:receive()
if res then
log('receive', res)
elseif partial then
log('partial', partial)
elseif err == 'closed' then
break
end
end
else
log('connect failed', err)
end
sock:close()RE: TCP receive with DENON Amplifier - Hadeel - 07.10.2024 Thank you admin! It did solve the issue and I can now get the reply from the amplifier! The issue was, as you said, this amplifier replies message without a single new line (\n) character.... Thank you so much as always! |