Class: Bertha

Inherits:
Object
  • Object
show all
Defined in:
lib/bertha.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port, speed = 9600) ⇒ Bertha

Returns a new instance of Bertha.



5
6
7
8
9
# File 'lib/bertha.rb', line 5

def initialize port, speed = 9600
  @serial = SerialPort.new port, speed, 8, 1
  @serial.read_timeout = 200
  @serial.read
end

Class Method Details

.open(port, speed) {|bertha| ... } ⇒ Object

Yields:

  • (bertha)


15
16
17
18
19
# File 'lib/bertha.rb', line 15

def Bertha.open port, speed
  bertha = Bertha.new port, speed
  yield bertha
  bertha.close
end

Instance Method Details

#closeObject



11
12
13
# File 'lib/bertha.rb', line 11

def close
  @serial.close
end

#versionObject



21
22
23
24
# File 'lib/bertha.rb', line 21

def version
  @serial.puts 'version'
  @serial.gets.chomp
end