Skip to content

Commit

Permalink
Merge pull request #1108 from FarmBot/rel-9.0.2
Browse files Browse the repository at this point in the history
v9.0.2 - Jolly Juniper
  • Loading branch information
RickCarlino authored Jan 9, 2020
2 parents 398f15c + 82fc90c commit 5a95d6c
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 49 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

# 9.0.2
* See notes for 9.0.1.

# 9.0.1
* Routine token updates on Circle CI.
* Fix bugs that were causing devices to erroneously factory reset under some circumstances.

# 9.0.0
* Run updates on Nerves systems.
* Updates to the way `set_servo_angle` is handled.
Expand Down
1 change: 0 additions & 1 deletion FEATURE_MIN_VERSIONS.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"api_pin_bindings": "6.4.4",
"assertion_block": "8.0.0",
"backscheduled_regimens": "6.4.0",
"boot_sequence": "8.3.0",
"change_ownership": "6.3.0",
"diagnostic_dumps": "6.4.4",
"endstop_invert": "6.4.1",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Download the version of FarmBot OS that corresponds to the FarmBot kit and compu

| FarmBot Kit | Computer | Download Link |
| --- | --- | --- |
| Genesis v1.2, Genesis v1.3, Genesis v1.4, Genesis XL v1.4 | Raspberry Pi 3 | [Download FBOS](https://github.com/FarmBot/farmbot_os/releases/download/v9.0.0/farmbot-rpi3-9.0.0.img) |
| Genesis v1.2, Genesis v1.3, Genesis v1.4, Genesis XL v1.4 | Raspberry Pi 3 | [Download FBOS](https://github.com/FarmBot/farmbot_os/releases/download/v9.0.2/farmbot-rpi3-9.0.2.img) |
| Express v1.0, Express XL v1.0 | Raspberry Pi Zero W | Coming soon |

---
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.0.0
9.0.2
4 changes: 2 additions & 2 deletions docs/target_development/provisioning_ota_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Publishing a FarmBotOS release requires coordination of a few different systems.

## Legacy Release System

The legacy system is somewhat simpiler. It goes as follows:
The legacy system is somewhat simpler. It goes as follows:

### Pull request into `master` branch

Expand Down Expand Up @@ -54,7 +54,7 @@ Beta releases are constructed by creating a tag off of the `staging` branch.

## NervesHub System

The NervesHub system is simpiler to use, but more complex to setup.
The NervesHub system is simpler to use, but more complex to setup.

### User registration

Expand Down
78 changes: 69 additions & 9 deletions docs/target_development/releasing_target_firmware.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,62 @@
# Publishing OTAs

## Beta
## Beta OTA channel

Publish an OTA to the `beta` channel can be done by:
Beta updates are simply tags matching the following semver string:

```
vMajor.Minor.Tiny-rcRC
```

for example:

```
v10.5.6-rc30
```

To publish an OTA, just tag a release matching that
string.

```bash
cd $FARMBOT_OS_ROOT_DIRECTORY
git checkout staging
git fetch --all && git reset --hard origin/staging
echo 10.5.6-rc30 > VERSION
# update the CHANGELOG, but DO NOT put the `rc`
# on the semver string.
$EDITOR CHANGELOG.md
git add CHANGELOG.md VERSION
git commit -m "Release v10.5.6-rc30"
git tag v$(cat VERSION)
git push origin staging v$(cat VERSION)
```

or call the helper script:
`./scripts/release_candidate.sh`

### NOTE about release candidate script

the helper script only **increments** the
RC version. Calling the `release-candidate` script
from a non rc version will fail. Example:

This will fail:

```bash
$ cat VERSION
10.5.6
./scripts/release_candidate.sh
```

This will succeed:

```bash
$ cat VERSION
10.5.6-rc44
./scripts/release_candidate.sh
```

## QA
## QA OTA channel

Publish an OTA to the `qa` channel can be done by pushing a new branch
to github with `qa/` prefix.
Expand All @@ -18,17 +66,29 @@ git checkout -b qa/<some-name>
git push origin qa/<some-name>
```

## Production
or to build a QA image from an existing branch:

```bash
git checkout -b some-feature
git commit -am "build out some feature"
git push origin some-feature some-feature:qa/some-featuer
```

## Stable OTA channel

Publish an OTA to the `stable` channel can be done by:
Publish an OTA to the `stable` OTA channel can be
done by pushing anything to the master branch:

```bash
git checkout -b rel-<version>
# update VERSION
echo $NEW_VERSION > VERSION
# update CHANGELOG.md
# update README.md
git commit -am "Release v<version>"
git push origin rel-<version>
$EDITOR CHANGELOG.md
# update the download link in the readme
$EDITOR README.md
git checkout -b rel-$(cat VERSION)
git commit -am 'Release v$(cat VERSION)'
git push origin rel-$(cat VERSION)
# open pull request
# merge pull request
# publish release once CI has completed
Expand Down
41 changes: 24 additions & 17 deletions farmbot_core/lib/farmbot_core/farmware_runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ defmodule FarmbotCore.FarmwareRuntime do
Handles execution of Farmware plugins.
"""

alias Avrdude.MuonTrapAdapter
alias FarmbotCeleryScript.AST
alias FarmbotCore.FarmwareRuntime.PipeWorker
alias FarmbotCore.AssetWorker.FarmbotCore.Asset.FarmwareInstallation
alias FarmbotCore.Asset.FarmwareInstallation.Manifest
alias FarmbotCore.AssetWorker.FarmbotCore.Asset.FarmwareInstallation
alias FarmbotCore.BotState.FileSystem
alias FarmbotCore.FarmwareRuntime.PipeWorker
alias FarmbotCore.Project
import FarmwareInstallation, only: [install_dir: 1]

Expand Down Expand Up @@ -67,15 +68,16 @@ defmodule FarmbotCore.FarmwareRuntime do

@doc "Stop a farmware"
def stop(pid) do
Logger.info "Terminating farmware process"
Logger.info("Terminating farmware process")

if Process.alive?(pid) do
GenServer.stop(pid, :normal)
end
end

def init([manifest, env, caller]) do
package = manifest.package
<<clause1 :: binary-size(8), _::binary>> = Ecto.UUID.generate()
<<clause1::binary-size(8), _::binary>> = Ecto.UUID.generate()

request_pipe =
Path.join([
Expand Down Expand Up @@ -109,8 +111,10 @@ defmodule FarmbotCore.FarmwareRuntime do
)

# Start the plugin.
Logger.debug "spawning farmware: #{exec} #{manifest.args}"
{cmd, _} = spawn_monitor(MuonTrap, :cmd, ["sh", ["-c", "#{exec} #{manifest.args}"], opts])
Logger.debug("spawning farmware: #{exec} #{manifest.args}")

{cmd, _} =
spawn_monitor(MuonTrapAdapter, :cmd, ["sh", ["-c", "#{exec} #{manifest.args}"], opts])

state = %State{
caller: caller,
Expand All @@ -125,7 +129,7 @@ defmodule FarmbotCore.FarmwareRuntime do
response_pipe_handle: resp
}

send self(), :timeout
send(self(), :timeout)
{:ok, state}
end

Expand All @@ -142,12 +146,12 @@ defmodule FarmbotCore.FarmwareRuntime do
end

def handle_info(msg, %{context: :error} = state) do
Logger.warn "unhandled message in error state: #{inspect(msg)}"
Logger.warn("unhandled message in error state: #{inspect(msg)}")
{:noreply, state}
end

def handle_info({:step_complete, ref, {:error, reason}}, %{scheduler_ref: ref} = state) do
send state.caller, {:error, reason}
send(state.caller, {:error, reason})
{:noreply, %{state | ref: nil, context: :error}}
end

Expand All @@ -159,7 +163,7 @@ defmodule FarmbotCore.FarmwareRuntime do
_reply = PipeWorker.write(state.response_pipe_handle, ipc)
# Make sure to `timeout` after this one to go back to the
# get_header context. This will cause another rpc to be processed.
send self(), :timeout
send(self(), :timeout)
{:noreply, %{state | rpc: nil, context: :get_header}}
end

Expand All @@ -174,14 +178,14 @@ defmodule FarmbotCore.FarmwareRuntime do
# didn't pick up the scheduled AST in a reasonable amount of time.
def handle_info(:timeout, %{context: :process_request} = state) do
Logger.error("Timeout waiting for #{inspect(state.rpc)} to be processed")
send state.caller, {:error, :rpc_timeout}
send(state.caller, {:error, :rpc_timeout})
{:noreply, %{state | context: :error}}
end

# farmware exit
def handle_info({:DOWN, _ref, :process, _pid, _reason}, %{cmd: _cmd_pid} = state) do
Logger.debug("Farmware exit")
send state.caller, {:error, :farmware_exit}
send(state.caller, {:error, :farmware_exit})
{:noreply, %{state | context: :error}}
end

Expand All @@ -200,14 +204,14 @@ defmodule FarmbotCore.FarmwareRuntime do
# error result of an io:read/2 in :get_header context
def handle_info({PipeWorker, _ref, {:ok, data}}, %{context: :get_header} = state) do
Logger.error("Bad header: #{inspect(data, base: :hex, limit: :infinity)}")
send state.caller, {:error, {:unhandled_packet, data}}
send(state.caller, {:error, {:unhandled_packet, data}})
{:noreply, %{state | context: :error}}
end

# error result of an io:read/2 in :get_header context
def handle_info({PipeWorker, _ref, error}, %{context: :get_header} = state) do
Logger.error("Bad header: #{inspect(error)}")
send state.caller, {:error, :bad_packet_header}
send(state.caller, {:error, :bad_packet_header})
{:noreply, %{state | context: :error}}
end

Expand All @@ -219,7 +223,7 @@ defmodule FarmbotCore.FarmwareRuntime do
# error result of an io:read/2 in :get_header context
def handle_info({PipeWorker, _ref, error}, %{context: :get_payload} = state) do
Logger.error("Bad payload: #{inspect(error)}")
send state.caller, {:error, :bad_packet_payload}
send(state.caller, {:error, :bad_packet_payload})
{:noreply, %{state | context: :error}}
end

Expand Down Expand Up @@ -247,10 +251,12 @@ defmodule FarmbotCore.FarmwareRuntime do
Logger.debug("executing rpc from farmware: #{inspect(rpc)}")
# todo(connor) replace this with StepRunner?
FarmbotCeleryScript.execute(rpc, ref)
{:noreply, %{state | rpc: rpc, scheduler_ref: ref, context: :process_request}, @error_timeout_ms}

{:noreply, %{state | rpc: rpc, scheduler_ref: ref, context: :process_request},
@error_timeout_ms}
else
{:error, reason} ->
send state.caller, {:error, reason}
send(state.caller, {:error, reason})
{:noreply, %{state | context: :error}}
end
end
Expand Down Expand Up @@ -300,6 +306,7 @@ defmodule FarmbotCore.FarmwareRuntime do
header =
<<@packet_header_token::size(16)>> <>
:binary.copy(<<0x00>>, 4) <> <<byte_size(payload)::big-size(32)>>

header <> payload
end
end
13 changes: 10 additions & 3 deletions farmbot_core/lib/farmbot_core/firmware_side_effects.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule FarmbotCore.FirmwareSideEffects do

@impl FarmbotFirmware.SideEffects
def handle_axis_timeout(axis) do
FarmbotCore.Logger.error 1, "Axis #{axis} timed out waiting for movement to complete"
FarmbotCore.Logger.error(1, "Axis #{axis} timed out waiting for movement to complete")
:noop
end

Expand All @@ -48,7 +48,7 @@ defmodule FarmbotCore.FirmwareSideEffects do

# this is a bug in the firmware code i think
def handle_encoders_scaled([]), do: :noop

@impl FarmbotFirmware.SideEffects
def handle_encoders_raw(x: x, y: y, z: z) do
:ok = BotState.set_encoders_raw(x, y, z)
Expand All @@ -64,6 +64,7 @@ defmodule FarmbotCore.FirmwareSideEffects do
%{param => value}
|> Asset.update_firmware_config!()
|> Asset.Private.mark_dirty!(%{})

:ok
end

Expand All @@ -75,27 +76,33 @@ defmodule FarmbotCore.FirmwareSideEffects do
@impl FarmbotFirmware.SideEffects
def handle_software_version([version]) do
:ok = BotState.set_firmware_version(version)

case String.split(version, ".") do
# Ramps
[_, _, _, "R"] ->
_ = Leds.red(:solid)
:ok = BotState.set_firmware_hardware("arduino")

# Farmduino
[_, _, _, "F"] ->
_ = Leds.red(:solid)
:ok = BotState.set_firmware_hardware("farmduino")

# Farmduino V14
[_, _, _, "G"] ->
_ = Leds.red(:solid)
:ok = BotState.set_firmware_hardware("farmduino_k14")

# Farmduino V15
[_, _, _, "H"] ->
_ = Leds.red(:solid)
:ok = BotState.set_firmware_hardware("farmduino_k15")

# Express V10
[_, _, _, "E"] ->
_ = Leds.red(:solid)
:ok = BotState.set_firmware_hardware("express_k10")

[_, _, _, "S"] ->
_ = Leds.red(:slow_blink)
:ok = BotState.set_firmware_version("none")
Expand Down Expand Up @@ -159,7 +166,7 @@ defmodule FarmbotCore.FirmwareSideEffects do
@impl FarmbotFirmware.SideEffects
def handle_debug_message([message]) do
fbos_config = Asset.fbos_config()
should_log? = fbos_config.firmware_debug_log || fbos_config.arduino_debug_messages
should_log? = fbos_config.firmware_debug_log || fbos_config.arduino_debug_messages
should_log? && FarmbotCore.Logger.debug(3, "Firmware debug message: " <> message)
end

Expand Down
2 changes: 1 addition & 1 deletion farmbot_ext/lib/farmbot_ext/jwt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule FarmbotExt.JWT do
{:ok, jwt}
else
:error -> {:error, "base64_decode_fail"}
{:error, _resson} -> {:error, "json_decode_error"}
{:error, _reason} -> {:error, "json_decode_error"}
end
end

Expand Down
Loading

0 comments on commit 5a95d6c

Please sign in to comment.