Skip to content

Commit

Permalink
Merge pull request #607 from FarmBot/staging
Browse files Browse the repository at this point in the history
 Fix sound for Espeak.
  • Loading branch information
ConnorRigby authored Jul 30, 2018
2 parents bacdb21 + dd26097 commit 50c28f8
Show file tree
Hide file tree
Showing 12 changed files with 682 additions and 26 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ erl_crash.dump
/cache
*.js
/release-*
node_modules
/node_modules
/farmbot_ext
/farmbot_core
/farmbot_os

# Various env vars.
.env
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
# 6.4.6
* Add new RPC to reinitialize Firmware
* Tweak PinBinding debounce timeout.
* Update Linux system layer to fix sound

# 6.4.5
* Fix Firmware syncing applying _every_ setting.

Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Build Status](https://circleci.com/gh/FarmBot/farmbot_os/tree/staging.svg?style=svg)](https://circleci.com/gh/FarmBot/farmbot_os/tree/staging)
[![Coverage Status](https://coveralls.io/repos/github/FarmBot/farmbot_os/badge.svg?branch=staging)](https://coveralls.io/github/FarmBot/farmbot_os?branch=staging)
[![Built with Nerves](http://nerves-project.org/images/badge/nerves-badge_75x39_black.png)](http://nerves-project.org/)
# Build status
| Master Build Status | Staging Build Status | Beta Build Status |
| :---: | :---: | :---: |
| [![Master Build Status](https://circleci.com/gh/FarmBot/farmbot_os/tree/master.svg?style=svg)](https://circleci.com/gh/FarmBot/farmbot_os/tree/master) | [![Staging Build Status](https://circleci.com/gh/FarmBot/farmbot_os/tree/staging.svg?style=svg)](https://circleci.com/gh/FarmBot/farmbot_os/tree/staging) | [![Beta Build Status](https://circleci.com/gh/FarmBot/farmbot_os/tree/beta.svg?style=svg)](https://circleci.com/gh/FarmBot/farmbot_os/tree/beta)|
---

# FarmBot OS
Expand All @@ -10,14 +11,7 @@ The "brains" of the FarmBot Project
# :floppy_disk: LATEST OS IMAGE DOWNLOADS
<!-- DON'T CHANGE THE TEXT ABOVE. It is used in documentation links. -->

# _*Important*_
For now we are only building and supporting Raspberry Pi 3. Pull Requests are very welcome
if you spot a bug or fix, but for now we suggest obtaining a Raspberry Pi 3 for the best support.


|Raspbery Pi Version |
|---|
| :star: **[RPi 3 (Ships with FarmBot.io kits)](https://github.com/FarmBot/farmbot_os/releases/download/v6.4.3/farmbot-rpi3-6.4.3.img)**|
:star: **[RPi 3 (Ships with FarmBot.io kits)](https://github.com/FarmBot/farmbot_os/releases/download/v6.4.5/farmbot-rpi3-6.4.5.img)**
---

## Installation
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.5
6.4.6
10 changes: 9 additions & 1 deletion lib/farmbot/celery_script/ast/node/reboot.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
defmodule Farmbot.CeleryScript.AST.Node.Reboot do
@moduledoc false
use Farmbot.CeleryScript.AST.Node
allow_args []
allow_args [:package]
use Farmbot.Logger

def execute(%{package: :arduino_firmware}, _, env) do
env = mutate_env(env)
Logger.warn 1, "Reinitializing Arduino Firmware."
Farmbot.BotState.set_sync_status(:maintenance)
Farmbot.Firmware.Supervisor.reinitialize()
{:ok, env}
end

def execute(_, _, env) do
env = mutate_env(env)
Logger.warn 1, "Going down for a reboot!"
Expand Down
4 changes: 4 additions & 0 deletions lib/farmbot/farmware/farmware.ex
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ defmodule Farmbot.Farmware do
defp extract_url(%{"url" => url}) when is_binary(url), do: {:ok, url}
defp extract_url(_), do: {:error, "bad or missing farmware url"}

defp extract_exe(%{"executable" => "./" <> _ = path}) do
{:ok, path}
end

defp extract_exe(%{"executable" => exe}) when is_binary(exe) do
case System.find_executable(exe) do
nil -> {:error, "#{exe} is not installed"}
Expand Down
11 changes: 10 additions & 1 deletion lib/farmbot/farmware/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ defmodule Farmbot.Farmware.Runtime do

with :ok <- File.cd(fw_path),
env <- build_env(farmware, env) do
exec = farmware.executable
exec =
case farmware.executable do
"./" <> exe ->
file = Path.join(fw_path, exe)
File.chmod(file, 0o777)
file

"/" <> _ ->
farmware.executable
end

opts = [
:stream,
Expand Down
16 changes: 9 additions & 7 deletions lib/farmbot/pin_binding/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ defmodule Farmbot.PinBinding.Manager do
end

defp do_register(state, %PinBinding{pin_num: pin} = binding) do
%{state | registered: Map.put(state.registered, pin, binding), signal: Map.put(state.signal, pin, nil)}
%{state | registered: Map.put(state.registered, pin, binding), signal: Map.put(state.signal, pin, debounce_timer(binding, 1000))}
end

defp do_unregister(state, %PinBinding{pin_num: pin_num}) do
Expand Down Expand Up @@ -95,12 +95,13 @@ defmodule Farmbot.PinBinding.Manager do
if binding do
do_usr_led(binding, :off)
if state.signal[pin] do
IO.puts "[#{pin}] #{binding} is in debounced state"
Process.cancel_timer(state.signal[pin])
{:noreply, [], %{state | signal: Map.put(state.signal, pin, debounce_timer(pin))}}
{:noreply, [], %{state | signal: Map.put(state.signal, pin, debounce_timer(binding))}}
else
Logger.busy(1, "Pin Binding #{binding} triggered #{binding.special_action || "execute_sequence"}")
env = %Macro.Env{} = do_execute(binding, state.env)
{:noreply, [], %{state | env: env, signal: Map.put(state.signal, pin, debounce_timer(pin))}}
{:noreply, [], %{state | env: env, signal: Map.put(state.signal, pin, debounce_timer(binding))}}
end
else
Logger.warn(3, "No Pin Binding assosiated with: #{pin}")
Expand All @@ -123,8 +124,9 @@ defmodule Farmbot.PinBinding.Manager do
{:noreply, [], %{state | repo_up: true}}
end

def handle_info({pin, :ok}, state) do
{:noreply, [], %{state | signal: Map.put(state.signal, pin, nil)}}
def handle_info({:debounce, %PinBinding{pin_num: pin_num} = binding}, state) do
IO.puts "[#{pin_num}] #{binding} debounce state clear."
{:noreply, [], %{state | signal: Map.put(state.signal, pin_num, nil)}}
end

def handle_call({:register_pin, %PinBinding{pin_num: pin_num} = binding}, _from, state) do
Expand Down Expand Up @@ -205,8 +207,8 @@ defmodule Farmbot.PinBinding.Manager do
end
end

defp debounce_timer(pin) do
Process.send_after(self(), {pin, :ok}, 350)
defp debounce_timer(%PinBinding{} = binding, timeout_ms \\ 200) do
Process.send_after(self(), {:debounce, binding}, timeout_ms)
end

defp do_usr_led(%PinBinding{pin_num: 26}, signal), do: do_write(:white1, signal)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ defmodule Farmbot.Mixfile do
end

defp system("rpi3"),
do: [{:nerves_system_farmbot_rpi3, "1.2.1-farmbot.1", runtime: false}]
do: [{:nerves_system_farmbot_rpi3, "1.2.1-farmbot.2", runtime: false}]

defp package do
[
Expand Down
4 changes: 2 additions & 2 deletions mix.lock.rpi3
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"hackney": {:hex, :hackney, "1.13.0", "24edc8cd2b28e1c652593833862435c80661834f6c9344e84b6a2255e7aeef03", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.2.0", "2702ed3da5fd7a8130fc34b11965c8cfa21ade2f232c00b42d96d4967c39a3a3", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.0", "9634bca30f2f7468dde3e704d5865319b1eb88e4a8cded5c995baf0aa957524f", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"joken": {:hex, :joken, "1.5.0", "42a0953e80bd933fc98a0874e156771f78bf0e92abe6c3a9c22feb6da28efb0b", [:mix], [{:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"jose": {:hex, :jose, "1.8.4", "7946d1e5c03a76ac9ef42a6e6a20001d35987afd68c2107bcd8f01a84e75aa73", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"},
"jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], [], "hexpm"},
Expand All @@ -45,7 +45,7 @@
"nerves_network_interface": {:hex, :nerves_network_interface, "0.4.4", "200b1a84bc1a7fdeaf3a1e0e2d4e9b33e240b034e73f39372768d43f8690bae0", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"},
"nerves_runtime": {:hex, :nerves_runtime, "0.6.1", "0af96a0de0ec85bdbda349aa3bdbe999ce2236640bb21b2c8ca29a03388863b8", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:system_registry, "~> 0.5", [hex: :system_registry, repo: "hexpm", optional: false]}], "hexpm"},
"nerves_system_br": {:hex, :nerves_system_br, "1.3.2", "e8d617095ebc015f45065965a951d62805bdea2535a774189a705f8385e9d756", [:mix], [], "hexpm"},
"nerves_system_farmbot_rpi3": {:hex, :nerves_system_farmbot_rpi3, "1.2.1-farmbot.1", "9b7587112b5f923c3a4cdc214b470facdb1ffe260a1abeb5450a2874ba5f244c", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.3.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_arm_unknown_linux_gnueabihf, "1.0.0", [hex: :nerves_toolchain_arm_unknown_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm"},
"nerves_system_farmbot_rpi3": {:hex, :nerves_system_farmbot_rpi3, "1.2.1-farmbot.2", "4e5c6f8794eb9dc1515c1fa4fb59f2fa3e44682d5938d2ae654a784dae274735", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_system_br, "1.3.2", [hex: :nerves_system_br, repo: "hexpm", optional: false]}, {:nerves_system_linter, "~> 0.3.0", [hex: :nerves_system_linter, repo: "hexpm", optional: false]}, {:nerves_toolchain_arm_unknown_linux_gnueabihf, "1.0.0", [hex: :nerves_toolchain_arm_unknown_linux_gnueabihf, repo: "hexpm", optional: false]}], "hexpm"},
"nerves_system_linter": {:hex, :nerves_system_linter, "0.3.0", "84e0f63c8ac196b16b77608bbe7df66dcf352845c4e4fb394bffd2b572025413", [:mix], [], "hexpm"},
"nerves_toolchain_arm_unknown_linux_gnueabihf": {:hex, :nerves_toolchain_arm_unknown_linux_gnueabihf, "1.0.0", "39da5b503b977a594c9e386ca16a50c433b333797bc30ac941fd402ce1832274", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}, {:nerves_toolchain_ctng, "~> 1.4", [hex: :nerves_toolchain_ctng, repo: "hexpm", optional: false]}], "hexpm"},
"nerves_toolchain_ctng": {:hex, :nerves_toolchain_ctng, "1.4.0", "ec844dd286a5281223e023edb1359c8763fef79a3af9daac45397713cff1cb88", [:mix], [{:nerves, "~> 1.0", [hex: :nerves, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down
5 changes: 4 additions & 1 deletion platform/target/gpio/pin_binding_ale_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ defmodule Farmbot.Target.PinBinding.AleHandler do
end

def handle_call({:register_pin, num}, _from, state) do
with {:ok, pid} <- GPIO.start_link(num, :input),
with {:ok, out_pid} <- GPIO.start_link(num, :output),
:ok <- GPIO.write(out_pid, 0),
:ok <- GPIO.release(out_pid),
{:ok, pid} <- GPIO.start_link(num, :input),
:ok <- GPIO.set_int(pid, :both),
new_pins <-
Map.put(state.pins, num, %PinState{pin: num, pid: pid, state: nil, signal: :rising}) do
Expand Down
Loading

0 comments on commit 50c28f8

Please sign in to comment.