Module: ObjectOrientedBeagleboneBlack::UartMappings

Included in:
UartConnection
Defined in:
lib/object_oriented_beaglebone_black/uart_mappings.rb

Constant Summary collapse

ID_TELETYPE_DEVICE_PATH_MAPPING =
{ "UART0" => "/dev/ttyO0", "UART1" => "/dev/ttyO1", "UART2" => "/dev/ttyO2", "UART3" => "/dev/ttyO3", "UART4" => "/dev/ttyO4", "UART5" => "/dev/ttyO5" }

Instance Method Summary collapse

Instance Method Details

#load_uarts_arrayObject



9
10
11
# File 'lib/object_oriented_beaglebone_black/uart_mappings.rb', line 9

def load_uarts_array
  ::OBJECT_ORIENTED_BEAGLEBONE_BLACK_UARTS_HASH ||= JSON.load(File.read(File.join(OBJECT_ORIENTED_BEAGLEBONE_BLACK_ROOT, "config", "uarts.json")))["uarts"]
end

#property_hash(id: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/object_oriented_beaglebone_black/uart_mappings.rb', line 13

def property_hash(id: nil)
  load_uarts_array

  uart_hash = {}

  if !id.nil?
    teletype_device_path = ID_TELETYPE_DEVICE_PATH_MAPPING[id]
    uart_hash = ::OBJECT_ORIENTED_BEAGLEBONE_BLACK_UARTS_HASH[teletype_device_path]
    uart_hash["teletype_device_path"] = teletype_device_path
  end

  uart_hash

end