Fix estop being queued

This commit is contained in:
connor rigby 2018-01-04 14:26:37 -08:00
parent d2958f050f
commit 539e950edc
2 changed files with 11 additions and 6 deletions

View file

@ -52,8 +52,8 @@ config :farmbot, Farmbot.System.ConfigStorage,
config :farmbot, :behaviour,
authorization: Farmbot.Bootstrap.Authorization,
system_tasks: Farmbot.Host.SystemTasks,
update_handler: Farmbot.Host.UpdateHandler
# firmware_handler: Farmbot.Firmware.UartHandler
update_handler: Farmbot.Host.UpdateHandler,
firmware_handler: Farmbot.Firmware.UartHandler
config :farmbot, :uart_handler, tty: "/dev/ttyACM0"

View file

@ -191,10 +191,13 @@ defmodule Farmbot.Firmware do
def handle_call({fun, args}, from, state) do
next_current = struct(Current, from: from, fun: fun, args: args)
current_current = state.current
if current_current do
do_queue_cmd(next_current, state)
else
do_begin_cmd(next_current, state, [])
cond do
fun == :emergency_lock ->
do_begin_cmd(next_current, state, [])
match?(%Current{}, current_current) ->
do_queue_cmd(next_current, state)
is_nil(current_current) ->
do_begin_cmd(next_current, state, [])
end
end
@ -523,6 +526,8 @@ defmodule Farmbot.Firmware do
defp do_reply(state, reply) do
case state.current do
%Current{fun: :emergency_lock, from: from} ->
:ok = GenServer.reply from, {:error, :emergency_lock}
%Current{fun: _fun, from: from} ->
# Logger.success 3, "FW Replying: #{fun}: #{inspect from}"
:ok = GenServer.reply from, reply