Class: ComConnection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ComConnection

Returns a new instance of ComConnection.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/com_connection.rb', line 4

def initialize(args)
  @portname      = args[:portname]
  @databits      = args[:databits]       || default_databits
  @speed         = args[:speed]          || default_speed
  @parity        = args[:parity]         || default_parity
  @stopbits      = args[:stopbits]       || default_stopbits
  @flowcontrol   = args[:flowcontrol]    || default_flowcontrol
  @readtimeout   = args[:readtimeout]    || default_readtimeout
  @writetimeout  = args[:writetimeout]   || default_writetimeout
  @usereadbuffer = args[:usereadbuffer]  || default_usereadbuffer
end

Instance Attribute Details

#databitsObject (readonly)

Returns the value of attribute databits.



2
3
4
# File 'lib/com_connection.rb', line 2

def databits
  @databits
end

#flowcontrolObject (readonly)

Returns the value of attribute flowcontrol.



2
3
4
# File 'lib/com_connection.rb', line 2

def flowcontrol
  @flowcontrol
end

#parityObject (readonly)

Returns the value of attribute parity.



2
3
4
# File 'lib/com_connection.rb', line 2

def parity
  @parity
end

#portnameObject (readonly)

Returns the value of attribute portname.



2
3
4
# File 'lib/com_connection.rb', line 2

def portname
  @portname
end

#readtimeoutObject (readonly)

Returns the value of attribute readtimeout.



2
3
4
# File 'lib/com_connection.rb', line 2

def readtimeout
  @readtimeout
end

#speedObject (readonly)

Returns the value of attribute speed.



2
3
4
# File 'lib/com_connection.rb', line 2

def speed
  @speed
end

#stopbitsObject (readonly)

Returns the value of attribute stopbits.



2
3
4
# File 'lib/com_connection.rb', line 2

def stopbits
  @stopbits
end

#usereadbufferObject (readonly)

Returns the value of attribute usereadbuffer.



2
3
4
# File 'lib/com_connection.rb', line 2

def usereadbuffer
  @usereadbuffer
end

#writetimeoutObject (readonly)

Returns the value of attribute writetimeout.



2
3
4
# File 'lib/com_connection.rb', line 2

def writetimeout
  @writetimeout
end

Instance Method Details

#port_config_stringObject



16
17
18
# File 'lib/com_connection.rb', line 16

def port_config_string  
  "PortName=#{portname};DataBits=#{databits};Speed=#{speed};Parity=#{parity};StopBits=#{stopbits};FlowControl=#{flowcontrol};ReadTimeout=#{readtimeout};WriteTimeout=#{writetimeout};UseReadBuffer=#{usereadbuffer}"
end