class Fluent::Plugin::SerialPortInput

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_serialport.rb, line 16
def configure(conf)
  super
  @device = device
end
run() click to toggle source
# File lib/fluent/plugin/in_serialport.rb, line 32
def run
  loop do
    break if @serial.closed?
    begin
      timenow = @include_time ? Time.now.to_s << ' ' : ''
      data = {@device => timenow << @serial.readline(@eol)}
      router.emit(@tag, Fluent::EventTime.now, data)
    rescue => ex
      log.warn(error: ex) unless stopped?
      break
    end
  end
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_serialport.rb, line 27
def shutdown
  @serial.close
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_serialport.rb, line 21
def start
  super
  @serial = SerialPort.new(@com_port, @baud_rate, 8, 1, SerialPort::NONE)
  thread_create(:in_serialport, &method(:run))
end

Private Instance Methods

device() click to toggle source
# File lib/fluent/plugin/in_serialport.rb, line 47
def device
  File.basename(@com_port).gsub(/\./,"_")
end