A
Adam Block
I'm trying to create a singleton serial port class with the following
code:
require 'serialport' # version 0.6
require 'singleton'
class SerialConnection < SerialPort
include Singleton
def initialize
sp = super("/dev/tty.KeySerial1", 9600, 8, 1, 0)
end
end
But when I try to create the instance it breaks:
irb(main):009:0> sp = SerialConnection.instance
ArgumentError: wrong number of arguments (0 for 1)
from (irb):8:in `new'
from (irb):8:in `new'
from /usr/local/lib/ruby/1.8/singleton.rb:95:in `instance'
from (irb):9
But this works fine:
irb(main):010:0> sp = SerialPort.new("/dev/tty.KeySerial1", 9600, 8, 1,
0)
=> #<SerialPort:0x3251fc>
Any ideas? This used to work, but now it doesn't, and I can't for the
life of me figure out what changed.
Thanks!
/afb
code:
require 'serialport' # version 0.6
require 'singleton'
class SerialConnection < SerialPort
include Singleton
def initialize
sp = super("/dev/tty.KeySerial1", 9600, 8, 1, 0)
end
end
But when I try to create the instance it breaks:
irb(main):009:0> sp = SerialConnection.instance
ArgumentError: wrong number of arguments (0 for 1)
from (irb):8:in `new'
from (irb):8:in `new'
from /usr/local/lib/ruby/1.8/singleton.rb:95:in `instance'
from (irb):9
But this works fine:
irb(main):010:0> sp = SerialPort.new("/dev/tty.KeySerial1", 9600, 8, 1,
0)
=> #<SerialPort:0x3251fc>
Any ideas? This used to work, but now it doesn't, and I can't for the
life of me figure out what changed.
Thanks!
/afb