LinuxMCE Forums

General => Developers => Topic started by: hari on January 13, 2008, 03:24:42 am

Title: Marantz SR over RS232
Post by: hari 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.
Title: Re: Marantz SR over RS232
Post by: bulek 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.
Title: Re: Marantz SR over RS232
Post by: hari 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
Title: Re: Marantz SR over RS232
Post by: ddamron 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!
Title: Re: Marantz SR over RS232
Post by: hari 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
Title: Re: Multiroom (Marantz SR over RS232)
Post by: hari 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
Title: Re: Multiroom (Marantz SR over RS232)
Post by: bulek 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.
 
Title: Re: Marantz SR over RS232
Post by: ddamron 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
Title: Re: Marantz SR over RS232
Post by: hari 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
Title: Re: Marantz SR over RS232
Post by: bulek 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.
Title: Re: Marantz SR over RS232
Post by: ddamron 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
Title: Re: Marantz SR over RS232
Post by: bulek 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.
Title: Re: Marantz SR over RS232
Post by: hari on February 12, 2008, 09:32:04 am
try "cmd" instead of "cmd_".

best regards,
Hari
Title: Re: Marantz SR over RS232
Post by: ddamron 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
Title: Re: Marantz SR over RS232
Post by: alx9r 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:

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
Title: Re: Marantz SR over RS232
Post by: hari on June 21, 2008, 07:09:01 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)

the code was updated in later releases. But I can confirm that video/music stop playing problem. Dunno where it comes from..

best regards,
Hari
Title: Re: Marantz SR over RS232
Post by: colinjones on June 22, 2008, 12:50:15 am
Hari - pls pls pls can you comment on when the pnp script for this template will be available? I just don't seem to have any luck setting up the template manually - can't even get it to communicate, can't get the pipes working properly, etc. Although after tinkering for a while once, I started noticing that the SR6001 was periodically turning itself off when I wasn't around, so I assume something was getting through, but it certainly wasn't "controlling" it. Will the pnp script be pushed out in an update? Does it already exist somewhere i can download and execute manually?
Title: Re: Marantz SR over RS232
Post by: alx9r on June 22, 2008, 03:16:06 am
Hari - Thanks for confirming the video/music stop playing problem.  I'll try to track it down or roll my own SR series template. 

colinjones - once I get my SR7500 working completely, I'll post my steps in my sample setup wiki page here:

http://wiki.linuxmce.org/index.php/Alx9r%27s_Sample_Setup

Hopefully that will help you along if you don't find a solution before then.

Cheers,

Alex
Title: Re: Marantz SR over RS232
Post by: colinjones on June 22, 2008, 05:46:28 am
Thanks heaps alx9r! Just out of interest, I have a:

ATEN International Co., Ltd UC-232A Serial Port [pl2303]

USB to serial converter to connect to the Marantz and can see it using lsusb, do you use something similar? Did you need a null modem converter? It doesn't seem likely I need one if there was even 2 instances were something switched off the amp within 24 hours of me setting up the template when it has never done that before in the 6 months I have owned it - so I assume it is able to communicate, just the template isn't working in the way I have set it up... but worth asking just in case!
Title: Re: Marantz SR over RS232
Post by: alx9r on June 22, 2008, 04:35:38 pm
Hi colinjones,
I use breakout cables from my motherboard, so I don't have that layer of complication.  I had the backpanel space and I found them to be cheaper.

To control my SR7500 you need a DB9 female to DB9 female straight through (i.e. NOT Nullmodem) cable.  This is an uncommon cable.  The easiest way I was able to accomplish it was to use a DB9 female to DB9 male extension cable (which is straight through) and a DB9 female to DB9 female gender mender.

I also recommend testing the serial connection separately by connecting to the receiver using a terminal program and typing commands manually, like I did here for my Aquos TV:
http://wiki.linuxmce.org/index.php/Alx9r%27s_Aquos_TV_Setup#Setting_TV_to_Respond_to_Power_On_Commands

You should be able to turn the receiver off and on over the serial cable by typing in the terminal window.

You'll need to use the commands for your receiver instead of course which you can find on Marantz's product page for your receiver.

HTH,

Alex
Title: Re: Marantz SR over RS232
Post by: bulek on June 23, 2008, 07:36:48 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

Hi,

here's something I'm working on, but beware it's for multiroom feature enabled (basically you split amplifier in two zones by this template/code):
http://wiki.linuxmce.org/index.php/User:Bulek (http://wiki.linuxmce.org/index.php/User:Bulek)

Regards,

Bulek.
Title: Re: Marantz SR over RS232
Post by: alx9r on June 23, 2008, 08:55:36 pm
Hi,

here's something I'm working on, but beware it's for multiroom feature enabled (basically you split amplifier in two zones by this template/code):
http://wiki.linuxmce.org/index.php/User:Bulek (http://wiki.linuxmce.org/index.php/User:Bulek)

Regards,

Bulek.

Thanks for posting that Bulek.  Looks like it will be pretty useful to me.  How well is it working?

As a side question: Do you edit the code in those ruby rectangles on the various admin pages, or is there consolidated place where changes can be made to those commands?  I was thinking there might be a way to load code for all of the commands from a text file somehow.

Regards,

Alex
Title: Re: Marantz SR over RS232
Post by: bulek on June 24, 2008, 08:21:34 am
Hi,

here's something I'm working on, but beware it's for multiroom feature enabled (basically you split amplifier in two zones by this template/code):
http://wiki.linuxmce.org/index.php/User:Bulek (http://wiki.linuxmce.org/index.php/User:Bulek)

Regards,

Bulek.

Thanks for posting that Bulek.  Looks like it will be pretty useful to me.  How well is it working?

As a side question: Do you edit the code in those ruby rectangles on the various admin pages, or is there consolidated place where changes can be made to those commands?  I was thinking there might be a way to load code for all of the commands from a text file somehow.

Regards,

Alex


Hi,

I have yet to try it.... I'm editing codes in rectangles (don't know for any other, better way)....

Will let you know - will also update Wiki page after that...

Regards,

Bulek.
Title: Re: Marantz SR over RS232
Post by: dh on April 13, 2012, 02:23:39 am
Did anyone get this Marantz interface working?  I'm considering purchasing a Marantz receiver and was hoping that it was now supported...
Title: Re: Marantz SR over RS232
Post by: hari on April 13, 2012, 09:30:24 pm
it works fine when you remove the part from the GSD that emits events.
Title: Re: Marantz SR over RS232
Post by: dh on April 16, 2012, 01:24:45 am
it works fine when you remove the part from the GSD that emits events.

I don't understand that response.  I guess I'll look into it and see if I can get it working.

D
Title: Re: Marantz SR over RS232
Post by: bulek on April 16, 2012, 08:56:42 am
Hi,

I have it working under Dianemo with whisperer Perl script. But I guess this is not of much help for you....
Selecting all those inputs in template is too much work, Dianemo has a bit easier system, but you have to know more to use it...


Regards,

Bulek.