class UdooNeoRest::Export
Public Instance Methods
export_gpio(gpio, mode = :export)
click to toggle source
Export
using the gpio
gpio : the gpio to be exported
# File lib/udooneorest/export.rb, line 60 def export_gpio(gpio, mode = :export) # lets make sure the gpio is good gpio_ = ValidateGpio.new gpio return gpio_.error_message unless gpio_.valid? # send the command result = UdooNeoRest::Base.echo gpio, "#{BASE_PATH}#{'un' if mode == :unexport}export" # return ok if all is well return UdooNeoRest::Base.status_ok if result.empty? # provide some constructive feedback on the root cause of this specific error if result =~ /resource busy/ return UdooNeoRest::Base.status_error('Resource Busy error occurred. Maybe the gpio has already been exported. It only needs to be exported once.') end # otherwise just return the error UdooNeoRest::Base.status_error(result) end
export_pin(pin, mode = :export)
click to toggle source
Export
using the pin
pin : the pin to be exported
# File lib/udooneorest/export.rb, line 45 def export_pin(pin, mode = :export) # Validate the pin pin_ = ValidatePin.new pin return pin_.error_message unless pin_.valid? # Export the value after translating to gpio export_gpio pin_.to_gpio, mode end