Class: Mkduino::Probe

Inherits:
Object
  • Object
show all
Defined in:
lib/probe.rb

Constant Summary collapse

DEVICES =
["/dev/ttyUSB0",
"/dev/ttyUSB1",
"/dev/ttyUSB2",
"/dev/ttyACM0",
"/dev/ttyACM1",
"/dev/ttyACM2",
"/dev/rfcomm0",
"/dev/rfcomm1",
"/dev/rfcomm2"]
BOARDS =
{
  "mega" => {
    variant: "mega",
    clock_speed: 16000000,
    device: "/dev/ACM0",
    baud_rate: "115200",
    programmer: "stk500",
    mcu: "atmega2560"
  },
  "mega1280" => {
    variant: "mega",
    clock_speed: 16000000,
    device: "/dev/ACM0",
    baud_rate: "115200",
    programmer: "stk500",
    mcu: "atmega1280"
  },

  "uno" => {
    variant: "standard",
    clock_speed: 16000000,
    device: "/dev/USB0",
    baud_rate: "57600",
    programmer: "arduino",
    mcu: "atmega328p"

  },
  "mini" => {
    variant: "standard",
    clock_speed: 16000000,
    device: "/dev/USB0",
    baud_rate: "57600",
    programmer: "arduino",
    mcu: "atmega328p"
  },
  "mini3v" => {
    variant: "standard",
    clock_speed: 8000000,
    device: "/dev/USB0",
    baud_rate: "57600",
    programmer: "arduino",
    mcu: "atmega328p"
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(probe_options = {}) ⇒ Probe

Returns a new instance of Probe.



62
63
64
65
# File 'lib/probe.rb', line 62

def initialize probe_options = {}
  @probe_options = probe_options
  @options = {}
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/probe.rb', line 3

def options
  @options
end

#probe_optionsObject

Returns the value of attribute probe_options.



4
5
6
# File 'lib/probe.rb', line 4

def probe_options
  @probe_options
end

Instance Method Details

#probeObject



67
68
69
70
# File 'lib/probe.rb', line 67

def probe
  probe_device
  probe_variant
end

#probe_deviceObject



80
81
82
83
84
85
86
87
88
# File 'lib/probe.rb', line 80

def probe_device
  @options[:device] = DEVICES[0]
  DEVICES.each do |d|
    if File.exist?(d)
      @options[:device] = d
      break
    end
  end
end

#probe_variantObject



72
73
74
75
76
77
78
# File 'lib/probe.rb', line 72

def probe_variant
  if @options[:device] && @options[:device] =~ /ACM[0-9]/
    @options[:variant] = "mega"
  else
    @options[:variant] = "standard"
  end
end