Author Topic: Ruby &GSD: can I call local subroutines ?  (Read 3074 times)

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Ruby &GSD: can I call local subroutines ?
« on: October 17, 2008, 08:58:28 pm »
hi,

I'm changing template for Marantz audio receivers in multiroom usage scenario... I don't know what happened but it stopped working (could be my fault)... I had no code in

Quote
#384 Process Receive Command For Child

and it worked, cause commands were routed to parent device without problems. Now it seems that command only arrives into

Quote
#384 Process Receive Command For Child

which is more proper I guess...

Now I'd just like to add simple code to
Code: [Select]
538:def cmd_ReceiveCommandForChild(cmd)
 539:log("Received command for child with ID: " + cmd.id_.to_s + " from: " + cmd.devidfrom_.to_s + " to: " + cmd.devidto_.to_s + "\n")
 540:case cmd.id_
 541:    when 169 then    
 542:        cmd_169(cmd);
 543:    when 164 then    
 544:        cmd_164(cmd);
...

to call subroutines that are already written, but it seems it doesn't work - it looks like subroutine cmd_169 never gets executed.... Anyone with more insight ?

Thanks in advance,

regards,

Bulek.

Update: have also strange entry in device log :
Quote
01   10/17/08 20:46:21.904      Error while calling method: Cannot call class method: cmd_ReceiveCommandForChild
01   10/17/08 20:46:39.007      Ruby was unable to handle the command in reasonable amount of time <0xb7809b90>



Code: [Select]
RCODE:
   0:require 'Ruby_Generic_Serial_Device'
   1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
   2:end
   3:class Device_75 < Ruby_Generic_Serial_Device::RubySerialIOWrapper
   4:#### 89 ####################################################################
   5:def cmd_89(repeat_command, cmd=nil)
   6:@returnParamArray.clear
   7:SendMultiZoneCommand(cmd, ["@VOL:1", "@MSV:1", "@MVL:1"])
   8:return @returnParamArray
   9:end
  10:#### 90 ####################################################################
  11:def cmd_90(repeat_command, cmd=nil)
  12:@returnParamArray.clear
  13:SendMultiZoneCommand(cmd, ["@VOL:2", "@MSV:2", "@MVL:2"])
  14:return @returnParamArray
  15:end
  16:#### 97 ####################################################################
  17:def cmd_97(cmd=nil)
  18:@returnParamArray.clear
  19:SendMultiZoneCommand(cmd, ["@AMT:0", "@MSM:0", "@MAM:0"])
  20:return @returnParamArray
  21:end
  22:#### 160 ####################################################################
  23:def cmd_160(cmd=nil)
  24:@returnParamArray.clear
  25:SendMultiZoneCommand(cmd, ["@SRC:E", "@MSC:E", "@MSC:E"])
  26:return @returnParamArray
  27:end
  28:#### 161 ####################################################################
  29:def cmd_161(cmd=nil)
  30:@returnParamArray.clear
  31:SendMultiZoneCommand(cmd, ["@SRC:1", "@MSC:1", "@MSC:1"])
  32:return @returnParamArray
  33:end
  34:#### 162 ####################################################################
  35:def cmd_162(cmd=nil)
  36:@returnParamArray.clear
  37:SendMultiZoneCommand(cmd, ["@SRC:C", "@MSC:C", "@MSC:C"])
  38:return @returnParamArray
  39:end
  40:#### 164 ####################################################################
  41:def cmd_164(cmd=nil)
  42:@returnParamArray.clear
  43:SendMultiZoneCommand(cmd, ["@SRC:9", "@MSC:9", "@MSC:9"])
  44:return @returnParamArray
  45:end
  46:#### 165 ####################################################################
  47:def cmd_165(cmd=nil)
  48:@returnParamArray.clear
  49:SendMultiZoneCommand(cmd, ["@SRC:2", "@MSC:2", "@MSC:2"])
  50:return @returnParamArray
  51:end
  52:#### 166 ####################################################################
  53:def cmd_166(cmd=nil)
  54:@returnParamArray.clear
  55:SendMultiZoneCommand(cmd, ["@SRC:F", "@MSC:F", "@MSC:F"])
  56:return @returnParamArray
  57:end
  58:#### 169 ####################################################################
  59:def cmd_169(cmd=nil)
  60:@returnParamArray.clear
  61:SendMultiZoneCommand(cmd, ["@SRC:H", "@MSC:H", "@MSC:H"])
  62:return @returnParamArray
  63:end
  64:#### 170 ####################################################################
  65:def cmd_170(cmd=nil)
  66:@returnParamArray.clear
  67:SendMultiZoneCommand(cmd, ["@SRC:G", "@MSC:G", "@MSC:G"])
  68:return @returnParamArray
  69:end
  70:#### 172 ####################################################################
  71:def cmd_172(cmd=nil)
  72:@returnParamArray.clear
  73:SendMultiZoneCommand(cmd, ["@SRC:A", "@MSC:A", "@MSC:A"])
  74:return @returnParamArray
  75:end
  76:#### 178 ####################################################################
  77:def cmd_178(cmd=nil)
  78:@returnParamArray.clear
  79:SendMultiZoneCommand(cmd, ["@SRC:4", "@MSC:4", "@MSC:4"])
  80:return @returnParamArray
  81:end
  82:#### 192 ####################################################################
  83:def cmd_192(pk_pipe, pk_device_pipes, cmd=nil)
  84:@returnParamArray.clear
  85:#SendMultiZoneCommand(cmd, ["@PWR:2", "@MSP:2", "@MAM:1"])
  86:log("cmd_192 called: got command with ID: " + cmd.id_.to_s + " from: " + cmd.devidfrom_.to_s + " to: " + cmd.devidto_.to_s + "\n")
  87:SendMultiZonePowerOnCommand(cmd, ["@AMT:1", "@MSP:2", "@MAM:1"])
  88:
  89:return @returnParamArray
  90:end
  91:#### 193 ####################################################################
  92:def cmd_193(pk_pipe, cmd=nil)
  93:@returnParamArray.clear
  94:#SendMultiZoneCommand(cmd, ["@PWR:1", "@MSP:1", "@MAM:2"])    
  95:SendMultiZonePowerOffCommand(cmd, ["@AMT:2", "@MSP:1", "@MAM:2"])    
  96:
  97:return @returnParamArray
  98:end
  99:#### 282 ####################################################################
 100:def cmd_282(cmd=nil)
 101:@returnParamArray.clear
 102:SendMultiZoneCommand(cmd, ["@SRC:3", "@MSC:3", "@MSC:3"])
 103:return @returnParamArray
 104:end


 ....


 537:
 538:def cmd_ReceiveCommandForChild(cmd)
 539:log("Received command for child with ID: " + cmd.id_.to_s + " from: " + cmd.devidfrom_.to_s + " to: " + cmd.devidto_.to_s + "\n")
 540:case cmd.id_
 541:    when 169 then     #power on
 542:        cmd_169(cmd);
 543:    when 164 then     #power on
 544:        cmd_164(cmd);
 545:    when 172 then     #power on
 546:        cmd_172(cmd);
 547:    when 162 then     #power on
 548:        cmd_162(cmd);
 549:    when 420 then     #power on
 550:        cmd_420(cmd);
 551:    when 178 then     #power on
 552:        cmd_178(cmd);
 553:    when 165 then     #power on
 554:        cmd_165(cmd);
 555:    when 170 then     #power on
 556:        cmd_170(cmd);
 557:    when 160 then     #power on
 558:        cmd_160(cmd);
 559:    when 166 then     #power on
 560:        cmd_166(cmd);
 561:    when 161 then     #power on
 562:        cmd_161(cmd);
 563:
 564:    when 891 then     #power on
 565:        cmd_891(cmd);
 566:    when 587 then     #power off
 567:        cmd_587(cmd);
 568:    when 97 then      #power on
 569:        cmd_97(cmd);
 570:    when 313 then     #power off
 571:        cmd_313(cmd);
 572:    when 90 then     #power on
 573:        cmd_90(cmd);
 574:    when 89 then     #power off
 575:        cmd_89(cmd);
 576:    when 192 then     #power on
 577:        cmd_192(cmd);
 578:    when 193 then     #power off
 579:        cmd_193(cmd);
 580:    when 192  #power on
 581:        log("Calling cmd_192 with ID: " + cmd.id_.to_s + " from: " + cmd.devidfrom_.to_s + " to: " + cmd.devidto_.to_s + "\n");
 582:        cmd_192(cmd);
 583:    else
 584:        log("Unmatched command for child received with ID: " + cmd.id_.to_s + " from: " + cmd.devidfrom_.to_s + " to: " + cmd.devidto_.to_s + "\n")
 585:    
 586:    
 587:end
 588:
 589:end
 
 621:#### START SETTERS ####################################################################
 622:def initialize()
 623:super
 624:@returnParamArray=Array.new
 625:end
 626:####  END  SETTERS ####################################################################
 627:end
