Author Topic: Help with some ruby GSD code for an AV power switch device  (Read 5717 times)

chrisbirkinshaw

  • Guru
  • ****
  • Posts: 431
    • View Profile
Help with some ruby GSD code for an AV power switch device
« on: June 12, 2009, 11:09:49 pm »
I wonder if anyone can tell me what is wrong here?

I am trying to make a device which you can configure with the device id of an X10 or zwave module which will control the power to your AV rack (amps, TV, etc). The idea is that you connect audio and/or video pipes to it and the on/off code turns the power switch on/off.

The error I get is a bit confusing when the ruby code is run... "For obscure reasons could not handle the message <0xb57b4b90>"

Below is the code and the error message:

Code: [Select]
RCODE:
   0:require 'Ruby_Generic_Serial_Device'
   1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
   2:end
   3:class Device_128 < Ruby_Generic_Serial_Device::RubySerialWrapper
   4:#### 192 ####################################################################
   5:def cmd_192(pk_pipe, pk_device_pipes, cmd=nil)
   6:@returnParamArray.clear
   7:target = device_.devdata_[278]
   8:priority = 1
   9:type = 1
  10:command = 192
  11:log('Turning on device: ' + target.to_s)
  12:cmd = Command.new(target, target,  priority, type, command)
  13:SendCommand(cmd)
  14:return @returnParamArray
  15:end
  16:#### 193 ####################################################################
  17:def cmd_193(pk_pipe, cmd=nil)
  18:@returnParamArray.clear
  19:target = device_.devdata_[278]
  20:priority = 1
  21:type = 1
  22:command = 193
  23:log('Turning off device: ' + target.to_s)
  24:cmd = Command.new(target, target,  priority, type, command)
  25:SendCommand(cmd)
  26:return @returnParamArray
  27:end
  28:#### PRIVATE METHODS ####################################################################
  29:  def log(line)
  30:          $log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a")
  31:    logTime = Time.now
  32:    timeStr = logTime.strftime("%d-%m-%Y  %H:%M:%S  ")
  33:    $log.puts timeStr + "(***):" + line.to_s
  34:          $log.close
  35:  end
  36:#### START SETTERS ####################################################################
  37:def initialize()
  38:super
  39:@returnParamArray=Array.new
  40:end
  41:####  END  SETTERS ####################################################################
  42:end
 44:05 06/12/09 22:08:12.099 GSDMessageTranslator isCmdImplemented = true <0xb5fb5b90>
