Class: Prremote::Commands::Undeploy

Inherits:
Object
  • Object
show all
Defined in:
lib/prremote/commands/undeploy.rb

Constant Summary collapse

ERASE_MAGIC =
'ERSE'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(port:, baud:) ⇒ Undeploy

Returns a new instance of Undeploy.



6
7
8
9
# File 'lib/prremote/commands/undeploy.rb', line 6

def initialize(port:, baud:)
  @port = port
  @baud = baud
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/prremote/commands/undeploy.rb', line 11

def call
  serial = Serial.new(@port, @baud)
  sleep 0.5
  serial.read(4096)

  serial.write(ERASE_MAGIC)
  wait_for_erased(serial)
  warn 'Flash erased. Device will no longer auto-run a script on boot.'
ensure
  serial&.close
end