Add gcode handler for `report_axis_timeout`

pull/1045/head
Connor Rigby 2019-10-28 08:06:00 -07:00 committed by Connor Rigby
parent 75babb5415
commit 69ea5e9bcf
4 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,12 @@ defmodule FarmbotCore.FirmwareSideEffects do
BotState.set_axis_state(axis, state)
end
@impl FarmbotFirmware.SideEffects
def handle_axis_timeout(axis) do
FarmbotCore.Logger.error 1, "Axis #{axis} timed out waiting for movement to complete"
:noop
end
@impl FarmbotFirmware.SideEffects
def handle_home_complete(_) do
:noop

View File

@ -683,6 +683,14 @@ defmodule FarmbotFirmware do
{:noreply, state}
end
def handle_report({:report_axis_timeout, [axis]} = code, state) do
if state.caller_pid, do: send(state.caller_pid, {state.tag, code})
for {pid, _code} <- state.command_queue, do: send(pid, {state.tag, {:report_busy, []}})
side_effects(state, :handle_axis_timeout, [axis])
{:noreply, state}
end
def handle_report({:report_calibration_state, calibration_state} = code, state) do
if state.caller_pid, do: send(state.caller_pid, {state.tag, code})
for {pid, _code} <- state.command_queue, do: send(pid, {state.tag, {:report_busy, []}})

View File

@ -28,6 +28,8 @@ defmodule FarmbotFirmware.SideEffects do
@type axis_state :: :stop | :idle | :begin | :crawl | :decelerate | :accelerate
@callback handle_axis_state([{axis(), axis_state}]) :: any()
@callback handle_axis_timeout(axis()) :: any()
@type calibration_state :: :idle | :home | :end
@callback handle_calibration_state([{axis(), calibration_state()}]) :: any()

View File

@ -111,6 +111,9 @@ defmodule FarmbotFirmware.StubSideEffects do
@impl SideEffects
def handle_axis_state(_), do: :noop
@impl SideEffects
def handle_axis_timeout(_), do: :noop
@impl SideEffects
def handle_calibration_state(_), do: :noop