Skip to content
Permalink
Browse files

Add gcode handler for `report_axis_timeout`

  • Loading branch information
ConnorRigby committed Oct 28, 2019
1 parent 75babb5 commit 69ea5e9bcf70cad83d319816e57e799f1aa42d5e
@@ -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
@@ -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, []}})
@@ -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()

@@ -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

0 comments on commit 69ea5e9

Please sign in to comment.
You can’t perform that action at this time.