Sha256: 3bbc6a1646f93fd9c867eb8e6493e080839c628c3b335b4065ef29e61c6e31db

Contents?: true

Size: 542 Bytes

Versions: 10

Compression:

Stored size: 542 Bytes

Contents

module ArduinoFirmata

  def self.list
    Dir.entries('/dev').grep(/tty\.?(usb|acm)/i).map{|fname| "/dev/#{fname}"}
  end

  def self.connect(serial_name=nil, params={}, &block)
    serial_name = self.list[0] unless serial_name
    raise Error.new 'Arduino not found' unless serial_name
    Params.default.each do |k,v|
      params[k] = v unless params[k]
    end

    arduino = Arduino.new serial_name, params

    unless block_given?
      return arduino
    else
      arduino.instance_eval &block
      arduino.close
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
arduino_firmata-0.3.7 lib/arduino_firmata/main.rb
arduino_firmata-0.3.6 lib/arduino_firmata/main.rb
arduino_firmata-0.3.5 lib/arduino_firmata/main.rb
arduino_firmata-0.3.4 lib/arduino_firmata/main.rb
arduino_firmata-0.3.3 lib/arduino_firmata/main.rb
arduino_firmata-0.3.2 lib/arduino_firmata/main.rb
arduino_firmata-0.3.1 lib/arduino_firmata/main.rb
arduino_firmata-0.3.0 lib/arduino_firmata/main.rb
arduino_firmata-0.2.9 lib/arduino_firmata/main.rb
arduino_firmata-0.2.8 lib/arduino_firmata/main.rb