Class: Fluent::Plugin::SerialPortInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::SerialPortInput
- Defined in:
- lib/fluent/plugin/in_serialport.rb
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
16 17 18 19 |
# File 'lib/fluent/plugin/in_serialport.rb', line 16 def configure(conf) super @device = device end |
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fluent/plugin/in_serialport.rb', line 32 def run loop do unless @serial.closed? begin timenow = @include_time ? Time.now.to_s << ' ' : '' data = {@device => timenow << @serial.readline(@eol)} router.emit(@tag, Engine.now, data) rescue $stderr.puts(caller) unless stopped? break end end end end |
#shutdown ⇒ Object
27 28 29 30 |
# File 'lib/fluent/plugin/in_serialport.rb', line 27 def shutdown @serial.close super end |
#start ⇒ Object
21 22 23 24 25 |
# 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 |