-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
burn
task to Upgrade by default
This changes the `mix burn` (and subsequently `mix firmware.burn`) to use the FWUP `upgrade` task by default. If the upgrade fails because the device does not actually have upgradable firmware on it, then the task will fallback to using the `complete` task to overwrite the device. You can also now specify `--overwrite` to force the `complete` task and wipe the data on the device with the new firmware. see #679
- Loading branch information
1 parent
6f6f223
commit b8c28e0
Showing
2 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
defmodule Mix.Nerves.FwupStream do | ||
@moduledoc """ | ||
IO Stream for Fwup | ||
This functions the same as IO.Stream to push fwup IO to stdio, but | ||
it also captures the IO for cases where you want to check the | ||
output programatically as well. | ||
""" | ||
|
||
defstruct device: :standard_io, line_or_bytes: :line, raw: true, output: "" | ||
|
||
def new(), do: %__MODULE__{} | ||
|
||
defimpl Collectable do | ||
def into(%{output: output} = stream) do | ||
{[output], collect(stream)} | ||
end | ||
|
||
defp collect(%{device: device, raw: raw} = stream) do | ||
fn | ||
acc, {:cont, x} -> | ||
case raw do | ||
true -> IO.binwrite(device, x) | ||
false -> IO.write(device, x) | ||
end | ||
|
||
[acc | x] | ||
|
||
acc, _ -> | ||
%{stream | output: IO.iodata_to_binary(acc)} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters