Class: Calypso::SerialPortData

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

Overview

Serial port information wrapper.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port, baud = 9600, databits = 8, stopbits = 1, parity = SerialPort::NONE) ⇒ SerialPortData

Create a new serial port controller.

Parameters:

  • port (String)

    Path to the serial device.

  • baud (Fixnum) (defaults to: 9600)

    Serial baud rate.

  • databits (Fixnum) (defaults to: 8)

    Number of data bits per byte.

  • stopbits (Fixnum) (defaults to: 1)

    Number of stop bits.

  • parity (Symbol) (defaults to: SerialPort::NONE)

    Connection parity.



41
42
43
44
45
46
47
# File 'lib/calypso/serialportdata.rb', line 41

def initialize(port, baud = 9600, databits = 8, stopbits = 1, parity = SerialPort::NONE)
  @port = port
  @baud = baud
  @databits = databits
  @stopbits = stopbits
  @parity = parity
end

Instance Attribute Details

#baudFixnum (readonly)

Returns Serial baud rate.

Returns:

  • (Fixnum)

    Serial baud rate.



26
27
28
# File 'lib/calypso/serialportdata.rb', line 26

def baud
  @baud
end

#databitsFixnum (readonly)

Returns Number of data bits per byte.

Returns:

  • (Fixnum)

    Number of data bits per byte.



28
29
30
# File 'lib/calypso/serialportdata.rb', line 28

def databits
  @databits
end

#paritySymbol (readonly)

Returns Connection parity.

Returns:

  • (Symbol)

    Connection parity.



32
33
34
# File 'lib/calypso/serialportdata.rb', line 32

def parity
  @parity
end

#portString (readonly)

Returns Path to the serial device.

Returns:

  • (String)

    Path to the serial device.



24
25
26
# File 'lib/calypso/serialportdata.rb', line 24

def port
  @port
end

#stopbitsFixnum (readonly)

Returns Number of stop bits.

Returns:

  • (Fixnum)

    Number of stop bits.



30
31
32
# File 'lib/calypso/serialportdata.rb', line 30

def stopbits
  @stopbits
end