Class: Workshop::Uploader

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/workshop/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, hex_filename) ⇒ Uploader

Returns a new instance of Uploader.



6
7
8
9
10
# File 'lib/workshop/uploader.rb', line 6

def initialize(project, hex_filename)
  self.project = project
  self.tools = Workshop::Tools.new project.arduino_hardware_directory
  self.hex_filename = hex_filename
end

Instance Attribute Details

#hex_filenameObject

Returns the value of attribute hex_filename.



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

def hex_filename
  @hex_filename
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#toolsObject

Returns the value of attribute tools.



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

def tools
  @tools
end

Instance Method Details

#com_portObject



12
13
14
# File 'lib/workshop/uploader.rb', line 12

def com_port
  project.com_port
end

#uploadObject



30
31
32
# File 'lib/workshop/uploader.rb', line 30

def upload
  sh upload_command
end

#upload_commandObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/workshop/uploader.rb', line 16

def upload_command
  [
    tools.avrdude,
    "-C #{tools.avrdude_config}",
    "-v -v -v -v -v -v",
    "-p #{project.build_mcu}",
    "-c #{project.programmer}",
    "-P #{project.com_port}",
    "-b #{project.baud_rate}",
    "-D",
    "-Uflash:w:#{hex_filename}:i"
  ].join(' ')
end