05 06/12/09 22:08:12.099 #### Pre-Process Queue = 1 <0xb5fb5b90>
05 06/12/09 22:08:12.102 GSDMessageTranslator isCmdImplemented = false <0xb5fb5b90>
05 06/12/09 22:08:12.123 GSDMessageTranslator isCmdImplemented = false <0xb5fb5b90>
05 06/12/09 22:08:12.123 #### Pre-Process Queue = 2 <0xb5fb5b90>
05 06/12/09 22:08:12.123 _QueueProc Pre - 192 : 0 <0xb77b8b90>
05 06/12/09 22:08:12.123 GSD-Sleep Pre 192 : 0 <0xb77b8b90>
05 06/12/09 22:08:12.123 Process Queue = 1 <0xb77b8b90>
05 06/12/09 22:08:12.132 GSDMessageTranslator isCmdImplemented = true <0xb5fb5b90>
05 06/12/09 22:08:12.132 #### Pre-Process Queue = 2 <0xb5fb5b90>
05 06/12/09 22:08:12.133 GSDMessageTranslator isCmdImplemented = false <0xb5fb5b90>
05 06/12/09 22:08:12.133 #### Pre-Process Queue = 3 <0xb5fb5b90>
05 06/12/09 22:08:12.136 Parameter:  <0xb57b4b90>
05 06/12/09 22:08:12.136 Parameter:  <0xb57b4b90>
12-06-2009  22:08:12  (***):Turning on device: 51
01 06/12/09 22:08:12.138 Error while calling method: Cannot call class method: cmd_192
error: No matching function for overloaded 'new_RubyCommandWrapper', line: 12
backtrace:
in: (eval): 12
from (eval):12:in `initialize'
from (eval):12:in `new'
from (eval):12:in `cmd_192'
 <0xb57b4b90>
01 06/12/09 22:08:12.138 For obscure reasons could not handle the message <0xb57b4b90>

Thanks in advance,

Chris

« Last Edit: June 13, 2009, 01:34:16 pm by chrisbirkinshaw »

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Help with some ruby GSD code for an AV power switch device
« Reply #1 on: June 14, 2009, 05:04:14 pm »
Looks to me like the receiving device's template (power amp) doesn't handle that command.

You get that message when you send a command to a device and the command isn't implemented.

Can you post the GSD code of the amp? (if it's GSD)

Best Regards,

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.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Help with some ruby GSD code for an AV power switch device
« Reply #2 on: June 14, 2009, 09:22:13 pm »
I remember now,

the device's state is the same as you are setting it to.

try this:

device_.devdata_[120]="1"

devdata 120 is retransmit.  Long story, but because Ruby code is stored in the IR table, DCERouter tries to be 'smart', and if the device is already on, it won't send the command to turn it on again.

This is by design, for devices that have toggles.  ie, a remote control that has a POWER button. (press once to turn on, press again to turn off)

Looks to me that you also have some minor programming issues.

cmd = Command.new(target, target,  priority, type, command)

doesn't work.  Try this instead:
mycmd = Command.new(from, to, priority, type, command)
mycmd.devdata_[120] = "1"

SendCommand(mycmd)



"cmd" is reserved in Ruby.  that's the command received, iirc

Good luck,

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.

chrisbirkinshaw

  • Guru
  • ****
  • Posts: 431
    • View Profile
Re: Help with some ruby GSD code for an AV power switch device
« Reply #3 on: June 28, 2009, 08:30:40 pm »
Still get the same error. As a test I tried this:
Code: [Select]
   4:#### 192 ####################################################################
   5:def cmd_192(pk_pipe, pk_device_pipes, cmd=nil)
   6:@returnParamArray.clear
   7:log('Turning off device: ' + device_.devdata_[278].to_s)
   8:#switch('192')
   9:
  10:from = "128"
  11:to = "128"
  12:priority = "1"
  13:type = "1"
  14:command = "192"
  15:
  16:mycmd = Command.new(from, to, priority, type, command)
  17:mycmd.devdata_[120] = "1"
  18:
  19:SendCommand(mycmd)
  20:return @returnParamArray
  21:end
)

i.e. the exact code copy/pasted from above

and I get the same error:
Code: [Select]
01 06/28/09 19:25:23.801 Error while calling method: Cannot call class method: cmd_192
error: No matching function for overloaded 'new_RubyCommandWrapper', line: 16
backtrace:
in: (eval): 16
from (eval):16:in `initialize'
from (eval):16:in `new'
from (eval):16:in `cmd_192'
 <0xb584bb90>


I created the template by adding a new GSD device template then ticking the Ruby Internal Commands and the Standard Receiver Commands.

Thanks,

Chris


ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Help with some ruby GSD code for an AV power switch device
« Reply #4 on: July 11, 2009, 08:09:03 pm »
Still get the same error. As a test I tried this:
Code: [Select]
   4:#### 192 ####################################################################
   5:def cmd_192(pk_pipe, pk_device_pipes, cmd=nil)
   6:@returnParamArray.clear
   7:log('Turning off device: ' + device_.devdata_[278].to_s)
   8:#switch('192')
   9:
  10:from = "128"
  11:to = "128"
  12:priority = "1"
  13:type = "1"
  14:command = "192"
  15:
  16:mycmd = Command.new(from, to, priority, type, command)
  17:mycmd.devdata_[120] = "1"
  18:
  19:SendCommand(mycmd)
  20:return @returnParamArray
  21:end
)

i.e. the exact code copy/pasted from above

and I get the same error:
Code: [Select]
01 06/28/09 19:25:23.801 Error while calling method: Cannot call class method: cmd_192
error: No matching function for overloaded 'new_RubyCommandWrapper', line: 16
backtrace:
in: (eval): 16
from (eval):16:in `initialize'
from (eval):16:in `new'
from (eval):16:in `cmd_192'
 <0xb584bb90>


I created the template by adding a new GSD device template then ticking the Ruby Internal Commands and the Standard Receiver Commands.

Thanks,

Chris


Chris:
The values your passing are strings.  They need to be int's.
  10:from = 128
  11:to = 128
  12:priority = 1
  13:type = 1
  14:command = 192
  15:
  16:mycmd = Command.new(from, to, priority, type, command)
  17:mycmd.devdata_[120] = "1"
  18:
  19:SendCommand(mycmd)
  20:return @returnParamArray
  21:end

Try that, that sould work.  The devdata_[120] is a string.

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.