Class: Z4box::Iot

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

Overview

generic iot io class.

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ Iot

Returns a new instance of Iot.



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/z4box.rb', line 136

def initialize p
  @sp = SerialPort.new(p, 115200, 8, 1, SerialPort::NONE)
  #just read forever
  Process.detach( fork {
                    while true do
                      while (i = @sp.gets.chomp) do
                        puts %[#{i}]
                      end
                    end
                  } )
end

Instance Method Details

#<<(i) ⇒ Object



147
148
149
# File 'lib/z4box.rb', line 147

def << i
  @sp.puts(i)
end