Module: XBee

Included in:
RFModule
Defined in:
lib/ruby_xbee.rb,
lib/module_config.rb,
lib/apimode/xbee_api.rb,
lib/apimode/at_commands.rb,
lib/apimode/frame/frame.rb,
lib/legacy/command_mode.rb,
lib/apimode/frame/at_command.rb,
lib/apimode/frame/modem_status.rb,
lib/apimode/frame/receive_packet.rb,
lib/apimode/frame/transmit_status.rb,
lib/apimode/frame/transmit_request.rb,
lib/apimode/frame/at_command_response.rb,
lib/apimode/frame/explicit_rx_indicator.rb,
lib/apimode/frame/remote_command_request.rb,
lib/apimode/frame/remote_command_response.rb,
lib/apimode/frame/explicit_addressing_command.rb

Defined Under Namespace

Modules: ATCommands, Config, Frame Classes: BaseAPIModeInterface, BaseCommandModeInterface, RFModule, Series1APIModeInterface, Series2APIModeInterface, XBeeV1CommandModeInterface, XBeeV2CommandModeInterface

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(xbee_usbdev_str, baud, data_bits, stop_bits, parity) ⇒ Object

supports legacy API, command-mode interface



44
45
46
47
# File 'lib/ruby_xbee.rb', line 44

def XBee.new( xbee_usbdev_str, baud, data_bits, stop_bits, parity )
  require 'legacy/command_mode'
  BaseCommandModeInterface.new(xbee_usbdev_str, baud, data_bits, stop_bits, parity)
end

Instance Method Details

#getresults(sp, echo = true) ⇒ Object

a method for getting results from any Ruby SerialPort object. Not ideal, but seems effective enough.



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ruby_xbee.rb', line 51

def getresults( sp, echo = true )
  results = ""
  while (c = sp.getc) do
    if ( !echo.nil? && echo )
      putc c
    end
    results += "#{c.chr}"
  end

  # deal with multiple lines
  results.gsub!( "\r", "\n")
end