This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

TCP receive with DENON Amplifier
#1
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
end
Reply
#2
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()
Reply
#3
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!
Reply


Forum Jump: