Module: EventMachine
- Defined in:
- lib/em-serialport/connection.rb,
lib/em-serialport/serial_port.rb
Defined Under Namespace
Classes: Connection, SerialPort
Class Method Summary
collapse
Class Method Details
.connect_serial(dev, baud, databits, stopbits, parity) ⇒ Object
3
4
5
|
# File 'lib/em-serialport/serial_port.rb', line 3
def connect_serial(dev, baud, databits, stopbits, parity)
SerialPort.open(dev, baud, databits, stopbits, parity).uuid
end
|
.open_serial(dev, baud, databits, stopbits, parity, handler = nil) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/em-serialport/serial_port.rb', line 8
def EventMachine::open_serial(dev, baud, databits, stopbits, parity, handler=nil)
klass = if(handler and handler.is_a?(Class))
handler
else
Class.new(Connection) {handler and include handler}
end
uuid = connect_serial(dev, baud, databits, stopbits, parity)
connection = klass.new uuid
@conns[uuid] = connection
block_given? and yield connection
connection
end
|