Module: OpenHAB::Core::IO::Transport::Serial::SerialPortManager

Includes:
Enumerable
Defined in:
lib/openhab/core/io/transport/serial/serial_port_manager.rb

Overview

Finds and opens ports through openHAB's serial infrastructure.

Instance Method Summary collapse

Methods included from Enumerable

#all_groups, #all_members, #command, #command!, #decrease, #down, #equipments, #fast_forward, #groups, #increase, #locations, #member_of, #members, #move, #next, #not_member_of, #not_tagged, #off, #on, #pause, #play, #points, #previous, #refresh, #rewind, #stop, #tagged, #toggle, #up, #update, #update!

Instance Method Details

#current_owner(name) ⇒ String?

Returns The port's reported owner.

Parameters:

  • name (String)

Returns:

  • (String, nil) —

    The port's reported owner.



43
44
45
# File 'lib/openhab/core/io/transport/serial/serial_port_manager.rb', line 43

def current_owner(name)
  get_identifier(name)&.current_owner
end

#each {|name| ... } ⇒ Enumerator, self

Enumerates discovered port names. Known names can also be opened even when their provider does not support discovery.

Yield Parameters:

  • name (String)

Returns:

  • (Enumerator, self)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/openhab/core/io/transport/serial/serial_port_manager.rb', line 18

def each
  return enum_for(__method__) unless block_given?

  identifiers = self.identifiers
  begin
    identifiers.for_each { |identifier| yield identifier.name }
  ensure
    identifiers.close
  end
  self
end

#names ⇒ Array<String>

Returns Discovered port names.

Returns:

  • (Array<String>) —

    Discovered port names.



31
32
33
# File 'lib/openhab/core/io/transport/serial/serial_port_manager.rb', line 31

def names
  to_a
end

#owned?(name) ⇒ Boolean

Returns Whether the port is owned (including by this process).

Parameters:

  • name (String)

Returns:

  • (Boolean) —

    Whether the port is owned (including by this process).



37
38
39
# File 'lib/openhab/core/io/transport/serial/serial_port_manager.rb', line 37

def owned?(name)
  get_identifier(name)&.currently_owned?
end