Author Topic: GSD syntax error outside of my code  (Read 3725 times)

JoakimL

  • Veteran
  • ***
  • Posts: 149
    • View Profile
GSD syntax error outside of my code
« on: January 24, 2011, 09:52:28 pm »
I've got a Ruby problem, and I cannot see how to mend it. I get:

(eval):3: syntax error, unexpected $end, line: 3

And since line 3 is outside of my control I really don't know what to do.

Line 3 : class Device_120 < Ruby_Generic_Serial_Device::RubySerialWrapper

I get this for the two device templates I'm experimenting with at the moment.

Any pointers or clues?


/Joakim

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: GSD syntax error outside of my code
« Reply #1 on: January 24, 2011, 10:39:08 pm »
Please post your GSD code.

JoakimL

  • Veteran
  • ***
  • Posts: 149
    • View Profile
Re: GSD syntax error outside of my code
« Reply #2 on: January 25, 2011, 08:53:34 am »
It's actually nothing much to it. Strange thing is it worked Sunday morning and without me doing anything (well, at least I'm not aware of changing anything related to this device template) I got the error.

Here's the code:

# #373 Private Method Listing
#
#

def log(line)
# This function logs a line to the log file of the device
log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a")
log.puts Time.now.to_s + " (Ruby script):" + line.to_s
log.close
end

###


# #384 Process Receive Command For Child
#
#

cmdId = cmd.id_ # Command ID: ON, OFF, SET LEVEL
cmdTo = cmd.devidto_ # Device ID in LinuxMCE
devPort = device_.childdevices_[cmdTo].devdata_[12] # 12 contains a port/channel
childType = device_.childdevices_[cmdTo].devtemplid_ # Template ID to know type of device: switch or dimmer
level = 0

log ("Command received for port " + devPort)

case cmdId
when 192 # ON
system('tdtool --on ' + devPort)
log ("Device set to ON")

when 193 # OFF
system('tdtool --off ' + devPort)
log ("Device set to OFF")

when 184 # Change level of dimmer
level = cmd.params_[76].to_i*255/100
system('tdtool --dimlevel ' + level.to_s + ' --dim ' + devPort)
log ("Dim level set to " + level.to_s)
end

###