« Last Edit: October 17, 2008, 09:00:53 pm by bulek »
Thanks in advance,

regards,

Bulek.

MarcoZan

  • Veteran
  • ***
  • Posts: 148
    • View Profile
Re: Ruby &GSD: can I call local subroutines ?
« Reply #1 on: October 18, 2008, 10:57:09 am »
Hi Tinia

I got a similar issue, where I also had my GSD device that suddenly stopped working.

Well, not really suddenly, I was working on it and probably I made something wrong when saving the device settings.

In the end the reason was really trivial: the "COM Port on PC" parameter was blank.

Probably during update I did not realize that the proper parameter value was overwritten, and I spent a lot of time to figure it out.

HTH

Marco


bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Ruby &GSD: can I call local subroutines ?
« Reply #2 on: October 18, 2008, 02:39:53 pm »
Hi Tinia

I got a similar issue, where I also had my GSD device that suddenly stopped working.

Well, not really suddenly, I was working on it and probably I made something wrong when saving the device settings.

In the end the reason was really trivial: the "COM Port on PC" parameter was blank.

Probably during update I did not realize that the proper parameter value was overwritten, and I spent a lot of time to figure it out.

HTH

Marco


Hi,

thanks for response... in my case a problem is probably a bit different.

I can see in my log that :
Quote
18-10-2008  14:19:37  (***):Received command for child with ID: 192 from: 20 to: 79

But then nothing happens - it seems like cmd_192 is not called - and I guess the problem is in case statement - I'm ruby newbie and maybe I'm doing something awfully wrong....

Thanks in advance,

regards,

Bulek.
Thanks in advance,

regards,

Bulek.

MarcoZan

  • Veteran
  • ***
  • Posts: 148
    • View Profile
Re: Ruby &GSD: can I call local subroutines ?
« Reply #3 on: October 19, 2008, 12:42:57 pm »
Hi Bulek
I'm also very rude with Ruby, so I don't know how much I can help.

Looking at the code in my GSD device I can see a slightly different situation:

Code: [Select]
cmdId = cmd.Id_

......
case cmdId
  when 192 #192 is ON
      .... some code
  when 193 #193 is OFF
    .... some other code
 

As you can see I have not "then" statement.
If the syntax is wrong I expect that you should have a clear error at GSD compiling, but I guess this is not exactly the case. Nevertheless you claim to have a strange error regarding the method cmd_ReceiveCommandsForChilds, that in the end shouldn't be there.

Just my 0,02 (maybe less ...)

Regards
Marco