Class: UdooNeoRest::Export
- Inherits:
-
Sinatra::Application
- Object
- Sinatra::Application
- UdooNeoRest::Export
- Defined in:
- lib/udooneorest/export.rb
Instance Method Summary collapse
-
#export_gpio(gpio, mode = :export) ⇒ Object
Export using the gpio.
-
#export_pin(pin, mode = :export) ⇒ Object
Export using the pin.
Instance Method Details
#export_gpio(gpio, mode = :export) ⇒ Object
Export using the gpio
gpio : the gpio to be exported
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# 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_. 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) ⇒ Object
Export using the pin
pin : the pin to be exported
45 46 47 48 49 50 51 52 53 |
# File 'lib/udooneorest/export.rb', line 45 def export_pin(pin, mode = :export) # Validate the pin pin_ = ValidatePin.new pin return pin_. unless pin_.valid? # Export the value after translating to gpio export_gpio pin_.to_gpio, mode end |