Difference between revisions of "Onkyo TXSR805"
From LinuxMCE
Line 4: | Line 4: | ||
Section: 193 Off<br> | Section: 193 Off<br> | ||
− | + | <$"!1PWR00\r"$> | |
− | <$"!1PWR00\r"$> | + | |
− | + | ||
Section: 192 On<br> | Section: 192 On<br> | ||
− | + | <$"!1PWR01\r"$> | |
− | <$"!1PWR01\r"$ | + | sleep(2) |
− | sleep(2) | + | <$"!AMT00\r"$> |
− | <$"!AMT00\r"$ | + | @mute = false |
− | @mute = false | + | |
− | + | ||
Section: 169 AM<br> | Section: 169 AM<br> | ||
− | < | + | <$"!1SLI25\r"$> |
− | <$"! | + | |
− | </ | + | |
+ | Section: 164 Aux<br> | ||
+ | <$"!1SLI03\r"$> | ||
+ | |||
+ | |||
+ | Section: 172 Aux 2<br> | ||
+ | <$"!1SLI04\r"$> | ||
+ | |||
+ | |||
+ | Section: 162 CD<br> | ||
+ | <$"!1SLI23\r"$> | ||
+ | |||
+ | |||
+ | Section: 165 DVD<br> | ||
+ | <$"!1SLI10\r"$> | ||
+ | |||
+ | |||
+ | Section: 170 FM<br> | ||
+ | <$"!1SLI24\r"$> | ||
+ | |||
+ | |||
+ | Section: 163 Phono<br> | ||
+ | <$"!1SLI22\r"$> | ||
+ | |||
+ | |||
+ | Section: 160 Tape / Tape 1<br> | ||
+ | <$"!1SLI20\r"$> | ||
+ | |||
+ | |||
+ | Section: 173 Tape 2<br> | ||
+ | <$"!1SLI21\r"$> | ||
+ | |||
+ | |||
+ | Section: 166 Tuner<br> | ||
+ | <$"!1SLI26\r"$> | ||
+ | |||
+ | |||
+ | Section: 909 XM<br> | ||
+ | <$"!1SLI31\r"$> | ||
+ | |||
+ | |||
+ | Section: 373 Private Method Listing<br> | ||
+ | # Written by Jason Bennett | ||
+ | # | ||
+ | # Process 373 - Methods | ||
+ | def receiveMsg | ||
+ | buff = conn_.Recv(7, 1000) | ||
+ | log("Message Received: #{buff}") | ||
+ | trash = conn_.Recv(1, 100) | ||
+ | if (buff.length() < 7) | ||
+ | parsed1 = "ERR" | ||
+ | parsed2 = "00" | ||
+ | else | ||
+ | parsed2 = buff[5].chr + buff[6].chr | ||
+ | parsed1 = buff[2].chr + buff[3].chr + buff[4].chr | ||
+ | return [parsed1, parsed2] | ||
+ | end | ||
+ | end | ||
+ | #-------------------------------------------- Parsing ----------------------------------------------------------------------------------- | ||
+ | def chkMsg(cat, opt) | ||
+ | case cat | ||
+ | # Power | ||
+ | when "PWR" | ||
+ | cmd = Command.new(device_.devid_, -1001, 1, 2, 48) # 48 = Power State | ||
+ | case opt | ||
+ | when "01" | ||
+ | cmd.params_[10] = "1" # Command 48, Param 10: 1 = On | ||
+ | when "00" | ||
+ | cmd.params_[10] = "0" # Command 48, Param 10: 2 = Off | ||
+ | end | ||
+ | SendCommand(cmd) | ||
+ | # Master Volume Level | ||
+ | when "MVL" | ||
+ | cmd = Command.new(device_.devid_, -1001, 1, 2, 71) # 71 = Volume | ||
+ | cmd.params_[30] = opt.hex.to_s # Command 71, Param 16 = Volume Level in Decimal | ||
+ | log("volume reported as: #{opt.hex.to_s}") | ||
+ | SendCommand(cmd) | ||
+ | # Input Selection | ||
+ | when "SLI" | ||
+ | cmd = Command.new(device_.devid_, -1001, 1, 2, 49) # 49 = Input Selection | ||
+ | case opt | ||
+ | when "00" | ||
+ | input_param = 316 | ||
+ | when "01" | ||
+ | input_param = 317 | ||
+ | when "02" | ||
+ | input_param = 318 | ||
+ | when "03" | ||
+ | input_param = 164 | ||
+ | when "04" | ||
+ | input_param = 172 | ||
+ | when "10" | ||
+ | input_param = 165 | ||
+ | when "20" | ||
+ | input_param = 160 | ||
+ | when "22" | ||
+ | input_param = 163 | ||
+ | when "23" | ||
+ | input_param = 162 | ||
+ | when "24" | ||
+ | input_param = 170 | ||
+ | when "25" | ||
+ | input_param = 169 | ||
+ | when "26" | ||
+ | input_param = 166 | ||
+ | when "31" | ||
+ | input_param = 909 | ||
+ | end | ||
+ | cmd.params_[41] = input_param.to_s() # Command 49, Param 41 = Input | ||
+ | SendCommand(cmd) | ||
+ | end | ||
+ | end | ||
+ | #-------------------------------------------- Logging ----------------------------------------------------------------------------------- | ||
+ | def log(line) | ||
+ | $log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a") | ||
+ | $log.puts "(***):" + line.to_s | ||
+ | $log.close | ||
+ | end | ||
+ | |||
+ | |||
+ | Section: 350 Process Incoming Data<br> | ||
+ | # Written by Jason Bennett | ||
+ | # | ||
+ | # Process 350 - Incoming | ||
+ | incMsg = receiveMsg() | ||
+ | log("New Msg: #{incMsg[0]}:#{incMsg[1]}") | ||
+ | chkMsg(incMsg[0], incMsg[1]) | ||
+ | |||
+ | |||
+ | Section: 355 Process Initialize<br> | ||
+ | #31-May-06 14:13 init Onkyo Receiver | ||
+ | initok=false | ||
+ | for iRetry in 0...4 | ||
+ | print "Initializing unit\n" | ||
+ | conn_.Send("!1PWRQSTN\r") | ||
+ | buf = conn_.Recv(200, 1000) | ||
+ | if( !buf.nil? && !buf.index("PWR0").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 | ||
+ | print "Initialized ok, doing log\n" | ||
+ | |||
+ | |||
+ | Section: 97 Mute<br> | ||
+ | if(@mute) | ||
+ | <$"!1AMT00\r"$> | ||
+ | else | ||
+ | <$"!1AMT01\r"$> | ||
+ | end | ||
+ | @mute=!@mute | ||
+ | |||
+ | |||
+ | Section: 313 Set Volume<br> | ||
+ | slevel = sprintf( "%x", level.to_i) | ||
+ | <$"!1MVL" + slevel + "\r"$> | ||
+ | SetDeviceDataInDB( device_.devid_, 158, level ) # 158 = DEVICEDATA_Volume_Level_CONST | ||
+ | print "volume and corresponding device data set\n" | ||
+ | |||
+ | |||
+ | Section: 90 Vol Down<br> | ||
+ | <$"!1MVLDOWN\r"$> | ||
+ | |||
+ | |||
+ | Section: 89 Vol Up<br> | ||
+ | <$"!1MVLUP\r"$> |
Revision as of 15:12, 18 June 2008
Using the Onkyo TX-SR805 with RS232 Control
Needs a lot of editing...
Section: 193 Off
<$"!1PWR00\r"$>
Section: 192 On
<$"!1PWR01\r"$> sleep(2) <$"!AMT00\r"$> @mute = false
Section: 169 AM
<$"!1SLI25\r"$>
Section: 164 Aux
<$"!1SLI03\r"$>
Section: 172 Aux 2
<$"!1SLI04\r"$>
Section: 162 CD
<$"!1SLI23\r"$>
Section: 165 DVD
<$"!1SLI10\r"$>
Section: 170 FM
<$"!1SLI24\r"$>
Section: 163 Phono
<$"!1SLI22\r"$>
Section: 160 Tape / Tape 1
<$"!1SLI20\r"$>
Section: 173 Tape 2
<$"!1SLI21\r"$>
Section: 166 Tuner
<$"!1SLI26\r"$>
Section: 909 XM
<$"!1SLI31\r"$>
Section: 373 Private Method Listing
# Written by Jason Bennett # # Process 373 - Methods def receiveMsg buff = conn_.Recv(7, 1000) log("Message Received: #{buff}") trash = conn_.Recv(1, 100) if (buff.length() < 7) parsed1 = "ERR" parsed2 = "00" else parsed2 = buff[5].chr + buff[6].chr parsed1 = buff[2].chr + buff[3].chr + buff[4].chr return [parsed1, parsed2] end end #-------------------------------------------- Parsing ----------------------------------------------------------------------------------- def chkMsg(cat, opt) case cat # Power when "PWR" cmd = Command.new(device_.devid_, -1001, 1, 2, 48) # 48 = Power State case opt when "01" cmd.params_[10] = "1" # Command 48, Param 10: 1 = On when "00" cmd.params_[10] = "0" # Command 48, Param 10: 2 = Off end SendCommand(cmd) # Master Volume Level when "MVL" cmd = Command.new(device_.devid_, -1001, 1, 2, 71) # 71 = Volume cmd.params_[30] = opt.hex.to_s # Command 71, Param 16 = Volume Level in Decimal log("volume reported as: #{opt.hex.to_s}") SendCommand(cmd) # Input Selection when "SLI" cmd = Command.new(device_.devid_, -1001, 1, 2, 49) # 49 = Input Selection case opt when "00" input_param = 316 when "01" input_param = 317 when "02" input_param = 318 when "03" input_param = 164 when "04" input_param = 172 when "10" input_param = 165 when "20" input_param = 160 when "22" input_param = 163 when "23" input_param = 162 when "24" input_param = 170 when "25" input_param = 169 when "26" input_param = 166 when "31" input_param = 909 end cmd.params_[41] = input_param.to_s() # Command 49, Param 41 = Input SendCommand(cmd) end end #-------------------------------------------- Logging ----------------------------------------------------------------------------------- def log(line) $log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a") $log.puts "(***):" + line.to_s $log.close end
Section: 350 Process Incoming Data
# Written by Jason Bennett # # Process 350 - Incoming incMsg = receiveMsg() log("New Msg: #{incMsg[0]}:#{incMsg[1]}") chkMsg(incMsg[0], incMsg[1])
Section: 355 Process Initialize
#31-May-06 14:13 init Onkyo Receiver initok=false for iRetry in 0...4 print "Initializing unit\n"
conn_.Send("!1PWRQSTN\r")
buf = conn_.Recv(200, 1000) if( !buf.nil? && !buf.index("PWR0").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 print "Initialized ok, doing log\n"
Section: 97 Mute
if(@mute) <$"!1AMT00\r"$> else <$"!1AMT01\r"$> end @mute=!@mute
Section: 313 Set Volume
slevel = sprintf( "%x", level.to_i) <$"!1MVL" + slevel + "\r"$> SetDeviceDataInDB( device_.devid_, 158, level ) # 158 = DEVICEDATA_Volume_Level_CONST print "volume and corresponding device data set\n"
Section: 90 Vol Down
<$"!1MVLDOWN\r"$>
Section: 89 Vol Up
<$"!1MVLUP\r"$>