Author Topic: Marantz SR over RS232  (Read 20614 times)

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Marantz SR over RS232
« on: January 13, 2008, 03:24:42 am »
Hi Devs,

after the ruby hands on with ddamron (thanks again) I did a template for the Marantz SR series based on the work of bulek (http://wiki.linuxmce.org/index.php/Marantz_SR5600).
I'm handling messages from the SR with the #350 process incoming data command:
Code: [Select]
...
case avrcommand
  when 'SRC'
    case avrvalue
      when 'D'
         log('Input #420: CDR')
         input_param=420
...
cmd = Command.new(device_.devid_, -1001, 1, 2, 49);
cmd.params_[41] = input_param.to_s()
SendCommand(cmd);
i see the message on the router but it has no handlers:
Code: [Select]
07      01/13/08 2:54:49.681            Event #49 has no handlers <0x71aa8b90>
07      01/13/08 2:54:49.681            Received Message from 98 (SR7001 / Wohnzimmer) to -1001 (unknown / ), type 2 id 49 Event:AV Input Changed, retry none, parameters: <0x71aa8b90>
does anybody know more about event #49?

best regards,
Hari

ps: the plug and play script works fine, too. It's in the trunk.
rock your home - http://www.agocontrol.com home automation

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Marantz SR over RS232
« Reply #1 on: January 13, 2008, 03:37:46 am »
Hi,

I have much enhanced that template, but currently I'm stuck with it, cause I cannot contribute it anywhere.....

Regards,

Bulek.
Thanks in advance,

regards,

Bulek.

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: Marantz SR over RS232
« Reply #2 on: January 13, 2008, 03:44:08 am »
Hi,

I have much enhanced that template, but currently I'm stuck with it, cause I cannot contribute it anywhere.....

Regards,

Bulek.

can you post your ruby commands?

best regards,
Hari
rock your home - http://www.agocontrol.com home automation

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Marantz SR over RS232
« Reply #3 on: January 13, 2008, 05:22:59 am »
Hari,

Glad your getting used to Ruby!

it's quite the elegant language once you get used to it..

Dan

P.S.

Glad I could help!
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: Marantz SR over RS232
« Reply #4 on: January 13, 2008, 03:31:18 pm »
as requested by some devs (but be aware, the input handling is not finished yet):
Code: [Select]
RCODE:
   0:require 'Ruby_Generic_Serial_Device'
   1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
   2:end
   3:class Device_98 < Ruby_Generic_Serial_Device::RubySerialIOWrapper
   4:#### 89 ####################################################################
   5:def cmd_89(repeat_command, cmd=nil)
   6:@returnParamArray.clear
   7:conn_.Send("@VOL:1\r")
   8:
   9:return @returnParamArray
  10:end
  11:#### 90 ####################################################################
  12:def cmd_90(repeat_command, cmd=nil)
  13:@returnParamArray.clear
  14:conn_.Send("@VOL:2\r")
  15:
  16:return @returnParamArray
  17:end
  18:#### 97 ####################################################################
  19:def cmd_97(cmd=nil)
  20:@returnParamArray.clear
  21:conn_.Send("@AMT:0\r")
  22:
  23:return @returnParamArray
  24:end
  25:#### 160 ####################################################################
  26:def cmd_160(cmd=nil)
  27:@returnParamArray.clear
  28:conn_.Send("@SRC:E\r")
  29:
  30:return @returnParamArray
  31:end
  32:#### 165 ####################################################################
  33:def cmd_165(cmd=nil)
  34:@returnParamArray.clear
  35:conn_.Send("@SRC:2\r")
  36:
  37:return @returnParamArray
  38:end
  39:#### 178 ####################################################################
  40:def cmd_178(cmd=nil)
  41:@returnParamArray.clear
  42:conn_.Send("@SRC:4\r")
  43:
  44:return @returnParamArray
  45:end
  46:#### 192 ####################################################################
  47:def cmd_192(pk_pipe, pk_device_pipes, cmd=nil)
  48:@returnParamArray.clear
  49:conn_.Send("@PWR:2\r")
  50:
  51:return @returnParamArray
  52:end
  53:#### 193 ####################################################################
  54:def cmd_193(pk_pipe, cmd=nil)
  55:@returnParamArray.clear
  56:conn_.Send("@PWR:1\r")
  57:
  58:return @returnParamArray
  59:end
  60:#### 282 ####################################################################
  61:def cmd_282(cmd=nil)
  62:@returnParamArray.clear
  63:conn_.Send("@SRC:3\r")
  64:
  65:return @returnParamArray
  66:end
  67:#### 350 ####################################################################
  68:def cmd_350(cmd=nil)
  69:@returnParamArray.clear
  70:### #350
  71:while(true)
  72:  @buff = conn_.Recv(128,50)
  73:  if(@buff.length() == 0)
  74:    break
  75:  end
  76:  debugin(@buff)
  77:  response = @buff;
  78:  avrcommand = response[1..3]
  79:  avrvalue = response[5]
  80:  case avrcommand
  81:    when 'SRC'
  82:      case avrvalue
  83:        when 'D'
  84:     log('Input #420: CDR')
  85:          input_param=420
  86:        when '4'
  87:          log('Input #178: DSS')
  88:          input_param=178
  89:        when '2'
  90:          log('Input #165: DVD')
  91:          input_param=165
  92:        when '3'
  93:          log('Input #282: VCR-1')
  94:          input_param=282
  95:        when 'E'
  96:          log('Input #160: TAPE')
  97:          input_param=160
  98:      end
  99:      cmd = Command.new(device_.devid_, -1001, 1, 2, 49);
 100:      cmd.params_[41] = input_param.to_s()
 101:      SendCommand(cmd);
 102:
 103:    else
 104:        log('not handling command: ' + avrcommand.to_s())
 105:  end
 106:end
 107:
 108:### END OF #350
 109:return @returnParamArray
 110:end
 111:#### 355 ####################################################################
 112:def cmd_355(cmd=nil)
 113:@returnParamArray.clear
 114:### #355
 115:
 116:$red = 0x1b.chr + '[31m'
 117:$green = 0x1b.chr + '[32m'
 118:$yellow = 0x1b.chr + '[33m'
 119:$blue = 0x1b.chr + '[34m'
 120:$purple = 0x1b.chr + '[35m'
 121:$aqua = 0x1b.chr + '[36m'
 122:$grey = 0x1b.chr + '[37m'
 123:$redBack = 0x1b.chr + '[41m'
 124:$greenBack = 0x1b.chr + '[42m'
 125:$yellowBack = 0x1b.chr + '[43m'
 126:$blueBack = 0x1b.chr + '[44m'
 127:$purpleBack = 0x1b.chr + '[45m'
 128:$aquaBack = 0x1b.chr + '[46m'
 129:$greyBack = 0x1b.chr + '[47m'
 130:$blackBack = 0x1b.chr + '[48m'
 131:
 132:conn_.Send("@AST:F\r")
 133:return @returnParamArray
 134:end
 135:#### PRIVATE METHODS ####################################################################
 136:def debugin(text)
 137:  work = 'IN:' + text
 138:  log($red + work + "Length:" + text.length.to_s + $grey)
 139:end
 140:
 141:def log(line)
 142:  $log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a")
 143:  $log.puts "(***):" + line.to_s
 144:  $log.close
 145:end
 146:#### 420 ####################################################################
 147:def cmd_420(cmd=nil)
 148:@returnParamArray.clear
 149:conn_.Send("@SRC:D\r")
 150:
 151:return @returnParamArray
 152:end
 153:#### START SETTERS ####################################################################
 154:def initialize()
 155:super
 156:@returnParamArray=Array.new
 157:end
 158:####  END  SETTERS ####################################################################
 159:end

ps: some functions were shamelessly ripped from ddamron
rock your home - http://www.agocontrol.com home automation

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: Multiroom (Marantz SR over RS232)
« Reply #5 on: January 13, 2008, 03:40:51 pm »
to implement the multi room feature i think we should create the multi rooms as related child devices (got inspired by the Yamaha template). We could assign every child to another EA. The parent would handle all commands with the "handle commands for child" cmd and send the multi room commands to the amp. The on/off cmds for the child would enable/disable the multi room.

bulek, any ideas?

best regards,
Hari
rock your home - http://www.agocontrol.com home automation

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Multiroom (Marantz SR over RS232)
« Reply #6 on: January 13, 2008, 08:40:03 pm »
to implement the multi room feature i think we should create the multi rooms as related child devices (got inspired by the Yamaha template). We could assign every child to another EA. The parent would handle all commands with the "handle commands for child" cmd and send the multi room commands to the amp. The on/off cmds for the child would enable/disable the multi room.

bulek, any ideas?

best regards,
Hari
Hi,

generally speaking, you're thinking right... I already tried different things some year or so ago, but couldn't get to the proper solution. Basically I create one child device for FM Tuner, but the problem is that how to control/distribute commands. if you have separate commands (this is IMHO good enough solution till two separate output channels), then you can distinguish between them. if you have child device than it's probably impossible to assign volume controls to some other Orbiter screen... Also, don't forget that multiroom is only a feature, so you can easily swithc it off and use all channels for single source..

In my use, I usually declare new room called Audio Center and put all commands that relate to control of Marantz in Media scenarios (Vol+-, Vol+- multiroom, and basic switching/routing of audio sources and outputs - for instance I have "Separate" scenario, where I set up Marantz with two sources and two outputs..... I think this is not bad solution for a start...

I also hope that somewhere along the line, support for multichannel output devices will become part of LMCE and also ability to add 3rd party audio players (I also did a lot of work on "Audio only Xine player" idea, where you could use more separate stereo channels on Core as a source for whole house audio system for - either by putting in more sound cards, or using those cards that let you use multichannel outputs as separate stereo channels...)...

To be honest, for a start, good logging feature would help to enhance that template...

Regards,

Bulek.
 
Thanks in advance,

regards,

Bulek.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Marantz SR over RS232
« Reply #7 on: January 14, 2008, 07:07:31 am »
Hari,

I have no problem with you 'ripping' my code as long as I'm mentioned ;)

Happy coding!

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: Marantz SR over RS232
« Reply #8 on: January 16, 2008, 07:08:11 pm »
events for power on/off and vol up/down

Code: [Select]
### #350
while(true)
@buff = conn_.Recv(128,50)
if(@buff.length() == 0)
break
end
debugin(@buff)
response = @buff;
avrcommand = response[1..3]
avrvalue = response[5]
case avrcommand
when 'SRC'
log('input changed: '+ avrvalue);
input_param=0
case avrvalue
when 'D'
log('Input #420: CDR')
input_param=420
when '4'
log('Input #178: DSS')
input_param=178
when '2'
log('Input #165: DVD')
input_param=165
when '3'
log('Input #282: VCR-1')
input_param=282
when 'E'
log('Input #160: TAPE')
input_param=160
end
cmd = Command.new(device_.devid_, -1001, 1, 2, 49);
cmd.params_[41] = input_param.to_s();
SendCommand(cmd);
when 'VOL'
volume = response[5..-1].to_i();
log('volume changed: ' + volume.to_s);
SetDeviceDataInDB( device_.devid_, 158, volume.to_s ) # 158 = DEVICEDATA_Volume_Level_CONST
cmd = Command.new(device_.devid_, -1001, 1, 2, 71);
cmd.params_[30] = volume.to_s
SendCommand(cmd);
when 'PWR'
case avrvalue
when '1'
log('power changed: off');
cmd.params_[10] = "0";
when '2'
log('power changed: on');
cmd.params_[10] = "1";
end
cmd = Command.new(device_.devid_, -1001, 1, 2, 48);
SendCommand(cmd);
else
log('not handling command: ' + avrcommand.to_s())
end
end

### END OF #350
rock your home - http://www.agocontrol.com home automation

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Marantz SR over RS232
« Reply #9 on: February 11, 2008, 01:40:47 pm »
Hi,

I'm still in some kind of passive state regarding template for Marantz. I talked to guys and the main advice was to wait for 710 release and rewrite template and check it in...

I'm also happy cause I see that Hari is contributing a lot of stuff for this template. I guess we all will merge efforts in one template.

But I have one question for more experienced GSD guys :

1. how to treat more parameters in gsd code ? :
for instance I have volume up/down commands implemented with simple Ruby snippets : <$"@VOL:2\r"$>
But DCE command includes also parameter for repeat and it seems like end device is responsible for handling it
Quote
/usr/pluto/bin/MessageSend localhost 0 SR5600_ID 1 90 72 ""
How to parse this incoming parameter in Ruby snippet for Vol up Command that is currently <$"@VOL:2\r"$> ?

Major questions regarding Marantz template remained unanswered are :
- how to properly implement multiroom feature (option 1. separate commands for both zones, option2. having child device each for audio zone)
- how to add child device properly to audio zone/room or whatever ?
- can child devices mentioned above be in different rooms ?


Thanks in advance,

regards,

Bulek.
Thanks in advance,

regards,

Bulek.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Marantz SR over RS232
« Reply #10 on: February 11, 2008, 05:09:02 pm »
Hi,

I'm still in some kind of passive state regarding template for Marantz. I talked to guys and the main advice was to wait for 710 release and rewrite template and check it in...

I'm also happy cause I see that Hari is contributing a lot of stuff for this template. I guess we all will merge efforts in one template.

But I have one question for more experienced GSD guys :

1. how to treat more parameters in gsd code ? :
for instance I have volume up/down commands implemented with simple Ruby snippets : <$"@VOL:2\r"$>
But DCE command includes also parameter for repeat and it seems like end device is responsible for handling it
Quote
/usr/pluto/bin/MessageSend localhost 0 SR5600_ID 1 90 72 ""
How to parse this incoming parameter in Ruby snippet for Vol up Command that is currently <$"@VOL:2\r"$> ?

Major questions regarding Marantz template remained unanswered are :
- how to properly implement multiroom feature (option 1. separate commands for both zones, option2. having child device each for audio zone)
- how to add child device properly to audio zone/room or whatever ?
- can child devices mentioned above be in different rooms ?


Thanks in advance,

regards,

Bulek.


Hi Bulek,

I'd handle that scenario with a bit of code:

from that snippet, your parsing a cmd 90 with param72 = "" ( I assume )
in Ruby, you simply do:
if cmd_ = "90"
  @myvalue = cmd_.params_[72]
end
HTH,

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Marantz SR over RS232
« Reply #11 on: February 12, 2008, 08:49:29 am »
Hi,

I have put this code into ruby code rectangle for Set Volume command #313 Set Volume :
Quote
level = cmd_.params_[76]
conn_.Send("@VOL:0"+level+"\r");
log("Sending Marantz : Set Volume Level to "+level+" : @VOL:0"+level+"\r")
#<$"@VOL:0xxx\r"$>


and then fired this :
Quote
/usr/pluto/bin/MessageSend localhost 290 60 1 313 76 "-15"

and I got in log :
Quote
753:05   02/12/08 8:51:22.857      GSDMessageTranslator isCmdImplemented = true <0xb606cb90>
05   02/12/08 8:51:22.857      #### Pre-Process Queue = 1 <0xb606cb90>
05   02/12/08 8:51:22.907      _QueueProc Pre - 313 : 0 <0xb786fb90>
05   02/12/08 8:51:22.907      GSD-Sleep Pre 313 : 0 <0xb786fb90>
05   02/12/08 8:51:22.907      Process Queue = 1 <0xb786fb90>
05   02/12/08 8:51:23.071      Parameter: -15 <0xb506ab90>
01   02/12/08 8:51:23.071      Error while calling method: Cannot call class method: cmd_313
error: undefined local variable or method `cmd_' for #<Device_60:0xb48441bc>, line: 332
backtrace:
   in: (eval): 332
   from (eval):332:in `cmd_313'
 <0xb506ab90>
01   02/12/08 8:51:23.071      For obscure reasons could not handle the message <0xb506ab90>
05   02/12/08 8:51:23.323      GSD-Sleep Post 313 : 250 <0xb786fb90>
05   02/12/08 8:51:23.323      _QueueProc Post - 313 : 250 <0xb786fb90>


Code snippet from log :
Quote
329:#### 313 ####################################################################
 330:def cmd_313(level, cmd=nil)
 331:@returnParamArray.clear
 332:level = cmd_.params_[76]
 333:conn_.Send("@VOL:0"+level+"\r");
 334:log("Sending Marantz : Set Volume Level to "+level+" : @VOL:0"+level+"\r")
 335:#conn_.Send("@VOL:0xxx\r")
 336:
 337:
 338:return @returnParamArray
 339:end

I must be missing something obvious...

Thanks in advance,

regards,

Bulek.
« Last Edit: February 12, 2008, 08:55:15 am by bulek »
Thanks in advance,

regards,

Bulek.

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: Marantz SR over RS232
« Reply #12 on: February 12, 2008, 09:32:04 am »
try "cmd" instead of "cmd_".

best regards,
Hari
rock your home - http://www.agocontrol.com home automation

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Marantz SR over RS232
« Reply #13 on: February 12, 2008, 11:10:19 pm »
Yes, That's it.
line 330 shows the parameter being passed is cmd, with a default value of nil
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

alx9r

  • Guru
  • ****
  • Posts: 187
    • View Profile
Re: Marantz SR over RS232
« Reply #14 on: June 21, 2008, 04:42:13 pm »
Hello fellow Marantz SR users,
I've got an SR7500 that I've been tinkering with.  I was wondering if the "SR Series RS232" device template that shipped with 0710RC1 is up-to-date.  Here's what I have found about that template:
  • Some of the code in the Ruby rectangles is conspicuously less sophisticated than what is described in this thread.  For example, volume control just the straightforward <$"@VOL:2\r"$> style. 
  • the template doesn't have any av inputs.
  • something in that template causes video and music to stop playing immediately after it starts (you hear audio for about 1/4 second)

I have started to build my own SR Series template and have a simple implementation working so that the receiver turns on and off and the volume and inputs can be controlled.  I suspect, however, that someone out there has a better template for the SR series.  If so, can you share it with me somehow?

Cheers,

Alex