Author Topic: ruby initialise command vs receive buffer  (Read 3470 times)

johanr

  • Veteran
  • ***
  • Posts: 144
    • View Profile
ruby initialise command vs receive buffer
« on: December 09, 2010, 11:04:36 am »

Hi!

Starting off as always to excuse myself for posting, maybe even in the wrong section(?)
Anyway. a pointer to a page where these things are described would be as appreciated as giving pointers to what is not ok.

What is wrong with my initialise command?
I assume the answer from the device is handled correct, hence the device getting disabled upon quick reload(if power is on in this case) since I tried to change the first buf.index
 to 001 and then it does register ok.
Can the init command not put devices as enabled? (i.e unclick the disabled button)
Goal: when init send power question, if receive 000(power off)  set device as enabled
               if receive 001(power on)  set device as enabled
If no response at all, then disable device..
Code: [Select]
#31-Nov-10 14:13 init Panasonic AE3000

initok=false

for iRetry in 0...4
print "Initializing unit\n"
conn_.Send("\x02QPW\x03\r")
buf = conn_.Recv(100, 500)
if( !buf.nil? && !buf.index("000").nil? )
print "Initialized ok\n"
initok=true
if( !buf.nil? && !buf.index("001").nil? )
print "Initialized ok\n"
initok=true
break
else
print "Didn't respond to command\n"
end
end

if initok==false
DisableDevice( device_.devid_, true )
print "The device wouldn't respond. Disabling it.\n"
return
end
if initok==true
DisableDevice( device_.devid_, false )
print "The device responded. Enabling it.\n"
return
end

print "Initialized ok, doing log\n"
end

Below is the receive command(also copied from onkyo template)
I am not sure it is correct either, seems like it is reffered to in the init command but then it seem to be misspelled?
I guess it listens for what comes but what is the things between supposed to do " " ?
I guess this what's expected from the device?

Code: [Select]
buff = conn_.RecvDelimited("\1a", -1)
print buff,"\n"



Br
Johan

johanr

  • Veteran
  • ***
  • Posts: 144
    • View Profile
Re: ruby initialise command vs receive buffer
« Reply #1 on: December 09, 2010, 03:12:20 pm »
Ok, have found in the wiki a few explanations to the commands *my god what much there is to know about this*

Anyway There is no ping sort of command that the pana will just answer, so I want to have a init command that treats all possible answers and I simply do not understand how to do it. like an "elsif" of some sort? =/
Been looking at the LG42_ in the wiki which I think is a clean an neat way. But applying it to my config.. and still there are a few things in the LG template that feels overkill, like having to put manually he device id =/ (less is more)
Also, would be nice to get the commands From the device into the log, so I know it's received by the dce.. Like turning on the Projector and the dce would then get that message, Hmm but wait a minute.. Is it really sending anything(?) hmm.. I leave that for now..

anyway here's the latest config currently:
Code: [Select]
18:#### 350 ####################################################################
  19:def cmd_350(cmd=nil)
  20:@returnParamArray.clear
  21:#350 Process Incoming Data
  22:   buff = ''
  23:        loop do
  24:          buff=conn_.Recv(30,200)
  25:          if buff.empty?
  26:            print "Nothing Received\n"
  27:            break
  28:          end
  29:
  30:          if buff.include?("OK")
  31:            print "command received\n"
  32:          elsif buff.include?("ER401")
  33:            print "command ERROR\n"
  34:          end
  35:        end
  36:return @returnParamArray
  37:end
  38:#### 355 ####################################################################
  39:def cmd_355(cmd=nil)
  40:@returnParamArray.clear
  41:#31-Nov-10 14:13 init  Panasonic AE3000
  42:
  43:initok=false
  44:
  45:for iRetry in 0...4
  46:    print "Initializing unit\n"
  47:    conn_.Send("\x02QPW\x03\r")
  48:    buf = conn_.Recv(100, 500)
  49:    if( !buf.nil? && !buf.index("001").nil? )
  50:        print "Initialized ok\n"
  51:           initok=true
  52:           break
  53:   else
  54:           print "Didn't respond to command\n"
  55:   end
  56:end
  57:

johanr

  • Veteran
  • ***
  • Posts: 144
    • View Profile
Re: ruby initialise command vs receive buffer
« Reply #2 on: December 10, 2010, 09:30:51 pm »
ok.. I have no idea why, really but it works as I want now. commented out the disable commands and now it registers at I want, with or without power it seems. =)

closing this thread since the questions I had was not very clear(too much txt around them) and I guess that's why there was no reply.
 Maybe I'll learn/understand more about this later.  :)
Now I need to get ontop of other issues which has woken my attention.

Br
johan